I'm trying to recreate this figure, but unfortunately I no longer have access to its source material:


So far I've figured out how to draw the rectangle:



\definecolor{viewbutton_border}{RGB}{113, 145, 203}
\definecolor{viewbutton_top}{RGB}{143, 171, 217}
\definecolor{viewbutton_bottom}{RGB}{115, 147, 204}

    \node (button) at (0,0) [
        top color=viewbutton_top, 
        bottom color=viewbutton_bottom,
        rounded corners=0.5mm, 
        line width=0.4mm,
        minimum width=1.72cm,
        minimum height=1.37cm,
    ] {};
    % how to draw the arrows?


And now I'm lost figuring out how to draw these arrows with TikZ inside the rectangle. Do you have any suggestions?


3 Answers 3


The basic idea is to use a path picture to draw the arrows over the background of the node. Inside the path picture a special node path picture bounding box is available which is a rectangle which covers the extent of the node path.

The calc library is used to calculate start and end points points along the diagonals from the center of the path picture bounding box to each of its corners and also to calculate the height and width of the node. The minimum of the height and width is used as a basis for the thickness of the line and the dimensions of the arrowhead. Then the arrow is drawn using the Triangle arrow tip from the arrows.meta library.

I have also assumed that the border of the button should scale with the size of the button, which is passed as a parameter to the view button style.

\definecolor{vbborder}{RGB}{93, 120, 190}
\definecolor{vbtop}{RGB}{143, 171, 217}
\definecolor{vbbottom}{RGB}{115, 147, 204}
\tikzset{view button/.style={
  minimum width={#1}, minimum height={(#1)*1.37/1.72},
  line width={(#1)/20}, rounded corners={(#1)/5},
  top color=vbtop, 
  bottom color=vbbottom, 
  path picture={
    \foreach \i in {45,135,225,315}
      \draw let \p1=(path picture bounding box.center),
        \p2=(path picture bounding box.\i),
        \n1={min(abs(\x2-\x1),abs(\y2-\y1))} in
        [white, line width=\n1/4, -{Triangle[width=\n1*.75,length=\n1*.375]}]
        ($(\p1)!0.175!(\p2)$) -- ($(\p1)!0.7!(\p2)$);
view button/.default=1cm}
\coordinate (v);
\foreach \i in {1,...,5}
  \node [view button=\i*10pt, above=5pt of v] (v) {};

enter image description here

  • This is very impressive and uses many techniques that I'm unfamiliar with. Would you care to explain the general principle? I see some control flow and use of path picture... how does it work?
    – Korijn
    Dec 31, 2016 at 15:29
  • 1
    @Korijn see the updated answer. Dec 31, 2016 at 16:39
  • This answer taught me a lot about Tikz, and solved the problem perfectly, retaining the background gradient. Thanks.
    – Korijn
    Jan 1, 2017 at 21:30

I draw some squares like this. First, the background blue rectangle. Above that, a white square. On top of that, four squares, tilted at 45°, so that their tips will fall on the x or y axis. Last a blue square in the middle it.


\definecolor{bborder}{RGB}{113, 145, 203}
\definecolor{bbottom}{RGB}{115, 147, 204}
\definecolor{btop}{RGB}{255, 255, 255}

  % Draw the outer blue rectangle/square
  \draw[ultra thick, rounded corners, draw=bborder, fill=bbottom]
  (-10,-8.1) -- (-10,8.1) -- (10,8.1) -- (10,-8.1);
  % Draw the white square
  (-6.3,-6.3) -- (-6.3,6.3) -- (6.3,6.3) -- (6.3,-6.3) -- cycle;
  % Draw four squares, each tilted at 45° filled in blue
  \draw[draw=bbottom, fill=bbottom]
  (0,-7.9) -- (-3.1,-4.8) -- (0,-1.7) -- (3.1,-4.8) -- cycle;
  \draw[draw=bbottom, fill=bbottom]
  (0,7.9) -- (-3.1,4.8) -- (0,1.7) -- (3.1,4.8) -- cycle;
  \draw[draw=bbottom, fill=bbottom]
  (-7.9,0) -- (-4.8,-3.1) -- (-1.7,0) -- (-4.8,3.1) -- cycle;
  \draw[draw=bbottom, fill=bbottom]
  (7.9,0) -- (4.8,-3.1) -- (1.7,0) -- (4.8,3.1) -- cycle;
  % A last square on top in the middle, again in blue
  (-2.5,0) -- (0,-2.5) -- (2.5,0) -- (0,2.5);

This is my result. Please, polish my code to your needs.

enter image description here

  • Nice out-of-the-box thinking! Unfortunately, I really want the gradient in the background to remain visible and I'm not sure how I would accomplish that with this approach. It looks very pretty though!
    – Korijn
    Dec 31, 2016 at 15:32
  • 1
    @Korijn: Oh yes. You are right. Bear with me, this was my second attempt on TkiZ. It was a good learning experience.
    – Jan
    Dec 31, 2016 at 18:32

A short code with pstricks, compilable with pdflatex if you add the switch --enable-write18 for MiKTeX, or -shell-escape for TeX Live and MacTeX:

\documentclass[x11names, border=3pt]{standalone}

\psset{unit=1mm, linecolor=white, linejoin=1}%


\psframe[unit=2cm, linewidth=3pt, linecolor=SteelBlue3, fillstyle=solid, fillcolor=LightSteelBlue3, framearc=0.1](-1,-1)(1,1)%
\multido{\i = 45 + 90}{4}{\rput{\i}(0.4; \i) {\BigArrow}}


enter image description here

  • If possible I would prefer to stick with utilities that are "available by default". It's easier to deploy in automated systems. I'm also unfamiliar with pstrick so a Tikz solution would be preferable to me.
    – Korijn
    Dec 31, 2016 at 15:34
  • 1
    The switch is necessary only if you compile with pdflatex. Otherwise, you can remove loading of auto-pst-pdf, and either: – follow the classic latex->dvips->pstopdf way, or – compile with xelatex.
    – Bernard
    Dec 31, 2016 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .