Re: [NTG-context] passvariable(); path problem

2013-10-07 Thread Peter Rolf
Am 06.10.2013 17:06, schrieb Hans Hagen:
 On 10/6/2013 3:05 PM, Peter Rolf wrote:
 
 Thanks for the explanation. I think I have understood the scheme (but I
 might be wrong, because this doesn't help me with my example).

 Where is the starting point['20 20'] in the returned example path? Same
 is true for the first control point ['20 190.34']. Either I'm missing
 something, or the returned path data is incomplete.
 
 you get just the value of the path variable in your mp code, not a ps or
 whatever representation and in mp a path has just points so the starting
 point is the x y of the first point


I tested several examples and the only time that the starting point was
part of the returned path was, when the path only consists of one point.
In all other cases it was missing.

This is a bit contrary to my definition of a (complete) path. Anyhow,
thanks for the pointer :-)

Peter

 -
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
  | www.pragma-pod.nl
 -
 ___
 
 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
 ___
 
 

___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-07 Thread luigi scarso
On Mon, Oct 7, 2013 at 10:48 AM, Peter Rolf indi...@gmx.net wrote:

 Am 06.10.2013 17:06, schrieb Hans Hagen:
  On 10/6/2013 3:05 PM, Peter Rolf wrote:
 
  Thanks for the explanation. I think I have understood the scheme (but I
  might be wrong, because this doesn't help me with my example).
 
  Where is the starting point['20 20'] in the returned example path? Same
  is true for the first control point ['20 190.34']. Either I'm missing
  something, or the returned path data is incomplete.
 
  you get just the value of the path variable in your mp code, not a ps or
  whatever representation and in mp a path has just points so the starting
  point is the x y of the first point
 

 I tested several examples and the only time that the starting point was
 part of the returned path was, when the path only consists of one point.
 In all other cases it was missing.

 This is a bit contrary to my definition of a (complete) path. Anyhow,
 thanks for the pointer :-)


in mp-mlib.mpiv should be :
vardef mfun_path_to_string(expr p) =
mfun_point_to_string(p,0) for i=1 upto length(p) :
mfun_point_to_string(p,i) endfor
enddef ;


(You can fix it and rebuild the format. To understand the output, is better
to know that mfun_point_to_string is

 vardef mfun_point_to_string(expr p,i) =
decimal xpart (point   i of p)
decimal ypart (point   i of p)
decimal xpart (precontrol  i of p)
decimal ypart (precontrol  i of p)
decimal xpart (postcontrol i of p)
decimal ypart (postcontrol i of p)
enddef ;

)


-- 
luigi
___
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
___

Re: [NTG-context] passvariable(); path problem

2013-10-07 Thread Hans Hagen

On 10/7/2013 11:47 AM, luigi scarso wrote:


