* curved
@ 2021-12-14 17:44 Hans Hagen via ntg-context
0 siblings, 0 replies; only message in thread
From: Hans Hagen via ntg-context @ 2021-12-14 17:44 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
Hi Hraban,
follow up on chat ...
\starttext
\startMPcode % {doublefun}
mfun_bend_tolerance := 0.002; % double : 131/65536
mfun_bend_tolerance := 0.02 ; % scaled
vardef iscurved(expr p, i, tolerance) =
save d, b, r ; boolean r ; r := true ;
d := (xpart precontrol i of p) - (xpart postcontrol (i-1)
of p) ;
b := abs((xpart postcontrol (i-1) of p) - (xpart point (i-1)
of p) - d);
if b <= tolerance :
b := abs((xpart point i of p) - (xpart precontrol i of p) - d) ;
if b <= tolerance :
d := (ypart precontrol i of p) - (ypart
postcontrol (i-1) of p) ;
b := abs((ypart postcontrol (i-1) of p) - (ypart point
(i-1) of p) - d) ;
if b <= tolerance :
b := abs((ypart point i of p) - (ypart precontrol i of
p) - d) ;
if b <= tolerance :
r := false ;
fi ;
fi ;
fi ;
fi ;
r
enddef ;
path p ; p := fullcircle scaled 10cm ;
path q ; q := fullsquare scaled 10cm ;
path r ; r := fullsquare scaled 10cm randomized 1cm ;
draw p ; draw q ; draw r ;
message(iscurved(p,2,0.02));
message(iscurved(q,2,0.02));
message(iscurved(r,2,0.02));
\stopMPcode
\stoptext
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 : 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] only message in thread
only message in thread, other threads:[~2021-12-14 17:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 17:44 curved Hans Hagen via ntg-context
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).