10
\$\begingroup\$

Seeing how hello world has backfired terribly, here is a harder one.

I love Zelda and I love ReBoot.

Create the following

enter image description here

Requirements:
It must be a window (can be ANY window even browsers and such).
The window can be of any size.
Window may not contain anything else except the picture.
Window should not close itself right away.
Triangles must be any shade of blue.
Circle must be any shade of green.
Smaller triangle must touch edges of the
No stealing images by providing links.

Condition: Shortest code wins.

PS: Yes ReBoot logo is slightly different but this is close enough to make it fun.

EDIT: I added another requirement. It seems like we have a lot of very genius people who enjoy finding loopholes :P I love you guys.

\$\endgroup\$

closed as too broad by Rɪᴋᴇʀ, ATaco, Mama Fun Roll, ETHproductions, mbomb007 Dec 20 '16 at 4:37

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ "Triangles must be any shade of yellow." Picture conflicts? \$\endgroup\$ – Timtech Nov 29 '13 at 14:51
  • \$\begingroup\$ @Timtech I am sorry, text got underlined as orange due to misspelling and I thought orange while wanting to write blue. \$\endgroup\$ – Quillion Nov 29 '13 at 15:02
  • 1
    \$\begingroup\$ Okay, at least it's fixed now. And I'm even trying to get shorter comments - too much code golfing... \$\endgroup\$ – Timtech Nov 29 '13 at 15:04
  • \$\begingroup\$ Do I get bonus points if the image fills the screen, and continues to as I resize the screen? (You have to allow the circle to be an oval then) \$\endgroup\$ – Cruncher Nov 29 '13 at 15:21
  • \$\begingroup\$ Actually reading the requirements again, what's stop someone from just creating the image in paint, and making a program read the image? This would only be a couple of lines in python. Perhaps you should write a rule against that \$\endgroup\$ – Cruncher Nov 29 '13 at 15:23

14 Answers 14

10
\$\begingroup\$

Mathematica 118 119 118 107 97

Edit: Shortened to 107 chars with help from Belisarius and to 97 with alephalpha.

CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}}, Green,
{2,1}~Circle~1}]

triangle

\$\endgroup\$
  • \$\begingroup\$ I was scared you had beat me :3 But that circle's gotta be green! \$\endgroup\$ – Timtech Nov 29 '13 at 16:17
  • \$\begingroup\$ It's green now. Thanks for noting. \$\endgroup\$ – DavidC Nov 29 '13 at 16:23
  • 1
    \$\begingroup\$ In 107: p=Polygon;a={1,1};b={2,0};CreateDialog[Graphics@{Blue,p@{0a,2b,2a},White,p@{a,b+a,b},Green,{2,1}~Circle~1}] \$\endgroup\$ – Dr. belisarius Nov 29 '13 at 22:36
  • 1
    \$\begingroup\$ CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}},Green,{2,1}~Circle~1}] \$\endgroup\$ – alephalpha Nov 30 '13 at 3:44
  • 3
    \$\begingroup\$ I got a little help from my friends. \$\endgroup\$ – DavidC Nov 30 '13 at 4:46
7
\$\begingroup\$

Dyalog APL (121 116 115)

(Edit: use triangles 8 elements wide instead of 10, to shorten code a bit)

(Edit 2: I was only ever using , so included the ¨ in the definition of M)

M←{' ',⍵,⍺,⍨4/0}¨⋄⎕SM←↑(256M⊃,/(⊂8 0)(⊂8 32)(⊂0 16)∘.+⊂(,⍳⍴Z)/⍨≤/¨,Z←⊖Z,⌽Z←2/⍳2/8),512M⌈0 16∘+¨1 2∘ר8+8×1 2∘○¨⍳1e4

Graphics? Who needs graphics?

