I can't find much information about creating TikZ fill patterns or even using the custom built-in patterns. Look to do all the common fills like lines, hatches, dots, stars, etc… I need to be able to control the scale, too. (The patterns I did end up finding were way to large.)
Google doesn't seem to return much info on TikZ fill patterns.
Best Answer
Customizing an existing pattern
The
fivepointed star
pattern is defined inpgflibrarypatterns.code.tex
asIf you want to change the size of stars or how far away they are of each other, you just need to change the
1mm
and3mm
values respectively, but you need to define a new pattern for that. If you want full flexibility, you need to define a pattern with variables which you can adjust. Let's say we want thestarsize
andstarspread
parameters to customize the pattern. We first define the lengths:then declare the corresponding tikz keys:
then set the default values:
and finally declare the pattern itself using our variables:
You can then just use things like
\draw[pattern=custom fivepointed stars,starspread=1.5mm,starsize=0.5mm] (0,0) rectangle (3,4);
to produce small stars close to each other in a rectangle. Here's the full code:In the same vein, you can customize hatch lines. Here's the code for north west lines. I've put options for color and shifting the hatch lines up (not down):
Here's the code for north east lines:
Creating new patterns
Creating new patterns is a bit more complex and needs choosing the right shape, the bounding box overlapping, etc. You can see an example with hexagons in the question Drawing Hexagons. I didn't do the work to control the size within Tikz, but it's straightforward to adapt the method described above.