* What was that 'rounding paths' metafun(?) function again? @ 2020-04-05 10:31 Gerben Wierda 2020-04-05 10:37 ` Wolfgang Schuster 2020-04-05 13:24 ` Keith McKay 0 siblings, 2 replies; 5+ messages in thread From: Gerben Wierda @ 2020-04-05 10:31 UTC (permalink / raw) To: mailing list for ConTeXt users I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded (part of a circle) corners (still straight lines), but I can’t find it anymore. I wrote my own, but it is giving me headaches so I’d like to find something that is better than what I produce. G ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What was that 'rounding paths' metafun(?) function again? 2020-04-05 10:31 What was that 'rounding paths' metafun(?) function again? Gerben Wierda @ 2020-04-05 10:37 ` Wolfgang Schuster 2020-04-05 11:18 ` Gerben Wierda 2020-04-05 13:24 ` Keith McKay 1 sibling, 1 reply; 5+ messages in thread From: Wolfgang Schuster @ 2020-04-05 10:37 UTC (permalink / raw) To: mailing list for ConTeXt users, Gerben Wierda Gerben Wierda schrieb am 05.04.2020 um 12:31: > I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded (part of a circle) corners (still straight lines), but I can’t find it anymore. I wrote my own, but it is giving me headaches so I’d like to find something that is better than what I produce. You you mean "cornered ..." or "smoothed ..."? Wolfgang ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What was that 'rounding paths' metafun(?) function again? 2020-04-05 10:37 ` Wolfgang Schuster @ 2020-04-05 11:18 ` Gerben Wierda 0 siblings, 0 replies; 5+ messages in thread From: Gerben Wierda @ 2020-04-05 11:18 UTC (permalink / raw) To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 2010 bytes --] Yes, I meant cornered. But it turns out it works worse in my case, I get paths with hundreds of segments and a run that goes amok. But that made me find a mistake in my code and now I’m using my own again and it works fine: vardef softenPath( expr hardPath) = save softPath; path softPath; save len; len := length hardPath; save rounding; rounding := 5; save i; for i=0 upto len: if (i=0): % first pair softPath := point i of hardPath; elseif (i=len): % lastpair softPath := softPath -- point i of hardPath; else: % intermediate pair save subOne; path subOne; subOne := subpath(i-1, i) of hardPath; save subTwo; path subTwo; subTwo := subpath(i, i+1) of hardPath; save lenOne; numeric lenOne; lenOne := arclength subOne; save lenTwo; numeric lenTwo; lenTwo := arclength subTwo; save pointOne, pointTwo; pair pointOne, pointTwo; pointOne := point (arctime (lenOne-rounding) of subOne) of subOne; pointTwo := point (arctime rounding of subTwo) of subTwo; save dirOne, dirTwo; pair dirOne, dirTwo; dirOne := direction (arctime (lenOne-rounding) of subOne) of subOne; dirTwo := direction (arctime (rounding) of subTwo) of subTwo; softPath := softPath -- pointOne{dirOne} .. {dirTwo}pointTwo; fi endfor; softPath enddef; Fixed rounding of 5bp, but that is easy to change. > On 5 Apr 2020, at 12:37, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote: > > Gerben Wierda schrieb am 05.04.2020 um 12:31: >> I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded (part of a circle) corners (still straight lines), but I can’t find it anymore. I wrote my own, but it is giving me headaches so I’d like to find something that is better than what I produce. > > You you mean "cornered ..." or "smoothed ..."? > > Wolfgang [-- Attachment #1.2: Type: text/html, Size: 5988 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What was that 'rounding paths' metafun(?) function again? 2020-04-05 10:31 What was that 'rounding paths' metafun(?) function again? Gerben Wierda 2020-04-05 10:37 ` Wolfgang Schuster @ 2020-04-05 13:24 ` Keith McKay 2020-04-05 13:52 ` Gerben Wierda 1 sibling, 1 reply; 5+ messages in thread From: Keith McKay @ 2020-04-05 13:24 UTC (permalink / raw) To: ntg-context Would sections 1.3, 1.18, 2.5 and 2.6 in the Metafun manual help? Keith On 05/04/2020 11:31, Gerben Wierda wrote: > I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded (part of a circle) corners (still straight lines), but I can’t find it anymore. I wrote my own, but it is giving me headaches so I’d like to find something that is better than what I produce. > > G > ___________________________________________________________________________________ > 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://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What was that 'rounding paths' metafun(?) function again? 2020-04-05 13:24 ` Keith McKay @ 2020-04-05 13:52 ` Gerben Wierda 0 siblings, 0 replies; 5+ messages in thread From: Gerben Wierda @ 2020-04-05 13:52 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 2187 bytes --] > On 5 Apr 2020, at 15:24, Keith McKay <mckaymeister@gmail.com> wrote: > > Would sections 1.3, 1.18, 2.5 and 2.6 in the Metafun manual help? I used what is in 1.3 (though I actually used Peter Grogono’s PDF MetaPost: A Reference Manual <https://users.encs.concordia.ca/~grogono/Writings/mpref.pdf> which I find the best educational document about plain METAPOST so far). 1.18 was what I was looking for but did not work in my situation (don’t know why, but it exploded). I fixed another issue (calling cornering on top of cornering when doing recursion) and that made my own macro behave perfectly civilised. I had looked at 2.5 and 2.6 but this was not required (nor of any use). G > > Keith > > On 05/04/2020 11:31, Gerben Wierda wrote: >> I think I saw a function in MetaFun somehwre that you could give a ‘hard’ path, i.e. (0,0) -- (0,1) — (1,1) and it would become a path with nicely rounded (part of a circle) corners (still straight lines), but I can’t find it anymore. I wrote my own, but it is giving me headaches so I’d like to find something that is better than what I produce. >> >> G >> ___________________________________________________________________________________ >> 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://context.aanhet.net >> archive : https://bitbucket.org/phg/context-mirror/commits/ >> wiki : http://contextgarden.net >> ___________________________________________________________________________________ > ___________________________________________________________________________________ > 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://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 3877 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-05 13:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-05 10:31 What was that 'rounding paths' metafun(?) function again? Gerben Wierda 2020-04-05 10:37 ` Wolfgang Schuster 2020-04-05 11:18 ` Gerben Wierda 2020-04-05 13:24 ` Keith McKay 2020-04-05 13:52 ` Gerben Wierda
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).