From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113404 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aditya Mahajan via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Bug in lmt_arrow Date: Sun, 14 Nov 2021 22:07:52 -0500 (EST) Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-2013078949-1636945672=:949070" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6812"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Alpine 2.23 (LNX 453 2020-06-18) Cc: Aditya Mahajan To: Aditya Mahajan via ntg-context Original-X-From: ntg-context-bounces@ntg.nl Mon Nov 15 04:08:26 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmSM5-0001bL-RU for gctc-ntg-context-518@m.gmane-mx.org; Mon, 15 Nov 2021 04:08:25 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6F1E9288D48; Mon, 15 Nov 2021 04:08:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5NItRV-9OSXN; Mon, 15 Nov 2021 04:08:01 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8E27128925D; Mon, 15 Nov 2021 04:08:01 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id AE4AA2891F9 for ; Mon, 15 Nov 2021 04:07:58 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UDK-Uv-Abz3U for ; Mon, 15 Nov 2021 04:07:57 +0100 (CET) Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=132.206.73.2; helo=orford.cim.mcgill.ca; envelope-from=adityam@umich.edu; receiver= Original-Received: from orford.cim.mcgill.ca (smtp.cim.mcgill.ca [132.206.73.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 85356288D48 for ; Mon, 15 Nov 2021 04:07:57 +0100 (CET) Original-Received: from adi-thinkpad.local (bras-base-joltpq1712w-grc-37-69-159-160-7.dsl.bell.ca [69.159.160.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adityam) by orford.cim.mcgill.ca (Postfix) with ESMTPSA id A750122F1C1; Sun, 14 Nov 2021 22:07:55 -0500 (EST) In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:113404 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2013078949-1636945672=:949070 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: QUOTED-PRINTABLE On Sun, 14 Nov 2021, Aditya Mahajan via ntg-context wrote: > On Sun, 14 Nov 2021, Hans Hagen wrote: >=20 > > On 11/14/2021 4:33 AM, Aditya Mahajan via ntg-context wrote: > > > Hi, > > >=20 > > > There is a bug in lmt_arrow. If given a "non-cycle" path, lmt_arrow > > > completes the cycle. > > >=20 > > > \starttext > > >=20 > > > \startMPcode > > > newpath p; > > > ahfactor :=3D 5; > > > p :=3D origin .. (1cm, 1cm) .. (2cm, 0); > > > draw lmt_arrow > > > [ > > > path =3D p, > > > location =3D "percentage", > > > percentage =3D 50, > > > alternative =3D "curved", > > > ] > > > withpen pencircle scaled 1bp; > > > \stopMPcode > > > \stoptext > > >=20 > > > With 2021.11.11, I get the attached file. Note that lmt_arrow has dra= wn the > > > "cycle" version of the path, even though p does not have a cycle. > > >=20 > > > I have looked at the code and cannot figure out why this is happening= =2E > >=20 > > it happens in the 'direct' variant (metapost.registerdirect) where a bo= olean > > is passed as signal and that boolean then is also picked up by the (sha= red) > > path injector as (old school) signal that a path is closed while it sho= uld > > instead consutl the closed field in a path table (sounds more complex t= han it > > is) > >=20 > > so in the end it is a nasty side effect of the fast inject code path (s= hared > > function with different stack values; i'll probably have to ditch a "lo= w level > > backward compatibility feature no one uses anyway" some day) > >=20 > > i uploaded a fix that you can test when the bins are compiled at > >=20 > > =09https://build.contextgarden.net/#/waterfall?tags=3Dc.luametatex > >=20 > > new bins then in: > >=20 > > =09https://dl.contextgarden.net/build/luametatex/ > >=20 > > (fyi: in the mp code you see that the path p is 'get' from the lua end = where > > it got passed to by parameter) >=20 > Thanks! Works perfectly here. Spoke too soon. Now straight lines don't work: \starttext \startMPcode newpath p; ahfactor :=3D 5; p :=3D origin .. (3cm,0); draw lmt_arrow [ path =3D p,=20 location =3D "percentage", percentage =3D 50, alternative =3D "curved",=20 ] withpen pencircle scaled 1bp; \stopMPcode \stoptext gives metapost > trace > This is MPLIB for LuaMetaTeX, version 3.11, runni= ng in scaled mode. metapost > trace >=20 metapost > trace > loading metafun for lmtx, including the plain 1.0= 04 base definitions metapost > trace >=20 metafun > log > metafun > log > error: This can't happen (division by zero) metafun > log > metapost > trace > arrowhead -> -> begingroup.save.q,= e,r;pair.e;e=3Dpoint.length(EXPR2)of(EXPR2);path.q;q=3Dgobble((EXPR2)shifte= d-e.cutafter.makepath(pencircle.scaled(2ahlength)))cuttings;if.ahvariant>0:= path.r;r=3Dgobble((EXPR2)shifted-e.cutafter.makepath(pencircle.scaled((1-ah= dimple)*2ahlength)))cuttings;fi(q.rotated(ahangle/2)&reverse.q.rotated-(aha= ngle/2)if.ahvariant=3D1:--point0of.r--elseif.ahvariant=3D2:...point0of.r...= else:--fi.cycle)shifted.e.endgroup metapost > trace > endgroup metapost > trace > pushparameters "arrow" ; save a ; stri= ng a ; a :=3D getparameter "alternative" ; save l ; string l ; l :=3D getpa= rameter "location" ; save k ; string k ; k :=3D getparameter "kind" ; save = p ; path p ; p :=3D getparameter "path" ; interim ahvariant :=3D if a =3D "= dimpled" : 1 elseif a =3D "curved" : 2 else : 0 fi ; interim ahdimple :=3D = getparameter "dimple" ; interim ahscale :=3D getparameter "scale" ; interim= ahangle :=3D getparameter "angle" ; interim ahlength :=3D getparameter "le= ngth" ; if not getparameter "headonly" : draw p ; fi ; if hasparameter "pen= " : if hasoption "pen" "auto" : ahlength :=3D ( getparameter "penscale" ) *= boundingradius ( currentpen ) ; else : ahlength :=3D ( getparameter "pensc= ale" ) * boundingradius ( getparameterpen "pen" ) ; fi ; fi ; if k =3D "dra= w" : draw elseif k =3D "both" : filldraw else : fill fi if l =3D "middle" := midarrowhead p ; elseif l =3D "percentage" : arrowheadonpath ( p , ( getpa= rameter "percentage" ) / 100 ) ; elseif l =3D "both" : arrowhead p ; if k = =3D "draw" : draw elseif k =3D "both" : filldraw else : fill fi arrowhead r= everse p ; else : arrowhead p ; fi ; popparameters ; metapost > trace > image -> (TEXT3)-> begingroup.save.curren= tpicture;picture.currentpicture;currentpicture:=3Dnullpicture;(TEXT3);curre= ntpicture.if.str(SUFFIX2)<>"":shifted(mfun_labxf(SUFFIX2)*lrcorner.p+mfun_l= abyf(SUFFIX2)*ulcorner.p+(1-mfun_labxf(SUFFIX2)-mfun_labyf(SUFFIX2))*llcorn= er.p)fi.endgroup metapost > trace > lmt_do_arrow -> -> begingroup.image(pushp= arameters"arrow";save.a;string.a;a:=3Dgetparameter"alternative";save.l;stri= ng.l;l:=3Dgetparameter"location";save.k;string.k;k:=3Dgetparameter"kind";sa= ve.p;path.p;p:=3Dgetparameter"path";interim.ahvariant:=3Dif.a=3D"dimpled":1= elseif.a=3D"curved":2else:0fi;interim.ahdimple:=3Dgetparameter"dimple";inte= rim.ahscale:=3Dgetparameter"scale";interim.ahangle:=3Dgetparameter"angle";i= nterim.ahlength:=3Dgetparameter"length";if.not.getparameter"headonly":draw.= p;fi;if.hasparameter"pen":if.hasoption"pen""auto":ahlength:=3D(getparameter= "penscale")*boundingradius(currentpen);else:ahlength:=3D(getparameter"pensc= ale")*boundingradius(getparameterpen"pen");fi;fi;if.k=3D"draw":draw.elseif.= k=3D"both":filldraw.else:fill.fi.if.l=3D"middle":midarrowhead.p;elseif.l=3D= "percentage":arrowheadonpath(p,(getparameter"percentage")/100);elseif.l=3D"= both":arrowhead.p;if.k=3D"draw":draw.elseif.k=3D"both":filldraw.else:fill.f= i.arrowhead.reverse.p;else:arrowhead.p;fi;popparameters;)endgroup metapost > trace > lmt_do_arrow metafun > log > metafun > log > I'm broken. Please show this to someone who can fix= can fix it and try again metafun > log > metapost > trace > newpath p; ahfactor :=3D 5; p :=3D origi= n .. (3cm,0); draw lmt_arrow [ path =3D p, location =3D "percentage", perce= ntage =3D 50, alternative =3D "curved", ] withpen pencircle scaled 1bp; ; metapost > trace >=20 Aditya --8323329-2013078949-1636945672=:949070 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --8323329-2013078949-1636945672=:949070--