From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/90456 Path: news.gmane.org!not-for-mail From: DesdeChaves Newsgroups: gmane.comp.tex.context Subject: Update text variables inside metapost Date: Sat, 7 Mar 2015 16:37:01 +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="===============0481474651==" X-Trace: ger.gmane.org 1425746268 2195 80.91.229.3 (7 Mar 2015 16:37:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Mar 2015 16:37:48 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Mar 07 17:37:37 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 1YUHjM-0007zN-UV for gctc-ntg-context-518@m.gmane.org; Sat, 07 Mar 2015 17:37:37 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 3A5E110232 for ; Sat, 7 Mar 2015 17:37:36 +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 mvnJYftPv5yI for ; Sat, 7 Mar 2015 17:37:35 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 6823A1023D for ; Sat, 7 Mar 2015 17:37:10 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2A43F101FB for ; Sat, 7 Mar 2015 17:37:06 +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 1ZSi5YoNQw6N for ; Sat, 7 Mar 2015 17:37:04 +0100 (CET) Original-Received: from filter3-til.mf.surf.net (filter3-til.mf.surf.net [194.171.167.219]) by balder.ntg.nl (Postfix) with ESMTP id BB6B5101EA for ; Sat, 7 Mar 2015 17:37:04 +0100 (CET) Original-Received: from mail-oi0-x230.google.com (mail-oi0-x230.google.com [IPv6:2607:f8b0:4003:c06::230]) by filter3-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id t27Gb2eL025823 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sat, 7 Mar 2015 17:37:03 +0100 Original-Received: by oiav63 with SMTP id v63so22690633oia.13 for ; Sat, 07 Mar 2015 08:37:02 -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=VaJXHP/Fx1nGwcQ0yjBFCAbV/r+7iwrLXvitkH+KP68=; b=llvei9pmCrqiBOYyupa5WDr+NpmA0ZH1yHQbBFyZXoIyvgxCR0gRBOYdmTfW+gWtGk 5u7nlu6ocW+QSNM6viwfYVR2208IEcDU5YvFh5VBxDGbqjjnpO1uXO6Nb/bx/l0undBI +52YW1ZLFvUjLutFU5ve3mx5Sn5d0XI9JyXs+cPUHAPUwq37ONGHE85kkLjHbp7L4kBd 3J506M4mEFgBrWeIdVaC+fWuImvHLasmU0s5Nt9dcHF9+SNEptmwdk5v0F/DZTS7lBe0 z+2PEERcvuDiis6+0iE8b8StnTpgmB3Lw0kbDc/eN/S9YkYFLVsRHi34GJy4f3kvRTdv 0zsw== X-Received: by 10.202.209.23 with SMTP id i23mr14380686oig.108.1425746221990; Sat, 07 Mar 2015 08:37:01 -0800 (PST) Original-Received: by 10.60.148.232 with HTTP; Sat, 7 Mar 2015 08:37:01 -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::230; country=US; latitude=38.0000; longitude=-97.0000; http://maps.google.com/maps?q=38.0000,-97.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 06O0EB30Q - 41329e037c1c - 20150307 (trained as not-spam) Received-SPF: pass (filter3-til.mf.surf.net: domain of desdechaves@gmail.com designates 2607:f8b0:4003:c06::230 as permitted sender) receiver=filter3-til.mf.surf.net; client-ip=2607:f8b0:4003:c06::230; envelope-from=; helo=mail-oi0-x230.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:90456 Archived-At: --===============0481474651== Content-Type: multipart/alternative; boundary=001a113d37021a0b190510b56942 --001a113d37021a0b190510b56942 Content-Type: text/plain; charset=UTF-8 Why the metapost not updated the value of text variables that are generated inside luacode environment? In the code below, If I have \startitemize[columns,two] then metapost draw: 1. \Bolha[size=6cm]{text1}{text2}{text3}, 2. and four \Bolha[size=4cm]{text1}{text2}{text3}, but text1, text2 and text3 is not updated in every call; If I omit the itemize environment or with \startitemize metapost only draw: 1. the first call of Bolha that is: \Bolha[size=6cm]{text1}{text2}{text3} 2. and four call of \Bolha[size=6cm]{text1}{text2}{text3} %% all new information is omited Jorge %%%%% code \def\Bolha[#1]#2#3#4% {\setupMPvariables[bolha][#1]% \setMPtext{labelcima}{#3}% \setMPtext{labelesquerda}{#2}% \setMPtext{labeldireita}{#4}% \useMPgraphic{bolha}} \startuniqueMPgraphic{bolha} path p, q, cima, esquerda, direita, vertical; pair A, B, C; p:=fullcircle scaled \MPvar{size}; A:= (point 4 of p); B:= (point 8 of p); C:= (point 6 of p); q:=A--B; vertical := .5[A,B]--C; cima := buildcycle(q, subpath(4,8) of reverse p); esquerda := buildcycle(subpath(4,6) of p, vertical, subpath(0,.5) of q); direita := buildcycle(subpath(6,8) of p, subpath(0,.5) of reverse q, vertical); draw p; draw q; draw vertical; label(textext( \MPstring{labelcima} ), center cima); label(textext( \MPstring{labelesquerda} ), center esquerda); label(textext( \MPstring{labeldireita} ), center direita); \stopuniqueMPgraphic \starttext \placefigure[center, nonumber]{}{ \Bolha[size=6cm]{$C_m$ (g/dm\high{3})}{mass (g)}{V\low{s} (dm\high{3})} } \startitemize[columns,two] %% try only \startitemize \startluacode flasks={20,25,50,100,200,250,500,1000} k=1 repeat Cm=math.random(1,10)/10 Vs=flasks[math.random(1,8)]/1000 mass=Cm*Vs --incognita=math.random(1,3) incognita=1 context.item() if incognita==1 then context("\\Bolha[size=4cm]{$C_m$}{%.2f g}{%.1f dm\\high{3}} mass=%.2f g", mass, Vs, mass) elseif incognita==2 then context("\\Bolha[size=5cm]{%.1f g/dm\\high{3}}{m}{%.1f dm\\high{3}} mass= hidde", Cm, Vs, mass) elseif incognita==3 then context("\\Bolha[size=5cm]{%.1f g/dm\\high{3}}{%.2f g}{V\\low{s}} mass=%.2f g", Cm ,mass, mass) end k=k+1 until k==5 \stopluacode \stopitemize \stoptext %%% stop code --001a113d37021a0b190510b56942 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Why the metapost not updated the value of text variab= les that are generated inside luacode environment?

In the code below, If I have \startitemize[columns,two] then metapost draw= :

1. \Bolha[size=3D6cm]{text1}{text2}{text3},=C2= =A0
2. and four =C2=A0\Bolha[size=3D4cm]{text1}{text2}{text3}, bu= t text1, text2 and text3 is not updated in every call;

=

If I omit the itemize environment or with \startitemize= =C2=A0metapost only draw:

1. the first call of Bo= lha that is: \Bolha[size=3D6cm]{text1}{text2}{text3}
2. and four = call of \Bolha[size=3D6cm]{text1}{text2}{text3} %% all new information is o= mited


Jorge
<= br>
%%%%% code

\def\Bolha[#1]#2#3#= 4%
{\setupMPvariables[bolha][#1]%
\setMPtext{labelcima}= {#3}%
\setMPtext{labelesquerda}{#2}%
\setMPtext{labeldi= reita}{#4}%
\useMPgraphic{bolha}}


\startuniqueMPgraphic{bolha}
path p, q, cima, esquerda, = direita, vertical; pair A, B, C;

p:=3Dfullcircle s= caled \MPvar{size};
A:=3D (point 4 of p);
B:=3D (point = 8 of p);
C:=3D (point 6 of p);
q:=3DA--B;
ver= tical :=3D .5[A,B]--C;
cima :=3D buildcycle(q, subpath(4,8) of re= verse p);
esquerda :=3D buildcycle(subpath(4,6) of p, vertical, s= ubpath(0,.5) of q);
direita :=3D buildcycle(subpath(6,8) of p, su= bpath(0,.5) of reverse q, vertical);

draw p;
=
draw q;
draw vertical;

label(textex= t( \MPstring{labelcima} ), center cima);
label(textext( \MPstring= {labelesquerda} ), center esquerda);
label(textext( \MPstring{lab= eldireita} ), center direita);

\stopuniqueMPgraphi= c



\starttext



\placefigure[center, nonumb= er]{}{
\Bolha[= size=3D6cm]{$C_m$ (g/dm\high{3})}{mass (g)}{V\low{s} (dm\high{3})}
}


\startitemize[columns,two] %% t= ry only \startitemize

\startluacode
flas= ks=3D{20,25,50,100,200,250,500,1000}

k=3D1
repeat

Cm=3Dmath.random(1,10)/10
Vs= =3Dflasks[math.random(1,8)]/1000
mass=3DCm*Vs

--incognita=3Dmath.random(1,3)
incognita=3D1

=
context.item()

if incognita=3D=3D1 then=

context("\\Bolha[size=3D4cm]{$C_m$}{%.2f g}{= %.1f dm\\high{3}} mass=3D%.2f g", mass, Vs, mass)

=
elseif incognita=3D=3D2 then

context("\\= Bolha[size=3D5cm]{%.1f g/dm\\high{3}}{m}{%.1f dm\\high{3}} =C2=A0mass=3D hi= dde", Cm, Vs, mass)
elseif incognita=3D=3D3 then
<= br>
context("\\Bolha[size=3D5cm]{%.1f g/dm\\high{3}}{%.2f g}= {V\\low{s}} =C2=A0 mass=3D%.2f g", Cm ,mass, mass)
end=C2=A0=

k=3Dk+1
until k=3D=3D5

\stopluacode

\stopitemize

<= /div>
\stoptext

%%% stop code


--001a113d37021a0b190510b56942-- --===============0481474651== 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= --===============0481474651==--