[metapost] augment drawoptions
mailing_list at arcor.de
Fri Apr 11 23:07:44 CEST 2008
Taco Hoekwater schrieb:
> Stephan Hennig wrote:
>> ...' directly. My idea was to augment the current draw option by
>> 'withpen ...', that is, keeping the former drawoptions configuration,
>> but append my own draw options.
> You can use expandafter, much like you would in tex:
Thanks! There is one remaining problem: changes to drawoptions are
global. In the attached example the final stroke is drawn with a thick
pen, instead of the standard pen.
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?
def addtodrawoptions(text t) =
expandafter def expandafter _myop_ expandafter = _op_ t enddef;
let _op_ = _myop_;
def thick_circle =
save _op_;% Doesn't work.
addtodrawoptions(withpen pencircle scaled 4);
draw fullcircle scaled 100;
def thin_circle =
addtodrawoptions(withpen pencircle scaled 2);
draw fullcircle scaled 100 shifted (0, 100);
drawoptions(withcolor red);% Set colour.
draw (0,0)--(100,100);% Ooops! Wrong pen width.
More information about the metapost