First part of my question is answered already in the question itself, see Edit #1.
For rounding corners and using a [0,1] interval when addressing lengths during clipping I came up with this solution:
\begin{tikzpicture}[x=72pt,y=36pt]
\draw[clip] (0, 1)
-- (0, 0.2)
decorate [decoration={random steps,segment length=4pt,amplitude=2pt},
rounded corners=1pt] {-- (1, 0.1)}
-- (1, 1)
--cycle;
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=72pt]{black.png}};
\end{tikzpicture}
First I added the rounded corners
option to the decorated path. Second I specified the exact size of the tikzpicture at the start: \begin{tikzpicture}[x=72pt,y=36pt]
. This may not be the most elegant solution but works like a charm, see the picture below (the blue box illustrates the size of the original picture).
You can use a decoration
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,
mark=between positions 0 and 1 step 6pt
with { \draw [fill] (0,0) circle [radius=2pt];}}]
\path[postaction={decorate}] (0,0) to (4,0);
\end{tikzpicture}
\end{document}
Or using decorations.shapes
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.shapes}
\begin{document}
\tikzset{decorate sep/.style 2 args=
{decorate,decoration={shape backgrounds,shape=circle,shape size=#1,shape sep=#2}}}
\begin{tikzpicture}
\draw[decorate sep={2mm}{4mm},fill] (0,0) -- (4,0);
\draw[decorate sep={2mm}{6mm},fill] (0,1) -- (4,1);
\draw[decorate sep={1mm}{4mm},fill] (0,2) -- (4,2);
\end{tikzpicture}
\end{document}
Best Answer
You could define a custom dash pattern with an
on
length of0pt
. If you setline cap=round
, you'll end up with perfect circles. Thedash pattern
approach is much faster than usingdecorations
for the same purpose.The whole thing can of course be made into a new style so you just have to use
dots
, and which allows you to comfortably set the dot diameter usingdot diameter
and the dot spacing usingdot spacing