(Also, black is the default background, you didn't say to change it)

enter image description here

\$\endgroup\$
4
\$\begingroup\$

Shell script: 166 163 characters

f=-fill
d=-draw
convert -size 64x32 xc: $f blue $d 'polygon 32,0 0,32 64,32' $f white $d 'polygon 32,32 16,16 48,16' $f none -stroke lime $d 'circle 32,16 32,0' x:

Sample output:

Triforce ReBoot logo

\$\endgroup\$
  • \$\begingroup\$ this is more of imagemagick than shell \$\endgroup\$ – mniip Dec 9 '13 at 13:25
  • \$\begingroup\$ @mniip, right. But as ImageMagick is primarily a library. If this was a PHP script using IMagick, the post heading would say PHP, not ImageMagick. Well, according to my logic. I am not against any heading improvement. But anyway, 2 of the 3 characters shortening since the first version are on shell side. :) \$\endgroup\$ – manatwork Dec 9 '13 at 13:44
4
\$\begingroup\$

R, 124, 122, 111

frame()
p=polygon
p(c(1,3,5)/5,c(1,3,1)/5,c=4)
p(c(2,4,3)/5,c(2,2,1)/5,c="white")
symbols(.6,.4,.1,i=1,a=T,f=3)

This produces the following picture in a plot window:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I think you can save one character by writing p=polygon, then p(c(1,3,5 etc. (BTW, on my system, the circle size scales differently than the triangles when the window is resized, and I have to play with it a bit to get the circle to intersect the corners of the "square".) \$\endgroup\$ – r.e.s. Dec 2 '13 at 4:57
  • \$\begingroup\$ @r.e.s. Thanks for the tip. The size of the circle is the major drawback of this solution. I wasn't able to figure out a short code to solve this problem. \$\endgroup\$ – Sven Hohenstein Dec 2 '13 at 8:05
  • \$\begingroup\$ @plannapus Great idea, thanks! This saved 11 characters. \$\endgroup\$ – Sven Hohenstein Dec 9 '13 at 16:39
3
\$\begingroup\$

Java, 434 358 349

import java.awt.*;
public class T
{
    public static void main(String[] a)
    {
        new Frame()
        {
            public void paint(Graphics g)
            {
                g.setColor(Color.BLUE);
                Polygon p=new Polygon(new int[]{50, 75, 100},new int[]{75, 50, 75},3);
                g.fillPolygon(p);
                p.translate(-25, 25);
                g.fillPolygon(p);
                p.translate(50, 0);
                g.fillPolygon(p);
                g.setColor(Color.green);
                g.drawOval(50, 50, 50, 50);
            }
        }.show();
    }
}

golfed

import java.awt.*;public class T{public static void main(String[] a){new Frame(){public void paint(Graphics g){g.setColor(Color.BLUE);Polygon p=new Polygon(new int[]{50,75,100},new int[]{75,50,75},3);g.fillPolygon(p);p.translate(-25,25);g.fillPolygon(p);p.translate(50,0);g.fillPolygon(p);g.setColor(Color.green);g.drawOval(50,50,50,50);}}.show();}}

Who knew golfing reduces code so much.

EDIT: Thanks manatwork for all your suggestions.

\$\endgroup\$
  • 1
    \$\begingroup\$ Please golf your code. \$\endgroup\$ – Kevin Cox Nov 29 '13 at 17:30
  • \$\begingroup\$ You still have useless spaces after parameter separator commas. And please use code block instead of inline code markup, so scripts like Code Golf UserScript Enhancement Pack can recognize it as code and displays its size. \$\endgroup\$ – manatwork Nov 29 '13 at 17:58
3
\$\begingroup\$

Game Maker Language, 167 165 155

EDIT 1 - I shaved off two characters by replacing c_green with 32768, the same value. The other color's values were longer than their predefined names.

EDIT 2 - Epic golf! Used variables for frequently used values, and forgot that newlines aren't needed (newlines count as two spaces).

The room (r) is predefined 64 by 32 with a white background. Object d is anywhere in room r. Draw Event code:

a=16b=32draw_set_color(c_blue)draw_triangle(0,b,64,b,b,0,0)draw_set_color(32768)draw_circle(b,a,a,1)draw_set_color(c_white)draw_triangle(a,a,48,a,b,b,0)

Result:

Output of room r

Ti84-Basic - 54 characters (but output is black and white)

:Line(0,0,2,0
:Line(0,0,1,1
:Line(2,0,1,1
:Circle(1,.5,.5
\$\endgroup\$
  • \$\begingroup\$ No pictures used! \$\endgroup\$ – Timtech Nov 29 '13 at 15:26
  • \$\begingroup\$ Does the figure appear in its own window? \$\endgroup\$ – DavidC Nov 29 '13 at 15:39
  • \$\begingroup\$ @DavidCarraher Yes. I used in-game screen capture, so the window doesn't show up. \$\endgroup\$ – Timtech Nov 29 '13 at 15:40
  • \$\begingroup\$ You used draw_set_color three times. Can't you save characters by something like d=draw_set_character? \$\endgroup\$ – DavidC Nov 29 '13 at 16:42
  • \$\begingroup\$ @DavidCarraher I tried that already; it doesn't work :( GML gets kind of stubborn sometimes. \$\endgroup\$ – Timtech Nov 29 '13 at 16:43
2
\$\begingroup\$

HTML, 101

<img style=position:absolute;clip:rect(30px,130px,110px,20px) src=http://i.stack.imgur.com/iE6m9.png>
\$\endgroup\$
  • 2
    \$\begingroup\$ There's a new requirement - "No stealing images by providing links." \$\endgroup\$ – Timtech Nov 29 '13 at 15:39
  • \$\begingroup\$ I bet you could beat that with a simple: http://someshort.url (... and that this would create another requirement as well) \$\endgroup\$ – Olivier Dulac Nov 29 '13 at 18:32
2
\$\begingroup\$

HTML+CSS, 352 290 261 257

<div style="width:0;border:50px solid #fff;border-bottom-color:#00f">
<p style="border:25px solid #00f;border-top-color:#fff;border-bottom:0;margin:25px 0 0 -25px">
<p style="border:1px solid #0f0;border-radius:50px;width:50px;height:50px;margin:-52px -26px">

http://jsfiddle.net/WF3hP/6/

Ungolfed:

<style>
    #blue-triangle {
        width:0;
        border:50px solid #fff;
        border-bottom-color:#00f
    }
    #white-triangle {
       border:25px solid #00f;
       border-top-color:#fff;
       border-bottom:0;
       margin:25px 0 0 -25px        
    }
    #circle {
       border:1px solid #0f0;
       border-radius:50px;
       width:50px;
       height:50px;
       margin:-52px -26px        
     }
</style>
<div id="blue-triangle">
<p id="white-triangle">
<p id="circle">
\$\endgroup\$
  • 1
    \$\begingroup\$ Instead of setting border-left and border-right separately, better set border then reduce the unneeded one like border-top:0: jsfiddle.net/WF3hP/2 \$\endgroup\$ – manatwork Nov 29 '13 at 16:41
  • \$\begingroup\$ Yes, I'd recommend that too. It will make your code shorter. \$\endgroup\$ – Timtech Nov 29 '13 at 16:42
  • \$\begingroup\$ @manatwork, even that can be improved with border-bottom-color instead of border-bottom on the first div and similarly border-top-color on the second div. And using 1em instead of 25px and 2em instead of 50px changes the size but saves a few characters. \$\endgroup\$ – Peter Taylor Nov 29 '13 at 16:51
  • \$\begingroup\$ Thanks, @manatwork & Pete Taylor. I tried using em instead of px, but it's hard to get the circle centred if its border has to be 1px wide. \$\endgroup\$ – Danko Durbić Nov 29 '13 at 19:21
  • \$\begingroup\$ Do the id's really have to be that long? \$\endgroup\$ – Timtech Dec 1 '13 at 23:57
2
\$\begingroup\$

R, 108 characters

Very similar to Sven Hohenstein solution but differs in two interesting points, so I thought I would add it:

frame()
p=polygon
p(c(0:3,1:4)/5,c(0:1,0:1,1:2,1:0)/5,c=4)
t=seq(0,2*pi,.1)
p(.2*cos(t)+.4,.2*sin(t)+.2,b=3)

Instead of drawing a large blue triangle and a small white one, I draw a polygon representing already the three triangles. As for the circle, this one (whose code is clearly longer than Sven's) doesn't lose its contacts with the triangles on resize.
Finally instead of using the color names I used their number in R's default color palette (4 for blue and 3 for green).

enter image description here

\$\endgroup\$
1
\$\begingroup\$

JavaScript (canvas, Firefox), 237 231 characters

<body onload=with(c=document.all.a.getContext('2d'))fillStyle='#00F',strokeStyle='#0F0',mozFillRule='evenodd',c.f=lineTo,moveTo(4,0),f(8,4),f(0,4),f(2,2),f(6,2),f(4,4),f(2,2),fill(),beginPath(),arc(4,2,2,0,7),stroke()><canvas id=a>

I couldn't find any hard requirements on the dimensions, so I decided to abuse that a bit and go with 8×4 pixels to cut down code size... also, relies on the Mozilla extension mozFillRule to get even-odd filling for the triforce.

jsbin (small), jsbin (bigger)

\$\endgroup\$
1
\$\begingroup\$

SVG 305 296

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="1 3 9 10">
<path d="M 5,4 2.5,7 7.5,7 5,4 z M 7.5,7 5,10 10,10 7.5,7 z M 5,10 2.5,7 0,10 5,10 z"
fill="#00f" /><path d="m 7.5,7 a 2.5,3 0 0 1 -5,0 2.5,3 0 1 1 5,0 z"
fill="none" stroke="#0f0" stroke-width="0.02" /></svg>

Firefox window with svg draw

\$\endgroup\$
  • \$\begingroup\$ Instead of style="fill:#00f", you can use fill="#00f", I think. Same for the other styles. \$\endgroup\$ – Ry- Nov 30 '13 at 1:15
  • \$\begingroup\$ @minitech: I must be able to save 5 more bytes in shifting this drawing up by 1: having vertical plan from 2 to 9 instead of 3 to 10... \$\endgroup\$ – F. Hauri Dec 3 '13 at 21:54
1
\$\begingroup\$

HTML 118

<svg><path fill=#00f d="M0,2 2,0 4,2 2,2 3,1 1,1 2,2z"/><circle fill=none stroke-width=.1 stroke=#0f0 cx=2 cy=1 r=1 />
\$\endgroup\$
1
\$\begingroup\$

Sage (CLI), 111 106

p=polygon;circle((2,1),1,color=(0,1,0))+p([(0,0),(2,2),(4,0)])+p([(1,1),(3,1),(2,0)],axes=0,color=(1,1,1))

image in window created by Sage This is via the Sage command line interface. (This works also in a Sage Notebook, but although the image appears in its own cell, that probably doesn't qualify as a "window".)

EDIT: Eliminated 5 minus signs and replaced the screenshot of a Sage Notebook cell with one of a Sage CLI window. (Credit @boothby)

\$\endgroup\$
  • \$\begingroup\$ If you call .show() on a graphics object from the CLI, it will pop up a window. Also you can save a few characters by shifting everything (+2,+1). \$\endgroup\$ – boothby Dec 3 '13 at 18:08
  • \$\begingroup\$ @boothby - Thanks for the idea to get rid of the minus signs. About the window, it turns out that running the program as-is (without .show()) produces the desired window from the Sage CLI. (Neither this nor the .show() version works when I run Sage under Linux in a virtual machine (Win7/VirtualBox). Works fine when I boot up Ubuntu and run Sage that way.) Thanks for the nudge to try the CLI. \$\endgroup\$ – r.e.s. Dec 4 '13 at 2:44
0
\$\begingroup\$

Golf-Basic 84, 36 characters (Output is Black and White)

l;0,0,2,0l;0,0,1,1l;2,0,1,1c;1,.5,.5
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.