[NTG-context] Metafun: how to draw a straight line past the end points
fabrice.alpha at gmail.com
Wed Dec 9 17:19:59 CET 2020
> Le 9 déc. 2020 à 10:57, Otared Kavian <otared at gmail.com> a écrit :
> I have a silly question: given two points in the plane
> z1 = (1cm,3cm) ;
> z2 = (5cm, 9cm) ;
> the command
> draw z1 -- z2 withpen pencircle scaled .5pt ;
> draws the line segment joining z1 and z2. How could I draw the line segment which goes a little further (say 1cm) than both the end points of this segment (that is in this example, a point before z1 and a point after z2 on the straight line) .
> Indeed it is possible to write the equation of the line and then compute by hand the coordinates of the new end points, but I think there is a simpler way in Metafun to do this.
The shortened operation is the solution ! See MetaFun manual section 1.18
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
draw (z1--z2) shortened -1cm withcolor blue ;
draw (z1--z2) withcolor red ;
> Thanks for any help: Otared
> If your question is of interest to others as well, please add an entry to the Wiki!
> maillist : ntg-context at 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
More information about the ntg-context