Hello, I have a question for metapost specialists: I am looking for some sort of effect, built upon a zig-zag line. The first graphic in the minimal example below is as I would expect. The second graphic seems to be drawn without the point at (0,0). (Ignore the asymmetry at the end of the path in the 2nd, this is to be expected in this minimal example.) Is the result correct or is this a bug? Alan \starttext \startTEXpage \startMPcode u := 1mm ; path p[] ; p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ; pickup pensquare scaled 10u rotated 45 ; draw p0 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p0 withcolor yellow ; pickup pencircle scaled .1u ; draw p0 ; \stopMPcode \stopTEXpage \startTEXpage \startMPcode p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u shifted point infinity of p0 ; p2 := p0--p1 ; pickup pensquare scaled 10u rotated 45 ; draw p2 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p2 withcolor yellow ; pickup pencircle scaled .1u ; draw p2 ; \stopMPcode \stopTEXpage \stoptext
On Thu, Jul 21, 2011 at 4:39 PM, Alan Braslau
Hello,
I have a question for metapost specialists:
I am looking for some sort of effect, built upon a zig-zag line. The first graphic in the minimal example below is as I would expect. The second graphic seems to be drawn without the point at (0,0). (Ignore the asymmetry at the end of the path in the 2nd, this is to be expected in this minimal example.)
Is the result correct or is this a bug?
Alan
\starttext
\startTEXpage \startMPcode u := 1mm ;
path p[] ; p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ; pickup pensquare scaled 10u rotated 45 ; draw p0 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p0 withcolor yellow ; pickup pencircle scaled .1u ; draw p0 ; \stopMPcode \stopTEXpage
\startTEXpage \startMPcode p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u shifted point infinity of p0 ; p2 := p0--p1 ;
pickup pensquare scaled 10u rotated 45 ; draw p2 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p2 withcolor yellow ; pickup pencircle scaled .1u ; draw p2 ; \stopMPcode \stopTEXpage
\stoptext You are shifting by a certain amount : what is the net effect of shifted point infinity of p0 ?
-- luigi
Am 21.07.2011 16:53, schrieb luigi scarso:
On Thu, Jul 21, 2011 at 4:39 PM, Alan Braslau
wrote: Hello,
I have a question for metapost specialists:
I am looking for some sort of effect, built upon a zig-zag line. The first graphic in the minimal example below is as I would expect. The second graphic seems to be drawn without the point at (0,0). (Ignore the asymmetry at the end of the path in the 2nd, this is to be expected in this minimal example.)
Is the result correct or is this a bug?
Alan
\starttext
\startTEXpage \startMPcode u := 1mm ;
path p[] ; p0 := ((0,0)--(1,0)) rotated 45 scaled 20u ; pickup pensquare scaled 10u rotated 45 ; draw p0 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p0 withcolor yellow ; pickup pencircle scaled .1u ; draw p0 ; \stopMPcode \stopTEXpage
\startTEXpage \startMPcode p1 := ((0,0)--(sqrt(2),0)) rotated -30 scaled 20u shifted point infinity of p0 ; p2 := p0--p1 ;
use
p2 := p0 & p1; the reason for the 'unexpected' output is, that point 1 and 2 of the path p2 are equal. keep in mind that drawing with an asymmetrical pen has its own (complex) rules.
pickup pensquare scaled 10u rotated 45 ; draw p2 withcolor blue ; pickup pensquare yscaled 2u xscaled 5u rotated 45 ; draw p2 withcolor yellow ; pickup pencircle scaled .1u ; draw p2 ; \stopMPcode \stopTEXpage
\stoptext
You are shifting by a certain amount : what is the net effect of shifted point infinity of p0 ?
afaik simply the last point of p0.
On Thu, Jul 21, 2011 at 05:39:48PM +0200, Peter Rolf wrote:
use
p2 := p0 & p1;
the reason for the 'unexpected' output is, that point 1 and 2 of the path p2 are equal. keep in mind that drawing with an asymmetrical pen has its own (complex) rules.
Thank you -- I forgot about the path operator & (Funny thing, though, that the problem shows up with point 0. I would also think that having two consecutive identical points, although poor style, should not cause problems as it does.) And yes, the use of an asymmetrical pen is indeed the whole point of this figure -- I am using metapost to achieve very easily an effect, conceptually very simple, that a colleague has not been able to produce using Adobe Illustrator. Thank you again for helping out. Alan
Am 21.07.2011 23:21, schrieb Alan Braslau:
On Thu, Jul 21, 2011 at 05:39:48PM +0200, Peter Rolf wrote:
use
p2 := p0 & p1;
the reason for the 'unexpected' output is, that point 1 and 2 of the path p2 are equal. keep in mind that drawing with an asymmetrical pen has its own (complex) rules.
Thank you -- I forgot about the path operator &
same here (i had to browse the metapost manual for the operator) :-)
(Funny thing, though, that the problem shows up with point 0. I would also think that having two consecutive identical points, although poor style, should not cause problems as it does.)
i guess it has to do with the fact, that 'drawing' with non circular pens always results in a *filled* path. metapost is calculating new points for the shape, instead of just storing the given path points and the pen size (like in a normal pencircle draw). and if a filled path is intersecting with itself, funny things can happen. well, most times not that funny (because unwanted). probably not the best example (not drawn, no special pen), but it gives a first impression of what is going on. \startTEXpage \startMPcode path p[]; p0 := unitcircle scaled 10cm; p1 := p0 scaled .5; p2 := p0 -- reverse(p1) -- cycle; fill p2; \stopMPcode \stopTEXpage depending on their direction (clockwise or counter clockwise) and location (intersection or not) such path 'cycles' are cleared or filled. with this trick you are able to produce punches as in the glyphs of "O" or "e". if you like and have the time you can debug your example (simply add a loop that draws all points and labels them). you will then see the difference between a drawn (pencircle) and a 'drawn' (non circular pen) path. ;-)
And yes, the use of an asymmetrical pen is indeed the whole point of this figure -- I am using metapost to achieve very easily an effect, conceptually very simple, that a colleague has not been able to produce using Adobe Illustrator.
Thank you again for helping out.
my pleasure. Peter
Alan ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (3)
-
Alan Braslau
-
luigi scarso
-
Peter Rolf