Draw the Warm Welcome Secret Hat

SVG (462 460 454 429 384 365 bytes)

I know it isn't a programming language, but I thought this will at least be useful to anyone generating SVG output...

This is based on Peter Taylor's SVG.

By using the original coords, and optimizing the paths a little, I managed to shrink the SVG down. I also fixed the colours.

<svg><g stroke-linecap=round stroke-linejoin=round stroke-width=26><path d=M54,13,13,36V75H151V36L110,13 stroke=#1f1a1a /><path d=M21,84V36H37A91,91,0,0,1,127,36h16V84z stroke=#404040 /><path d=M30,36v48h104V36z stroke=#58585c fill=#58585c /></g><circle cx=82 cy=60 r=23 fill=#ffca57 stroke=#ff1c22 stroke-width=5 /><path d=M82,43,92,74,66,55H98L72,74z fill=#ff1c22

Update: Fixed flaw pointed out by Peter Taylor and position of rects and saved 2 more bytes.

Update 2: Incorporated another fix and suggestions from Peter (-6 bytes)

Update 3: Just noticed the instructions now specify all radii are 13, so taking advantage of that, and optimizing the paths a bit more, I saved another 25 bytes. More readable fiddle here.

Update 4: Since I am already assuming the SVG is embedded in HTML (standalone SVGs need the namespace declaration), I can actually squeeze this more. (a) I don't need the width and height attributes because the size of the SVG is smaller than the default size browsers give to objects whose size is indeteminate (300x150), and (b) the HTML parser is forgiving about attributes which don't have quotes, so some of them can be removed (idea from Squeamish Ossifrage). Saves another 45 bytes.

Update 5: Using hsl's tricks for de-quoting the colours and dropping the trailing end tags. We saved another 19 bytes. The latter seemed a bit cheaty to me at first, but since it works in all browsers, I changed my mind. :) Thanks hsl!


Mathematica 787 612 600 514 506 bytes

Surprising amount of code needed. Will surely be beaten.

Ungolfed form

red=RGBColor[1.,.11,.13]
yellow=RGBColor[1.,.79,.34]
lightGrey=RGBColor[.35,.35,.36]
midGrey=RGBColor[.25,.25,.25]
r=RoundingRadius->8;
pentagonalVertices[offset_]:=Table[{Cos[2π k/5+ offset],Sin[2π k/5+offset]},{k,0,5}];
x=63;x2=72;
y=37;
pts={{e=22,50},{h=72,30},{h,-17},{-h,-15},{-h,30},{-e,50}};
pts2={{-h,-15},{-h,30},{-e,50}}
Graphics[{
{Black,Thickness[.13],JoinForm["Round"],CapForm["Round"], Line[pts]},
midGrey,Rectangle[{-x2,-y},{x2,y},r],
Disk[{0,-55},104,{Pi/3,2Pi/3}],
White,Rectangle[{-40,-60},{40,0},r],
lightGrey,Rectangle[{-x,-y},{x,y},r],
red,Disk[{0,0},25],yellow,Disk[{0,0},19.5],red,
GraphicsComplex[16.7 pentagonalVertices[Pi/2],Polygon[{1,3,5,2,4}]],
GraphicsComplex[6.4 pentagonalVertices[3 Pi/2],Polygon[{1,2,3,4,5}]]}]

hat

Golfed

g=GraphicsComplex;c=RGBColor;d=c[1.,.11,.13];o="Round";k=Rectangle;j=Disk;n=Polygon;r=RoundingRadius->8;w@s_:=Table[{Cos[2\[Pi]k/5+s],Sin[2\[Pi]k/5+s]},{k,0,5}];x=63;i=72;y=37;p={{e=22,50},{h=72,30},{h,-17},{-h,-15},{-h,30},{-e,50}};Graphics[{Thickness[.13],JoinForm@o,CapForm@o,Line@p,c[.25,.25,.25],k[{-i,-y},{i,y},r],j[{0,-55},104,{\[Pi]/3,2\[Pi]/3}],White,k[{-40,-60},{40,0},r],c[.35,.35,.36],k[{-x,-y},{x,y},r],d,j[{0,0},25],c[1.,.79,.34],j[{0,0},19.5],d,g[16.7w[\[Pi]/2],n[{1,3,5,2,4}]],g[6.4w[3\[Pi]/2],n[{1,2,3,4,5}]]}]

HTML + ES6, 533

<canvas id=D width=600 height=400><script>c=D.getContext('2d')
S=x=>c.strokeStyle=F(x)
F=x=>c.fillStyle=x
W=x=>c.lineWidth=x
B=x=>c.stroke()||c.fill()||c.beginPath()
G='s.charCodeAt(i++)*9-300,'
L=s=>B()||eval('for(i in s)i%2||c.lineTo('+G+G+'0)')&&B()
c.lineCap=c.lineJoin='round'
W(60)
S('#1F1A1A')
L(';,+3+BXBX3H,')
S('#404040')
L('.3.EUEU3.3')
c.arc(291,390,270,4,5.2,0)
B()
S('#58585C')
L('131ERER313')
S(R='#FF1C22')
F('#FFCA57')
W(30)
c.arc(291,240,69,0,7,0)
B()
c.font='105px serif'
S(R)
c.fillText('\u2605',239,276)</script>

Snippet (modified):

<canvas style="margin:-40px 0 0 100px;height:250px;" id=D width=600 height=400><script>stages=[function(){c=D.getContext('2d');S=function(x){return c.strokeStyle=F(x)};F=function(x){return c.fillStyle=x};W=function(x){return c.lineWidth=x};B=function(x){return c.stroke()||c.fill()||c.beginPath()};G='s.charCodeAt(i++)*9-300,';L=function(s){return B()||eval('for(i in s)i%2||c.lineTo('+G+G+'0)')&&B()}},function(){c.lineCap=c.lineJoin='round';W(60);S('#1F1A1A');L(';,+3+BXBX3H,')},function(){S('#404040');L('.3.EUEU3.3')},function(){c.arc(291,390,270,4,5.2,0);B()},function(){S('#58585C');L('131ERER313')},function(){S(R='#FF1C22');F('#FFCA57');W(30);c.arc(291,240,69,0,7,0);B()},function(){c.font='105px serif';S(R);c.fillText('\u2605',239,276)}];next=function(i){stages[i]();if(i<6)setTimeout(next,1000,i+1)};next(0)</script>

hat!