Download Learning METAPOST by Doing

Transcript
Learning MetaPost by doing
beer consumption (liter)
VOORJAAR 2005
92
90
88
86
84
82
1980 1985 1990 1995 2000
year
Style Directives
In this section we explain how you can alter the appearance of graphics primitives,
e.g., allowing certain lines to be thicker and others to be dashed, using different
colours, and changing the type of the drawing pen.
Dashing
Examples show you best how the specify a dash pattern when drawing a line or
curve.
beginfig(1);
path p; p := (0,0)--(102,0);
def drawit (suffix p)(expr pattern) =
draw p dashed pattern;
p := p shifted (0,-13);
enddef;
drawit(p, withdots);
drawit(p, withdots scaled 2);
drawit(p, evenly);
drawit(p, evenly scaled 2);
drawit(p, evenly scaled 4);
drawit(p, evenly scaled 6);
p := (0,-150)--(102,-150);
def shiftit (suffix p)(expr s) =
draw p dashed evenly scaled 4 shifted s;
dotlabel("",point 0 of p);
dotlabel("",point 1 of p);
p := p shifted (0,-13);
enddef;
shiftit(p, (0,0));
shiftit(p, (4bp,0));
shiftit(p, (8bp,0));
shiftit(p, (12bp,0));
shiftit(p, (16bp,0));
shiftit(p, (20bp,0));
picture dd; dd :=
dashpattern(on 6bp off 2bp on 2bp off 2bp);
draw (0,-283)--(102,-283) dashed dd;
draw (0,-296)--(102,-296) dashed dd scaled 2;
endfig;
end;
In general, the syntax for dashing is
draw path dashed dash pattern;
21