[NTG-context] Re: metapost spiral
Thanks for the answers, Mikael, Taco & Hans! Am 30.03.26 um 13:30 schrieb Hans Hagen via ntg-context: On 3/30/2026 12:52 PM, Hraban Ramm wrote: Hi, in https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf I found this code to draw a spiral: path S; S = origin for t=1 upto 90: .. 1/12 t * dir 16t endfor; draw S; I understand it starts at origin and adds a number of points – but where are the points (pairs)? There’s a number (distance?) and a direction (angle?). Could you explain this in layman’s terms? "dir" produces a pair \startMPpage path S; S := origin for t=1 upto 90 : .. 1/12 t * dir 16t endfor ; S := S scaled 10 ; draw S ; drawpoints S withcolor red ; \stopMPpage If I try a different starting point than origin, the spiral still is drawn around origin. I'd like to add it to another path and also hm, if you replace origin by (10,10) it does looks different > randomize the points a bit to make it look hand-drawn. 1/12 (t randomized .05t) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___
[NTG-context] Re: metapost spiral
On 3/30/2026 12:52 PM, Hraban Ramm wrote: Hi, in https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf I found this code to draw a spiral: path S; S = origin for t=1 upto 90: .. 1/12 t * dir 16t endfor; draw S; I understand it starts at origin and adds a number of points – but where are the points (pairs)? There’s a number (distance?) and a direction (angle?). Could you explain this in layman’s terms? "dir" produces a pair \startMPpage path S; S := origin for t=1 upto 90 : .. 1/12 t * dir 16t endfor ; S := S scaled 10 ; draw S ; drawpoints S withcolor red ; \stopMPpage If I try a different starting point than origin, the spiral still is drawn around origin. I'd like to add it to another path and also hm, if you replace origin by (10,10) it does looks different > randomize the points a bit to make it look hand-drawn. 1/12 (t randomized .05t) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___
[NTG-context] Re: metapost spiral
Hi Hraban, > On 30 Mar 2026, at 12:52, Hraban Ramm wrote: > > Hi, > in https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf > I found this code to draw a spiral: > path S; > S = origin > for t=1 upto 90: > .. 1/12 t * dir 16t > endfor; > draw S; > I understand it starts at origin and adds a number of points – but where are > the points (pairs)? Paths are built using pairs, not “points". And directions happen to be pairs (a unit vector). That is all there is to it. > There’s a number (distance?) and a direction (angle?). Could you explain this > in layman’s terms? > If I try a different starting point than origin, the spiral still is drawn > around origin. I'd like to add it to another path and also randomize the > points a bit to make it look hand-drawn. You can treat the “1/12 t * dir 16t” as a computed point, so just shift and/or modify it in place, e.g. > .. (1/12 t * dir 16t) shifted (100,0) Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___
[NTG-context] Re: metapost spiral
Hi, The secret is in dir that takes an angle and outputs a vector pointing in the corresponding direction. When t = 7 for example .. 1/12 t * dir 16t will equal .. 1/12 * 7 * (cosd(16*7),sind(16*7)) /Mikael On Mon, 30 Mar 2026 at 12:56, Hraban Ramm wrote: > > Hi, > > in https://tug.ctan.org/info/drawing-with-metapost/Drawing-with-Metapost.pdf > I found this code to draw a spiral: > > path S; > S = origin > for t=1 upto 90: > .. 1/12 t * dir 16t > endfor; > draw S; > > I understand it starts at origin and adds a number of points – but where are > the points (pairs)? There’s a number (distance?) and a direction (angle?). > Could you explain this in layman’s terms? > > If I try a different starting point than origin, the spiral still is drawn > around origin. I'd like to add it to another path and also randomize the > points a bit to make it look hand-drawn. > > Hraban > > > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : [email protected] / > https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) > archive : https://github.com/contextgarden/context > wiki : https://wiki.contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___
