7

How would you draw the Stack Overflow icon with TikZ?

  • 2
    Nice question! I got this idea of \usetikzlibrary{arrows}\tikz\draw[loosely dashed,[-,line width=1em] (0,0) to[out=90,in=180] (1,1.5);, but couldn't quite get it to work. Yet, anyway. – morbusg Mar 31 '16 at 14:13
  • Don't forget to attribute this work! – Clément Mar 31 '16 at 14:27
  • 2
    Is this what's known as "TeX-golf"? Is this on the correct site? ;) – Dɑvïd Mar 31 '16 at 17:15
12

Here is the first approach:

\documentclass[tikz, border=20mm]{standalone}

\definecolor{soorange}{RGB}{244,128,36}
\definecolor{sogray}{RGB}{188,187,187}

\pgfmathsetmacro\ae{54}          % end angle
\pgfmathsetmacro\as{.25*\ae}     % start angle
\pgfmathsetmacro\ch{29}          % cup height
\pgfmathsetmacro\cw{69}          % cup width
\pgfmathsetmacro\sw{44}          % stack width
\pgfmathsetmacro\sc{43}          % stack clip
\pgfmathsetmacro\sy{17}          % stack yshift
\pgfmathsetmacro\sx{\sc+.5*\sw}  % stack xshift
\pgfmathsetmacro\eh{9}           % line width

\begin{document}

\begin{tikzpicture}[x=1mm, y=1mm,
    stack/.style={line width=9mm, soorange},
    cup/.style={line width=9mm, sogray}
    ]
    \draw[cup] (-.5*\cw,\ch) -- (-.5*\cw,0) -- (.5*\cw,0) -- (.5*\cw,\ch);
    \begin{scope}[shift={(\sx,\sy)}]
        \foreach \x in {0,\as,...,\ae}
            \draw[stack] (180-\x:\sc) -- (180-\x:\sc+\sw);
    \end{scope}
\end{tikzpicture}

\end{document}

I hope I'm not violating the Guidelines for the Use of the Stack Exchange Trademarks! If so, please let me know.

Stack Overflow icon

  • 1
    Or \tikz[line width=9mm]{\foreach \x in {180,170,...,140}{\draw[soorange] (\x:10) -- (\x:6);}\draw[sogray] (175:11) |- ++(2,-2.5) -| (170:5);} in short without the fine tuning – percusse Mar 31 '16 at 12:14
  • 1
    @percusse I wanted to code golf against you, but then I realized that the rules are not precise : the rotation is between 12° and 13° and the center is moving ... so may be the next time ;) – Kpym Mar 31 '16 at 19:18
9
  • I have downloaded the official logo in EPS.
  • Then I used dvisvgm to convert it to svg :

    dvisvgm --eps so-logo.eps so-logo.svg
    
  • Then I opened the svg in chrome and using "Inspect element" I identified the logo part of the code

    <path clip-path="url(#clip1)" d="M84.0703 -10.52V-42.0703H94.5898V0H0V-42.0703H10.5156V-10.52H84.0703Z" fill="#bbc8c8"/>
    <path clip-path="url(#clip1)" d="M21.043 -21.0352H73.625V-31.5508H21.043V-21.0352ZM68.1719 -117.867L59.7344 -111.594L91.1133 -69.4023L99.5508 -75.6797L68.1719 -117.867ZM42.0898 -92.9961L82.4922 -59.3437L89.2227 -67.4258L48.8164 -101.074L42.0898 -92.9961ZM28.8984 -69.6094L76.5625 -47.4102L81.0039 -56.9453L33.3359 -79.1445L28.8984 -69.6094ZM22.0898 -44.9727L73.5469 -34.1562L75.7109 -44.4492L24.25 -55.2617L22.0898 -44.9727Z" fill="#fe6303"/>
    
  • And so finally using svg.path library I obtained using copy/paste the logo.

    \documentclass[tikz, border=7mm]{standalone}
    \usetikzlibrary{svg.path}
    \definecolor{org}{HTML}{FE6303}
    \definecolor{gry}{HTML}{BBC8C8}
    
    \begin{document}
      \begin{tikzpicture}[yscale=-1]
        \fill[gry] svg{M84.0703 -10.52V-42.0703H94.5898V0H0V-42.0703H10.5156V-10.52H84.0703Z};
        \fill[org] svg{M21.043 -21.0352H73.625V-31.5508H21.043V-21.0352ZM68.1719 -117.867L59.7344 -111.594L91.1133 -69.4023L99.5508 -75.6797L68.1719 -117.867ZM42.0898 -92.9961L82.4922 -59.3437L89.2227 -67.4258L48.8164 -101.074L42.0898 -92.9961ZM28.8984 -69.6094L76.5625 -47.4102L81.0039 -56.9453L33.3359 -79.1445L28.8984 -69.6094ZM22.0898 -44.9727L73.5469 -34.1562L75.7109 -44.4492L24.25 -55.2617L22.0898 -44.9727Z};
      \end{tikzpicture}
    \end{document}
    

