Is there any easy way to draw in TikZ an edge decorated with zigzag style, in which every corner is coloured, so that the result will be similar to:

enter image description here

I thought about creating such line by hand - by calculating all corners coordinates and drawing nodes there - but that seems very problematic, as I want to draw many such lines in different directions, I would also like to manipulate their segment lengths and amplitudes. Zigzag decoration just seems perfect for that - apart from no obvious way to colour corners.

Is there any nice way to do so? I'm new to TikZ.


1 Answer 1


You can add a marking decoration to a zigzag decoration.

enter image description here

The amplitude and segment length of the zigzag decoration will determine where the marks must be. The mark command can be used with distances or percentages, so mark=between positions .35355cm and 1 step .7071cm will place a mark starting at √2/4 cm and then every √2/2 cm, until position 1, which is the end of the path.


\usetikzlibrary{decorations.pathmorphing, decorations.markings}

    dot/.style={fill=red, circle, inner sep=0pt, minimum size=2mm},
        decorate, decoration={zigzag, amplitude=.25cm, segment length=1cm},
        postaction={decorate, decoration={markings, 
            mark=between positions .35355cm and 1 step .7071cm with{\node[dot]{};}}}




Kind of works with curves also:

\draw[dotzz](0,0) circle[radius=3cm];

enter image description here

You must log in to answer this question.

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