From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/90061 Path: news.gmane.org!not-for-mail From: DesdeChaves Newsgroups: gmane.comp.tex.context Subject: Code that run in Metapost but not in starMPcode enviroment Date: Sun, 1 Feb 2015 11:29:06 +0000 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1072941360==" X-Trace: ger.gmane.org 1422790182 30763 80.91.229.3 (1 Feb 2015 11:29:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Feb 2015 11:29:42 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Feb 01 12:29:42 2015 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YHsii-0005vp-SN for gctc-ntg-context-518@m.gmane.org; Sun, 01 Feb 2015 12:29:40 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 3E00B1022F for ; Sun, 1 Feb 2015 12:29:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id FEI0pVdIigla for ; Sun, 1 Feb 2015 12:29:39 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 3F96710239 for ; Sun, 1 Feb 2015 12:29:14 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 624F9101FB for ; Sun, 1 Feb 2015 12:29:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3m1QCvKR1D2J for ; Sun, 1 Feb 2015 12:29:09 +0100 (CET) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by balder.ntg.nl (Postfix) with ESMTP id 631FF101EA for ; Sun, 1 Feb 2015 12:29:09 +0100 (CET) Original-Received: from mail-oi0-x229.google.com (mail-oi0-x229.google.com [IPv6:2607:f8b0:4003:c06::229]) by filter4-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id t11BT7E7019274 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 1 Feb 2015 12:29:08 +0100 Original-Received: by mail-oi0-f41.google.com with SMTP id z81so40722797oif.0 for ; Sun, 01 Feb 2015 03:29:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=VMWZ18GuowmEhqNwJ1JDGWy+u71V+Hy4claPM5hn0Vg=; b=sSsVN1dMvxnVUh2mRX5aFJ9GhohuyS8tAwFnIqkEQ23O1npNpiQISi6V6hIuHSucdn Y5OfA4Ahg6f/hyyzSGCTnVP32s+Sj8Yyo5SHGsEqMOJaqY93Y6gsuWlmCnfe7WQjTdxx 7mrC08seoJwYNIsotDt7SaUsuXNpZ3SOEksCbaRxielhghemOqkt114nBWrKOQblYMSr CbDprN5kOYlCm1FS9bvtLeCaPYYevBLwMRNsXEUXOG5y+iYHqFAQW4FOuEnmLZJdO/9o gLDzY8QudWeOlXQlmeuEHMYpQFUsDL7o8GuY2bEDcQNwVqykXIpskXky6qECQJfP9eLP KOoQ== X-Received: by 10.60.62.42 with SMTP id v10mr424211oer.45.1422790146592; Sun, 01 Feb 2015 03:29:06 -0800 (PST) Original-Received: by 10.60.141.1 with HTTP; Sun, 1 Feb 2015 03:29:06 -0800 (PST) X-Bayes-Prob: 0.0001 (Score 0, tokens from: ntg-context@ntg.nl, base:default, @@RPTN) X-CanIt-Geo: ip=2607:f8b0:4003:c06::229; country=US X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0VNKXt8ge - 5ff7e69034a5 - 20150201 (trained as not-spam) Received-SPF: pass (filter4-til.mf.surf.net: domain of desdechaves@gmail.com designates 2607:f8b0:4003:c06::229 as permitted sender) receiver=filter4-til.mf.surf.net; client-ip=2607:f8b0:4003:c06::229; envelope-from=; helo=mail-oi0-x229.google.com; identity=mailfrom X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 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.org gmane.comp.tex.context:90061 Archived-At: --===============1072941360== Content-Type: multipart/alternative; boundary=089e013c5ca84714f4050e05257c --089e013c5ca84714f4050e05257c Content-Type: text/plain; charset=UTF-8 I'm trying to draw some random arrows using Metapost. For that I use a piece of code from fpast that in found at stackexchange Unfortunately this code does not work in context (request for a solution ) because the freelabel() function. If I disable it the result is the expected. What is wrong with this code? \starttext \startMPcode numeric u, nb_vectors, wd; u := 1cm; % unit length nb_vectors := 20; wd = .5; boolean intersect; pair random_origin; color random_color; path candidate, random_vector[]; % vardef bb(expr p) = save orig, extr; pair orig, extr; orig = point 0 of p; extr = point 1 of p; pair v,w; v = wd*unitvector(extr-orig)*u; w = v rotated 90; (orig - v + w) -- (extr + v + w) -- (extr + v - w) -- (orig - v - w) -- cycle enddef; % pickup pencircle scaled 2bp; i = 1; forever: exitunless (i <= nb_vectors); intersect := false; random_length := u*(2+uniformdeviate(1)); random_angle := uniformdeviate(359); random_origin := u*(uniformdeviate(wd*nb_vectors), uniformdeviate(wd*nb_vectors)); random_color := (uniformdeviate(1), uniformdeviate(1), uniformdeviate(1)); candidate := random_origin -- (random_origin + random_length*dir(random_angle)); j := 1; forever: exitif (j = i) or (intersect = true); if bb(random_vector[j]) intersectiontimes bb(candidate) <> (-1, -1): intersect := true; fi; j := j+1; endfor; if intersect = false: random_vector[i] = candidate; drawarrow candidate withcolor random_color; freelabel(btex $v$ etex, point .5 of candidate, point .5 of candidate + dir (random_angle + 90)); i := i+1; fi; endfor; \stopMPcode \stoptext --089e013c5ca84714f4050e05257c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I'm trying to draw some r= andom arrows using Metapost. For that I use a piece of code from fpast that= in found at stackexchange



