ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jens-Uwe Morawski <morawski@gmx.net>
Subject: MetaFun refill/do_repath bug
Date: Mon, 16 Sep 2002 17:31:30 +0200	[thread overview]
Message-ID: <20020916173130.57957f34.morawski@gmx.net> (raw)

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


             reply	other threads:[~2002-09-16 15:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-16 15:31 Jens-Uwe Morawski [this message]
2002-09-16 16:29 ` Hans Hagen
2002-09-16 20:03   ` Jens-Uwe Morawski
2002-09-17  7:57     ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020916173130.57957f34.morawski@gmx.net \
    --to=morawski@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).