From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/9250 Path: main.gmane.org!not-for-mail From: Jens-Uwe Morawski Newsgroups: gmane.comp.tex.context Subject: MetaFun refill/do_repath bug Date: Mon, 16 Sep 2002 17:31:30 +0200 Sender: owner-ntg-context@let.uu.nl Message-ID: <20020916173130.57957f34.morawski@gmx.net> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035399588 1733 80.91.224.250 (23 Oct 2002 18:59:48 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 18:59:48 +0000 (UTC) Original-To: ConTeXt Xref: main.gmane.org gmane.comp.tex.context:9250 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:9250 Ahoi Hans, i wrote an article for the magazine of the german TUG that explains some advanced features of MetaPost. Esp. it explains the within,pathpart,penpart... stuff. In the article i give an example that refills all filled elements of a picture with a new color. The article is not yet published, but one who has proof-read the article told me that an equal macro is provided by MetaFun. A little bit surprised, since i thought that i know most of the MetaFun features, i've tried the "refill" macro and was surprised again, since it does not work correctly (IMO). The problem is that the macro "do_repath" does not handle clipped and bounded graphic elements correctly. Your macro ignores totally that clipped and bounded elements contain again some more graphic elements, i.e. lines, filled paths etc. Therefore the macro has to be applied recursively to these elements too. Furthermore the pathpart of a clipped or bounded object has to be applied only to the elements in that object and not to the whole picture. Please find below a MP-file that illustrates what i mean. It compares the macro "uniformfilled" from my article with your "refill". Best, Jens %%% ---snip--- input metafun ; primarydef p uniformfilled c = begingroup save t, f, s ; picture t, s ; t := nullpicture ; color f ; for i within p : f := (redpart i, greenpart i, bluepart i) ; if bounded i : s := i uniformfilled c ; setbounds s to pathpart i ; addto t also s ; elseif clipped i : s := i uniformfilled c ; clip s to pathpart i ; addto t also s ; elseif stroked i : addto t doublepath pathpart i dashed dashpart i withpen penpart i withcolor f ; elseif filled i : addto t contour pathpart i withcolor c ; else: addto t also i ; fi ; endfor; t endgroup enddef; picture pic[] ; %-- a clipped picture pic[0] := nullpicture ; addto pic[0] contour ( unitsquare scaled 2cm ) withcolor green ; addto pic[0] contour ( unitsquare scaled 2cm shifted (-2cm,-2cm) ) withcolor green ; addto pic[0] contour ( unitsquare scaled 2cm shifted (0,-2cm) ) withcolor red ; addto pic[0] contour ( unitsquare scaled 2cm shifted (-2cm,0) ) withcolor red ; clip pic[0] to fullcircle scaled 4cm ; %-- the base picture pic[1] := nullpicture ; addto pic[1] contour ( unitsquare xscaled 5cm yscaled 1cm shifted (-2.5cm,1cm) ) withcolor blue ; addto pic[1] contour ( unitsquare xscaled 5cm yscaled 1cm shifted (-2.5cm,-2cm) ) withcolor blue ; addto pic[1] also pic[0] ; addto pic[1] doublepath fullcircle scaled 4cm withpen pencircle scaled 3pt; %-- "uniformfilled" applied to the base picture pic[2] := pic[1] uniformfilled .6white ; %-- "refill" applied to the base picture pic[3] := pic[1] ; refill pic[3] withcolor .6white ; beginfig(1); label.top(pic[1],origin) ; label.bot("original",origin) ; label.top(pic[2],(5.3cm,0)) ; label.bot("uniformfilled",(5.3cm,0)) ; label.top(pic[3],(10.6cm,0)) ; label.bot("MetaFun/refill",(10.6cm,0)) ; endfig; end