ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Update text variables inside metapost
@ 2015-03-07 16:37 DesdeChaves
  2015-03-07 23:57 ` Aditya Mahajan
  0 siblings, 1 reply; 4+ messages in thread
From: DesdeChaves @ 2015-03-07 16:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2221 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 3541 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-08  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07 16:37 Update text variables inside metapost DesdeChaves
2015-03-07 23:57 ` Aditya Mahajan
2015-03-08  0:28   ` DesdeChaves
2015-03-08  9:54   ` Hans Hagen

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).