(You can fix it and rebuild the format. To understand the output, is
better to know that mfun_point_to_string is


no need to rebuild the format (at least not currently) as mp loads runtime

the next beta will have (the somewhat useless) helper:

\starttext

\startluacode

local result = metapost.quickanddirty(metafun,[[ draw fullcircle 
scaled 1cm ;]])


context(% t,result.bbox)
context.par()
context(% t,result.code)
context.par()

\stopluacode

\stoptext

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-07 Thread Peter Rolf
Am 07.10.2013 11:47, schrieb luigi scarso:
 
 
 
 On Mon, Oct 7, 2013 at 10:48 AM, Peter Rolf indi...@gmx.net
 mailto:indi...@gmx.net wrote:
 
 Am 06.10.2013 17:06, schrieb Hans Hagen:
  On 10/6/2013 3:05 PM, Peter Rolf wrote:
 
  Thanks for the explanation. I think I have understood the scheme
 (but I
  might be wrong, because this doesn't help me with my example).
 
  Where is the starting point['20 20'] in the returned example
 path? Same
  is true for the first control point ['20 190.34']. Either I'm missing
  something, or the returned path data is incomplete.
 
  you get just the value of the path variable in your mp code, not a
 ps or
  whatever representation and in mp a path has just points so the
 starting
  point is the x y of the first point
 
 
 I tested several examples and the only time that the starting point was
 part of the returned path was, when the path only consists of one point.
 In all other cases it was missing.
 
 This is a bit contrary to my definition of a (complete) path. Anyhow,
 thanks for the pointer :-)
 
 
 in mp-mlib.mpiv should be :
 vardef mfun_path_to_string(expr p) =
 mfun_point_to_string(p,0) for i=1 upto length(p) :
 mfun_point_to_string(p,i) endfor
 enddef ;
 
 
 (You can fix it and rebuild the format. To understand the output, is
 better to know that mfun_point_to_string is
 
  vardef mfun_point_to_string(expr p,i) =
 decimal xpart (point   i of p)
 decimal ypart (point   i of p)
 decimal xpart (precontrol  i of p)
 decimal ypart (precontrol  i of p)
 decimal xpart (postcontrol i of p)
 decimal ypart (postcontrol i of p)
 enddef ;
 
 )
 
 
 -- 
 luigi

@Luigi: thanks for the fix!

@Hans: quickanddirty sounds promising (bbox is needed anyway) :-D

___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-06 Thread Peter Rolf
Am 06.10.2013 00:37, schrieb Hans Hagen:
 On 10/5/2013 5:52 PM, Peter Rolf wrote:
 I played around with it, but I have problems to understand the format of
 the returned path.

 Example:
 % 
 \setuppagenumber[state=stop]

 \starttext
 \nopdfcompression

 \startMPpage
path p;
p:= (20,20){up} .. {down}(200,100);
passvariable(path,p);
draw p ;
 \stopMPpage

 \ctxlua{inspect{metapost.variables[path]}}
 \stoptext
 % ---

 The PDF code of the path is (mainly)

 20.00 20.00 m
 20.00 190.342880 200.00 184.016693 200.00 100.00 c

 path contains

 table={
   {
{ 200, 100, 200, 184.0167, 200, 100 },
   },
 }

 The end point and the second control point are the same, as in the PDF
 code. But how do I calculate the starting point and the first control
 point from the returned values?
 
 something
 
 local prev = nil
 for i=1,#path do
 local current = path[i]
 if not prev then
 print(current[1],current[2],m)
 else
 print(prev[5],prev[6],prev[3],prev[4],current[1],current[2],c)
 end
 prev = current
 end
 -- close last to first if needed
 
 And is the type of operation (line, curve,..) given by the number of
 values?
 
 by analyzing using thresholds (one can just use c always, as l is an
 optimization)
 
 Hans
 

Thanks for the explanation. I think I have understood the scheme (but I
might be wrong, because this doesn't help me with my example).

Where is the starting point['20 20'] in the returned example path? Same
is true for the first control point ['20 190.34']. Either I'm missing
something, or the returned path data is incomplete.


Peter

___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-06 Thread Hans Hagen

On 10/6/2013 3:05 PM, Peter Rolf wrote:


Thanks for the explanation. I think I have understood the scheme (but I
might be wrong, because this doesn't help me with my example).

Where is the starting point['20 20'] in the returned example path? Same
is true for the first control point ['20 190.34']. Either I'm missing
something, or the returned path data is incomplete.


you get just the value of the path variable in your mp code, not a ps or 
whatever representation and in mp a path has just points so the starting 
point is the x y of the first point


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-05 Thread Peter Rolf
I played around with it, but I have problems to understand the format of
the returned path.

Example:
% 
\setuppagenumber[state=stop]

\starttext
\nopdfcompression

\startMPpage
  path p;
  p:= (20,20){up} .. {down}(200,100);
  passvariable(path,p);
  draw p ;
\stopMPpage

\ctxlua{inspect{metapost.variables[path]}}
\stoptext
% ---

The PDF code of the path is (mainly)

20.00 20.00 m
20.00 190.342880 200.00 184.016693 200.00 100.00 c

path contains

table={
 {
  { 200, 100, 200, 184.0167, 200, 100 },
 },
}

The end point and the second control point are the same, as in the PDF
code. But how do I calculate the starting point and the first control
point from the returned values?
And is the type of operation (line, curve,..) given by the number of values?


Peter

Am 04.10.2013 16:15, schrieb Hans Hagen:
 On 10/4/2013 2:52 PM, Peter Rolf wrote:
 Hi,

 I played around with the new passvariable() option and ran into errors
 when passing a path. Used the latest beta (01.10.2013). Can someone
 confirm this?
 
 in mp-mlib.mpiv:
 
 vardef mfun_path_to_string(expr p) =
 mfun_point_to_string(p,1) for i=2 upto length(p) :
 mfun_point_to_string(p,i) endfor
 enddef ;
 
 vardef mfun_boolean_to_string(expr b) =
 if b : true else : false fi
 enddef ;
 
 (i forgot to rename the argument when outlining the code)
 
 fwiw: in your case you still get an (empty) graphic, use
 \startMPcalculation ... when you don't want that
 
 Hans
 
 -
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
  | www.pragma-pod.nl
 -
 ___
 
 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
 ___
 
 

___
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
___


Re: [NTG-context] passvariable(); path problem

2013-10-05 Thread Hans Hagen

On 10/5/2013 5:52 PM, Peter Rolf wrote:

I played around with it, but I have problems to understand the format of
the returned path.

Example:
% 
\setuppagenumber[state=stop]

\starttext
\nopdfcompression

\startMPpage
   path p;
   p:= (20,20){up} .. {down}(200,100);
   passvariable(path,p);
   draw p ;
\stopMPpage

\ctxlua{inspect{metapost.variables[path]}}
\stoptext
% ---

The PDF code of the path is (mainly)

20.00 20.00 m
20.00 190.342880 200.00 184.016693 200.00 100.00 c

path contains

table={
  {
   { 200, 100, 200, 184.0167, 200, 100 },
  },
}

The end point and the second control point are the same, as in the PDF
code. But how do I calculate the starting point and the first control
point from the returned values?


something

local prev = nil
for i=1,#path do
local current = path[i]
if not prev then
print(current[1],current[2],m)
else
print(prev[5],prev[6],prev[3],prev[4],current[1],current[2],c)
end
prev = current
end
-- close last to first if needed

 And is the type of operation (line, curve,..) given by the number of 
values?


by analyzing using thresholds (one can just use c always, as l is an 
optimization)


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


[NTG-context] passvariable(); path problem

2013-10-04 Thread Peter Rolf
Hi,

I played around with the new passvariable() option and ran into errors
when passing a path. Used the latest beta (01.10.2013). Can someone
confirm this?

Peter
\starttext
\startMPcode
passvariable(path,fullcircle scaled 1cm) ;
\stopMPcode
\stoptext 
___
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
___

Re: [NTG-context] passvariable(); path problem

2013-10-04 Thread Hans Hagen

On 10/4/2013 2:52 PM, Peter Rolf wrote:

Hi,

I played around with the new passvariable() option and ran into errors
when passing a path. Used the latest beta (01.10.2013). Can someone
confirm this?


in mp-mlib.mpiv:

vardef mfun_path_to_string(expr p) =
mfun_point_to_string(p,1) for i=2 upto length(p) : 
mfun_point_to_string(p,i) endfor

enddef ;

vardef mfun_boolean_to_string(expr b) =
if b : true else : false fi
enddef ;

(i forgot to rename the argument when outlining the code)

fwiw: in your case you still get an (empty) graphic, use 
\startMPcalculation ... when you don't want that


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___