enter image description here

Clarification note

If somebody think that the person who has designed this logo is a mathematician and that the lines are obtained by simple rotation, he can check the following image:

enter image description here

And the code to obtain this image is here :

\documentclass[tikz, border=7mm]{standalone}
\usetikzlibrary{svg.path, calc, spy}
\definecolor{org}{HTML}{FE6303}
\definecolor{gry}{HTML}{BBC8C8}

\begin{document}
  \begin{tikzpicture}[spy using outlines={circle, blue, magnification=3, size=1.5cm, connect spies}]
    \begin{scope}[yscale=-1,x=1pt,y=1pt]
      \fill[gry] svg{M84.0703 -10.52V-42.0703H94.5898V0H0V-42.0703H10.5156V-10.52H84.0703Z};
      \fill[org] svg{M21.043 -21.0352H73.625V-31.5508H21.043V-21.0352ZM68.1719 -117.867L59.7344 -111.594L91.1133 -69.4023L99.5508 -75.6797L68.1719 -117.867ZM42.0898 -92.9961L82.4922 -59.3437L89.2227 -67.4258L48.8164 -101.074L42.0898 -92.9961ZM28.8984 -69.6094L76.5625 -47.4102L81.0039 -56.9453L33.3359 -79.1445L28.8984 -69.6094ZM22.0898 -44.9727L73.5469 -34.1562L75.7109 -44.4492L24.25 -55.2617L22.0898 -44.9727Z};

      % take the coordinates
      \draw[blue]
        (21.043 , -21.0352) coordinate (A1) -- (73.625 , -21.0352) coordinate (B1) (73.625 , -31.5508) coordinate (C1)-- (21.043 , -31.5508) coordinate (D1)
        (22.0898, -44.9727) coordinate (A2) -- (73.5469, -34.1562) coordinate (B2) (75.7109, -44.4492) coordinate (C2)-- (24.25  , -55.2617) coordinate (D2)
        (28.8984, -69.6094) coordinate (A3) -- (76.5625, -47.4102) coordinate (B3) (81.0039, -56.9453) coordinate (C3)-- (33.3359, -79.1445) coordinate (D3)
        (42.0898, -92.9961) coordinate (A4) -- (82.4922, -59.3437) coordinate (B4) (89.2227, -67.4258) coordinate (C4)-- (48.8164, -101.074) coordinate (D4)
        (59.7344, -111.594) coordinate (A5) -- (91.1133, -69.4023) coordinate (B5) (99.5508, -75.6797) coordinate (C5)-- (68.1719, -117.867) coordinate (D5);
      % draw the middle lines
      \begin{scope}[black, shorten >=-3cm]
        \draw ($(A1)!.5!(D1)$) -- ($(C1)!.5!(B1)$);
        \draw ($(A2)!.5!(D2)$) -- ($(C2)!.5!(B2)$);
        \draw ($(A3)!.5!(D3)$) -- ($(C3)!.5!(B3)$);
        \draw ($(A4)!.5!(D4)$) -- ($(C4)!.5!(B4)$);
        \draw ($(A5)!.5!(D5)$) -- ($(C5)!.5!(B5)$);
      \end{scope}
    \end{scope}
    % spy on the crossings
    \spy on (4.5,1) in node at (5,3);
  \end{tikzpicture}
\end{document}
  • have you tried to fit an ellipse contour to the left sides ? perhaps this will work better than trying a circle for the right sides. – user4686 Mar 31 '16 at 20:33
  • @jfbu good idea ... or some nice polynomial curve, through the middle points ... but all of this is for somebody that is doing algebraic geometry ;) – Kpym Apr 1 '16 at 5:09
  • we are talking about logo designers, forget about math ;) – percusse Apr 1 '16 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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