[metapost] augment drawoptions
luecking at uark.edu
Wed Apr 16 01:34:04 CEST 2008
At 02:35 AM 4/12/2008, Taco Hoekwater wrote:
>Stephan Hennig wrote:
> > To keep changes to draw options locally, I've tried to save _op_ prior
> > to using addtodrawoptions. But again, this doesn't work. Any ideas?
>You cannot save _op_ because it is a macro, not a variable.
You _can_ save it, but it then immediately becomes undefined, and
so any effort to define it in terms of itself will have to fail.
If you do save it, its meaning will return after the group.
>You could do explicit macro definitions and restores with expandafter:
>def savedrawoptions =
> expandafter def expandafter _savedop_ expandafter = _op_ enddef;
>def restoredrawoptions =
> expandafter def expandafter _op_ expandafter = _savedop_ enddef;
If you combine these as illustrated below, you can make use
of the endgroup to restore _op_. This permits nested groups.
def save_op_ =
expandafter def expandafter _savedop_ expandafter = _op_ enddef;
expandafter def expandafter _op_ expandafter = _savedop_ enddef;
def addtodrawoptions (text t) =
expandafter def expandafter _op_ expandafter = _op_ t enddef;
pickup pencircle scaled .5bp;
addtodrawoptions(withpen pencircle scaled 10bp);
% fat and red
draw halfcircle scaled 100;
fat and blue
draw halfcircle scaled 100 shifted (0,100);
% fat and red again
draw halfcircle scaled 100 shifted (0,200);
% thin and red
draw halfcircle scaled 100 shifted (0,300);
Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
"Dubito ergo cogito, cogito ergo sum" --Descarte
More information about the metapost