\starttext

\startMPcode=
numeric u, nb_vectors, wd;
u :=3D 1cm; % unit length
nb_vectors :=3D 20; wd =3D .5;=C2=A0
boolean intersect; = pair random_origin; color random_color; path candidate, random_vector[];
%
vardef bb(expr p) =3D
=C2=A0 save orig, extr;= pair orig, extr; orig =3D point 0 of p; extr =3D point 1 of p;
= =C2=A0 pair v,w; v =3D wd*unitvector(extr-orig)*u; w =3D v rotated 90;
=C2=A0 (orig - v + w) -- (extr + v + w) -- (extr + v - w) -- (orig - = v - w) -- cycle
enddef;
%

=C2= =A0 pickup pencircle scaled 2bp;
=C2=A0 i =3D 1;=C2=A0
= =C2=A0 forever:=C2=A0
=C2=A0 =C2=A0 exitunless (i <=3D =C2=A0n= b_vectors);
=C2=A0 =C2=A0 intersect :=3D false;
=C2=A0 = =C2=A0 random_length :=3D u*(2+uniformdeviate(1));
=C2=A0 =C2=A0 = random_angle :=3D uniformdeviate(359);
=C2=A0 =C2=A0 random_origi= n :=3D u*(uniformdeviate(wd*nb_vectors), uniformdeviate(wd*nb_vectors));
=C2=A0 =C2=A0 random_color :=3D (uniformdeviate(1), uniformdeviate(= 1), uniformdeviate(1));
=C2=A0 =C2=A0 candidate :=3D random_origi= n -- (random_origin + random_length*dir(random_angle));
=C2=A0 = =C2=A0 j :=3D 1;
=C2=A0 =C2=A0 forever:
=C2=A0 =C2=A0 = =C2=A0 exitif (j =3D i) or (intersect =3D true);
=C2=A0 =C2=A0 = =C2=A0 if bb(random_vector[j]) intersectiontimes bb(candidate) <> =C2= =A0(-1, -1):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 intersect :=3D true;
=C2=A0 =C2=A0 =C2=A0 fi;
=C2=A0 =C2=A0 =C2=A0 j :=3D j+1;<= /div>
=C2=A0 =C2=A0 endfor;
=C2=A0 =C2=A0 if intersect =3D fa= lse:=C2=A0
=C2=A0 =C2=A0 =C2=A0 random_vector[i] =3D candidate;
=C2=A0 =C2=A0 =C2=A0 drawarrow candidate withcolor random_color;
=C2=A0 =C2=A0 =C2=A0 freelabel(btex $v$ etex, point .5 of candidat= e, point .5 of candidate + dir (random_angle + 90));
=C2=A0 =C2= =A0 =C2=A0 i :=3D i+1;
=C2=A0 =C2=A0 fi;
=C2=A0 endfor;=
\stopMPcode


\stoptext
--089e013c5ca84714f4050e05257c-- --===============1072941360== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============1072941360==--