Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-12 Thread Taco Hoekwater
Hi,

> On 11 Feb 2021, at 17:41, Mikael Sundqvist  wrote:
> 
> Thanks for your investigation and extended example!
> 
> So, if I understand it correctly, the problem occurs where the
> different circles are glued together with the .. construction.

Took me a while to get it, but the problem is the definition of p0:

p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated 240) .. 
(cl rotated 240) .. cycle;

Here are cs and cl after your earlier definition:

cs := (141.732246,-49.097491614210789)
  ..(75.312386775380347,111.25424516116959)
  ..(28.347427842053655,147.2925755432174);
   
cl := (28.346108531095332,147.29283827977969)
  ..(0,154.88788322842163)
  ..(-28.346108531095332,147.29283827977969);

Note how the last point of cs and the first point of cl are nearly the same. 
When you combine these bits into p0, p0 becomes a cyclic path with 18 points 
(where you really want/need only 12 points).

The micro-segments between these nearly-identical paths are the problem. At 
smaller u values the differences between the points become zero, and the 
directionpoint of a path of length zero is mathematically undefined. 

I do not know a quick generic solution off hand, but that is what the issue is.

Best wishes,
Taco


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-11 Thread Mikael Sundqvist
Thanks for your investigation and extended example!

So, if I understand it correctly, the problem occurs where the
different circles are glued together with the .. construction.

I will wait to see if Alan or somebody else has an idea of a nice
solution to the problem.

/Mikael

On Thu, Feb 11, 2021 at 3:54 PM Hans Hagen  wrote:
>
> On 2/11/2021 2:45 PM, Mikael Sundqvist wrote:
> > Hi,
> >
> > since I already started this thread, I continue here. My metapost code
> > is still not always working, and I do not understand what is going
> > wrong. In the example below, I draw two curves of constant width (p1
> > and p2), one rotated 180 degrees around the origin. Then I draw the
> > curve (p3), constructed as follows: for each direction (phi), find the
> > point of p1 and p2 which correspond to it, and add those points. This
> > should result in a circle, and with the code I paste it does (hooray!
> > see the file minkowski-good.pdf). BUT, it seems very unstable. If I
> > change u to 0.5cm instead of 1cm, it breaks down (see
> > minkowski-bad.pdf). If I loop over more angles phi (say step 2 instead
> > of step 30), it gets wrong.
> >
> > Any ideas are welcome.
> You need help from a metapost-mathematician to answer this (ping ...
> Alan). Here is a variant that shows you what happens (keep in mind that
> ".." is not always that useful with that amount of points):
>
> \starttext
> \startMPdefinitions{doublefun}
>
> def FOO(expr u) =
>
> path p[];
>
> % This defines the reulleaux curves
> % p[0] is a "base" reulleaux curve
> path cl,cs,rl ;
> z0 = (0,6/sqrt(3)*u);
> z1 = z0 rotated 120;
> cl := (fullcircle scaled 4u) shifted z0;
> cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
> cs := (fullcircle scaled 16u) shifted z1;
> cs := cs cutafter point 1/6 along cs;
> p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs
> rotated 240) .. (cl rotated 240) .. cycle;
>
> % the first curve (darkyellow)
> % p[1] := p[0] rotated 27 shifted (-10u,2u);
> p[1] := p[0] rotated 27 shifted (-10u,2u);
> draw p1 withpen pencircle scaled 2bp withcolor darkyellow;
> % the second curve (darkblue)
> p[2] := p[1] rotated 180;
> draw p2 withpen pencircle scaled 2bp withcolor darkblue;
>
> % the minkowski sum (darkred) of the reulleaux curves p1 and p2.
> % p3 := for phi=0 step 30 until 360: ((directionpoint dir(phi) of p1)
> % shifted (directionpoint dir(phi) of p2)) .. endfor cycle;
> % draw p3 withpen pencircle scaled 2bp withcolor darkred;
>
> % for phi=0 step 30 until 360:
> % draw (directionpoint dir(phi) of p1) withpen pencircle scaled 4bp
> withcolor darkgreen;
> % draw (directionpoint dir(phi) of p2) withpen pencircle scaled 4bp
> withcolor darkmagenta;
> % endfor ;
>
> drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of p1)
> -- endfor cycle withpen pencircle scaled 1bp withcolor darkgreen;
> drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of p2)
> -- endfor cycle withpen pencircle scaled 1bp withcolor darkmagenta;
>
> drawarrow for phi=0 step 30 until 360:
>  ((directionpoint dir(phi) of p1) shifted (directionpoint dir(phi)
> of p2)) -- endfor cycle
> % .5[directionpoint dir(phi) of p1, directionpoint dir(phi) of p2]
> -- endfor cycle
> withpen pencircle scaled 1bp withcolor darkred;
>
> % We give one direction as example
> % These are merely here to show the construction of the curve
> % But they also show what is going wrong
>
> direx:=40;
>
> z11=directionpoint dir(direx) of p1;
> z22=directionpoint dir(direx) of p2;
>
> p4 = ((-u,0)--(u,0)) rotated direx;
>
> % These arrows should be tangent
> drawarrow p4 shifted z11;
> drawarrow p4 shifted z22;
> drawarrow p4 shifted (z11 shifted z22);
>
> % Draw the parallelogram.
> draw origin -- z11 dashed evenly;
> draw origin -- z22 dashed evenly;
> draw z11 -- (z11 shifted z22) dashed evenly;
> draw z22 -- (z11 shifted z22) dashed evenly;
>
> % dotlabel.top("$O$",origin);
> enddef ;
> \stopMPdefinitions
>
> \startMPpage[offset=4bp,instance=doublefun]
>  FOO(1cm);
> \stopMPpage
> \startMPpage[offset=4bp,instance=doublefun]
>  FOO(.8cm);
> \stopMPpage
> \startMPpage[offset=4bp,instance=doublefun]
>  FOO(.5cm);
> \stopMPpage
> \startMPpage[offset=4bp,instance=doublefun]
>  draw image (FOO(1/20)) scaled 5cm withpen pencircle scaled 1bp;
> \stopMPpage
> \stoptext
>
> You probably end up in the 1bp resolutions ... or something around the
> origin ... so maybe just calculate large and scale the result to what
> you want.
>
> Hans
>
> --

Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-11 Thread Hans Hagen

On 2/11/2021 2:45 PM, Mikael Sundqvist wrote:

Hi,

since I already started this thread, I continue here. My metapost code
is still not always working, and I do not understand what is going
wrong. In the example below, I draw two curves of constant width (p1
and p2), one rotated 180 degrees around the origin. Then I draw the
curve (p3), constructed as follows: for each direction (phi), find the
point of p1 and p2 which correspond to it, and add those points. This
should result in a circle, and with the code I paste it does (hooray!
see the file minkowski-good.pdf). BUT, it seems very unstable. If I
change u to 0.5cm instead of 1cm, it breaks down (see
minkowski-bad.pdf). If I loop over more angles phi (say step 2 instead
of step 30), it gets wrong.

Any ideas are welcome.
You need help from a metapost-mathematician to answer this (ping ... 
Alan). Here is a variant that shows you what happens (keep in mind that 
".." is not always that useful with that amount of points):


\starttext
\startMPdefinitions{doublefun}

def FOO(expr u) =

path p[];

% This defines the reulleaux curves
% p[0] is a "base" reulleaux curve
path cl,cs,rl ;
z0 = (0,6/sqrt(3)*u);
z1 = z0 rotated 120;
cl := (fullcircle scaled 4u) shifted z0;
cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
cs := (fullcircle scaled 16u) shifted z1;
cs := cs cutafter point 1/6 along cs;
p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs
rotated 240) .. (cl rotated 240) .. cycle;

% the first curve (darkyellow)
% p[1] := p[0] rotated 27 shifted (-10u,2u);
p[1] := p[0] rotated 27 shifted (-10u,2u);
draw p1 withpen pencircle scaled 2bp withcolor darkyellow;
% the second curve (darkblue)
p[2] := p[1] rotated 180;
draw p2 withpen pencircle scaled 2bp withcolor darkblue;

% the minkowski sum (darkred) of the reulleaux curves p1 and p2.
% p3 := for phi=0 step 30 until 360: ((directionpoint dir(phi) of p1)
% shifted (directionpoint dir(phi) of p2)) .. endfor cycle;
% draw p3 withpen pencircle scaled 2bp withcolor darkred;

% for phi=0 step 30 until 360:
% draw (directionpoint dir(phi) of p1) withpen pencircle scaled 4bp 
withcolor darkgreen;
% draw (directionpoint dir(phi) of p2) withpen pencircle scaled 4bp 
withcolor darkmagenta;

% endfor ;

drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of p1) 
-- endfor cycle withpen pencircle scaled 1bp withcolor darkgreen;
drawarrow for phi=0 step 30 until 360: (directionpoint dir(phi) of p2) 
-- endfor cycle withpen pencircle scaled 1bp withcolor darkmagenta;


drawarrow for phi=0 step 30 until 360:
((directionpoint dir(phi) of p1) shifted (directionpoint dir(phi) 
of p2)) -- endfor cycle
% .5[directionpoint dir(phi) of p1, directionpoint dir(phi) of p2] 
-- endfor cycle

withpen pencircle scaled 1bp withcolor darkred;

% We give one direction as example
% These are merely here to show the construction of the curve
% But they also show what is going wrong

direx:=40;

z11=directionpoint dir(direx) of p1;
z22=directionpoint dir(direx) of p2;

p4 = ((-u,0)--(u,0)) rotated direx;

% These arrows should be tangent
drawarrow p4 shifted z11;
drawarrow p4 shifted z22;
drawarrow p4 shifted (z11 shifted z22);

% Draw the parallelogram.
draw origin -- z11 dashed evenly;
draw origin -- z22 dashed evenly;
draw z11 -- (z11 shifted z22) dashed evenly;
draw z22 -- (z11 shifted z22) dashed evenly;

% dotlabel.top("$O$",origin);
enddef ;
\stopMPdefinitions

\startMPpage[offset=4bp,instance=doublefun]
FOO(1cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
FOO(.8cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
FOO(.5cm);
\stopMPpage
\startMPpage[offset=4bp,instance=doublefun]
draw image (FOO(1/20)) scaled 5cm withpen pencircle scaled 1bp;
\stopMPpage
\stoptext

You probably end up in the 1bp resolutions ... or something around the 
origin ... so maybe just calculate large and scale the result to what 
you want.


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-11 Thread Mikael Sundqvist
Hi,

since I already started this thread, I continue here. My metapost code
is still not always working, and I do not understand what is going
wrong. In the example below, I draw two curves of constant width (p1
and p2), one rotated 180 degrees around the origin. Then I draw the
curve (p3), constructed as follows: for each direction (phi), find the
point of p1 and p2 which correspond to it, and add those points. This
should result in a circle, and with the code I paste it does (hooray!
see the file minkowski-good.pdf). BUT, it seems very unstable. If I
change u to 0.5cm instead of 1cm, it breaks down (see
minkowski-bad.pdf). If I loop over more angles phi (say step 2 instead
of step 30), it gets wrong.

Any ideas are welcome.

/Mikael

\starttext
\startMPpage[offset=4bp,instance=doublefun]
u:=1cm;

path p[];

% This defines the reulleaux curves
% p[0] is a "base" reulleaux curve
path cl,cs,rl ;
z0 = (0,6/sqrt(3)*u);
z1 = z0 rotated 120;
cl := (fullcircle scaled 4u) shifted z0;
cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
cs := (fullcircle scaled 16u) shifted z1;
cs := cs cutafter point 1/6 along cs;
p[0] := cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs
rotated 240) .. (cl rotated 240) .. cycle;

% the first curve (darkyellow)
p[1] := p[0] rotated 27 shifted (-10u,2u);
draw p1 withpen pencircle scaled 2bp withcolor darkyellow;
% the second curve (darkblue)
p[2] := p[1] rotated 180;
draw p2 withpen pencircle scaled 2bp withcolor darkblue;

% the minkowski sum (darkred) of the reulleaux curves p1 and p2.
p3 := for phi=0 step 30 until 360: ((directionpoint dir(phi) of p1)
shifted (directionpoint dir(phi) of p2)) .. endfor cycle;
draw p3 withpen pencircle scaled 2bp withcolor darkred;

% We give one direction as example
% These are merely here to show the construction of the curve
% But they also show what is going wrong

direx:=40;

z11=directionpoint dir(direx) of p1;
z22=directionpoint dir(direx) of p2;

p4 = ((-u,0)--(u,0)) rotated direx;

% These arrows should be tangent
drawarrow p4 shifted z11;
drawarrow p4 shifted z22;
drawarrow p4 shifted (z11 shifted z22);

% Draw the parallelogram.
draw origin -- z11 dashed evenly;
draw origin -- z22 dashed evenly;
draw z11 -- (z11 shifted z22) dashed evenly;
draw z22 -- (z11 shifted z22) dashed evenly;

dotlabel.top("$O$",origin);

\stopMPpage
\stoptext

On Fri, Feb 5, 2021 at 5:51 PM Mikael Sundqvist  wrote:
>
> Hi,
>
> I was too quick to push send. This must be some rounding error.
> Changing the instance fixes the problem. Sorry for the noise.
>
> /Mikael
>
> On Fri, Feb 5, 2021 at 5:48 PM Mikael Sundqvist  wrote:
> >
> > Hi,
> >
> > I get sometimes the wrong directionpoint. In the example below it
> > works for all values of direx except between 0 and 90. If I put direx
> > to something in this interval, it seems that the point between cs and
> > cl are chosen.
> >
> > Is there a better way to construct the paths not to get this problem?
> > Or some other way out?
> >
> > /Mikael
> >
> > \starttext
> > \startMPpage[offset=3bp]
> > u:=1cm;
> > path cl,cs,rl,p[];
> > z0 = (0,6/sqrt(3)*u);
> > z1 = z0 rotated 120;
> > cs := (fullcircle scaled 16u) shifted z1;
> > cs := cs cutafter point 1/6 along cs;
> > cl := (fullcircle scaled 4u) shifted z0;
> > cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
> >
> > p[0] = cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated
> > 240) .. (cl rotated 240) .. cycle;
> >
> > draw p[0];
> >
> > drawarrow cs withcolor darkblue;
> > drawarrow cl withcolor darkred;
> >
> > direx=300;
> > z11=directionpoint dir(direx) of p[0];
> > drawarrow ((-u,0)--(u,0)) rotated direx shifted z11;
> >
> > \stopMPpage
> > \stoptext


minkowski-good.pdf
Description: Adobe PDF document


minkowski-bad.pdf
Description: Adobe PDF document
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-05 Thread Mikael Sundqvist
Hi,

I was too quick to push send. This must be some rounding error.
Changing the instance fixes the problem. Sorry for the noise.

/Mikael

On Fri, Feb 5, 2021 at 5:48 PM Mikael Sundqvist  wrote:
>
> Hi,
>
> I get sometimes the wrong directionpoint. In the example below it
> works for all values of direx except between 0 and 90. If I put direx
> to something in this interval, it seems that the point between cs and
> cl are chosen.
>
> Is there a better way to construct the paths not to get this problem?
> Or some other way out?
>
> /Mikael
>
> \starttext
> \startMPpage[offset=3bp]
> u:=1cm;
> path cl,cs,rl,p[];
> z0 = (0,6/sqrt(3)*u);
> z1 = z0 rotated 120;
> cs := (fullcircle scaled 16u) shifted z1;
> cs := cs cutafter point 1/6 along cs;
> cl := (fullcircle scaled 4u) shifted z0;
> cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;
>
> p[0] = cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated
> 240) .. (cl rotated 240) .. cycle;
>
> draw p[0];
>
> drawarrow cs withcolor darkblue;
> drawarrow cl withcolor darkred;
>
> direx=300;
> z11=directionpoint dir(direx) of p[0];
> drawarrow ((-u,0)--(u,0)) rotated direx shifted z11;
>
> \stopMPpage
> \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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Metapost: directionpoint gives unexpected point(?)

2021-02-05 Thread Mikael Sundqvist
Hi,

I get sometimes the wrong directionpoint. In the example below it
works for all values of direx except between 0 and 90. If I put direx
to something in this interval, it seems that the point between cs and
cl are chosen.

Is there a better way to construct the paths not to get this problem?
Or some other way out?

/Mikael

\starttext
\startMPpage[offset=3bp]
u:=1cm;
path cl,cs,rl,p[];
z0 = (0,6/sqrt(3)*u);
z1 = z0 rotated 120;
cs := (fullcircle scaled 16u) shifted z1;
cs := cs cutafter point 1/6 along cs;
cl := (fullcircle scaled 4u) shifted z0;
cl := cl cutbefore point 1/6 along cl cutafter point 2/6 along cl;

p[0] = cs .. cl .. (cs rotated 120) .. (cl rotated 120) .. (cs rotated
240) .. (cl rotated 240) .. cycle;

draw p[0];

drawarrow cs withcolor darkblue;
drawarrow cl withcolor darkred;

direx=300;
z11=directionpoint dir(direx) of p[0];
drawarrow ((-u,0)--(u,0)) rotated direx shifted z11;

\stopMPpage
\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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] About baseline alignment in metapost - issue on the wiki ?

2021-01-29 Thread Stefan Nedeljkovic
Thank you very much Garulfo!

On Fri, Jan 29, 2021 at 9:34 AM Garulfo  wrote:

> The dlft version doesn't seem to work on the wiki.
>
> A MVE here https://wiki.contextgarden.net/textext_positioning#Test_dlft
>
>
>
>
> Le 29/01/2021 à 09:01, Garulfo a écrit :
> > To align with the baseline :
> >
> > thetextext.drt("Hello, World!", (1cm, 5cm)) ;
> >
> > Also existing :
> >
> > thetextext.d  (center)
> > thetextext.dlft   (left)
>
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] About baseline alignment in metapost - issue on the wiki ?

2021-01-29 Thread Taco Hoekwater


> On 29 Jan 2021, at 09:33, Garulfo  wrote:
> 
> The dlft version doesn't seem to work on the wiki.
> 
> A MVE here https://wiki.contextgarden.net/textext_positioning#Test_dlft

Version issue? The wiki is still running a context from june last year.
> 
> 
> 
> 
> Le 29/01/2021 à 09:01, Garulfo a écrit :
>> To align with the baseline :
>> thetextext.drt("Hello, World!", (1cm, 5cm)) ;
>> Also existing :
>> thetextext.d  (center)
>> thetextext.dlft   (left)
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)



___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] About baseline alignment in metapost - issue on the wiki ?

2021-01-29 Thread Garulfo

The dlft version doesn't seem to work on the wiki.

A MVE here https://wiki.contextgarden.net/textext_positioning#Test_dlft




Le 29/01/2021 à 09:01, Garulfo a écrit :

To align with the baseline :

thetextext.drt("Hello, World!", (1cm, 5cm)) ;

Also existing :

thetextext.d  (center)
thetextext.dlft   (left)

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] About baseline alignment in metapost

2021-01-29 Thread Garulfo

To align with the baseline :

thetextext.drt("Hello, World!", (1cm, 5cm)) ;

Also existing :

thetextext.d  (center)
thetextext.dlft   (left)
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] About baseline alignment in metapost

2021-01-28 Thread Stefan Nedeljkovic
Dear list,
Consider the following example:

\definepapersize [custom] [width=20cm, height=15cm]
\setuppapersize [custom]
\setuplayout [
width=fit,
rightmargin=0cm,
leftmargin=0cm,
leftmargindistance=0pt,
rightmargindistance=0pt,
height=fit,
header=0pt,
footer=0pt,
topspace=0cm,
backspace=0cm,
bottomspace=0cm,
bottom=0pt,
location=singlesided]
\setuppagenumbering[location=]


\startMPpage
StartPage ;
width := PaperWidth ; height := PaperHeight ; unit := cm ;
drawoptions(withpen pencircle scaled .2pt withcolor .8white) ;
draw vlingrid(0, width /unit, 1/10, width, height) ;
draw hlingrid(0, height/unit, 1/10, height, width ) ;
drawoptions(withpen pencircle scaled .5pt withcolor .4white) ;
draw vlingrid(0, width /unit, 1, width, height) ;
draw hlingrid(0, height/unit, 1, height, width ) ;

draw thetextext.origin("Hello, World!", (1cm, 5cm)) ;
StopPage ;
\stopMPpage

I want to position the text "Hello, World!" such that the vertical
coordinate of the text origin is at the baseline, but the output seems to
be the same even if I use  "thetextext.raw" (note how the output changes if
I remove the comma from the text). Also, how would I go about setting the
origin on the right side?

Kind regards,
Stefan
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Appearance of ticks and grids with ConTeXt metapost graph module

2021-01-04 Thread Jean-Philippe Rey
Dear list,

Thanks to Hans, I am now able to use the ConTeXt graph module with LMTX. 
However, I noticed that the tick/grid labels are drawn with the same parameters 
as the tick/grid marks.

For example

   grid.bot("@d", 1) withcolor red;

will draw the grid line AND "1" in red. The original metapost graph module 
doesn't apply drawing instructions to the label. That seems a better choice as 
you usually don't want to apply special effect on the labels. If you really 
want to draw the label with specific parameters you can write, for example,

   grid.bot(image(draw textext(1) withcolor blue;), 1) withcolor red;

and get red lines and blue labels. With the ConTeXt version, both line and 
label would be red! 

What do you think about reverting to the original metapost behavior? If I am 
right, here is a patch to do it:

--- mp-grap.mpiv2021-01-04 18:29:15.0 +0100
+++ mp-grap-new.mpiv2021-01-04 20:47:36.0 +0100
@@ -882,7 +882,7 @@
 if c : graph_xyscale fi
 shifted (((.5 + mfun_laboff@# dotprod (.5,.5)) * mfun_laboff@#) 
graph_xyscale) ;
 image(draw p w ;
-label@#(if string f : format(f,u) else : f fi, point 0 of p) w)
+label@#(if string f : format(f,u) else : f fi, point 0 of p))
   fi
 enddef ;


Thanks for reading this far.

-- 
Jean-Philippe Rey
jean-philippe@centralesupelec.fr
91192 Gif-sur-Yvette Cedex - France
Empreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Jean-Philippe Rey
Le 3 janv. 2021 à 19:21, Hans Hagen <j.ha...@xs4all.nl> a écrit :On 1/3/2021 7:12 PM, Jean-Philippe Rey wrote:Dear List,I have used TikZ and pgfplots for a few years and I am considering switching to metapost/metafun which appears more efficient with LMTX. I have already designed several figures with metapost/metafun and some with the help of metaobj and I am fully satisfied with the result.Alan rewrote graph in a more context way ... so, there is the m-grapph.mkiv module (I admit, not tested for a while).Thank you Hans for pointing to this module.I took a look at m-graph.mkiv and wrote the following ==\usemodule[graph]\starttext\startMPcode{graph}draw begingraph(150mm, 100mm);	gdraw "test-mpgraph.txt";	endgraph;\stopMPcode\stoptext==which fails with "error: Improper type" (see attached log file). Maybe I don't understand how to use the graph module.
-- Jean-Philippe Reyjean-philippe@centralesupelec.fr91192 Gif-sur-Yvette Cedex - FranceEmpreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51



test-mpgraph.log
Description: Binary data
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Hans Hagen

On 1/3/2021 7:12 PM, Jean-Philippe Rey wrote:

Dear List,

I have used TikZ and pgfplots for a few years and I am considering switching to 
metapost/metafun which appears more efficient with LMTX. I have already 
designed several figures with metapost/metafun and some with the help of 
metaobj and I am fully satisfied with the result.


Alan rewrote graph in a more context way ... so, there is the 
m-grapph.mkiv module (I admit, not tested for a while).


Hans
 -
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] metapost graph and ConTeXt LMTX

2021-01-03 Thread Jean-Philippe Rey
Dear List,

I have used TikZ and pgfplots for a few years and I am considering switching to 
metapost/metafun which appears more efficient with LMTX. I have already 
designed several figures with metapost/metafun and some with the help of 
metaobj and I am fully satisfied with the result.

I am now trying to draw graphs with the metapost graph module, but I haven't 
been integrated to my ConTeXt LMTX document. The following example works 
perfectly well when compiled directly with metapost (from TeXlive 2020).

= mpost example =
beginfig(1)
input graph

draw begingraph(150mm, 100mm);
gdraw "test-mpgraph.txt";
endgraph;
endfig;
end
=

Here is my demo data file

 test-mpgraph.txt 
0 0
1 1
2 2
3 1
4 3
5 2
6 1
==

I tried the following to draw directly from a ConTeXt document

 LMTX example =
\starttext
\startMPcode
troffmode:=0;
prologues:=0;
input graph

draw begingraph(150mm, 100mm);
gdraw "test-mpgraph.txt";
endgraph;
\stopMPcode
\stoptext
===

I had to define troffmode and prologues, otherwise I get error messages about 
undecidable expressions and now I get an error that I don't understand (see 
attached log file).

I also tried \usemodule[graph] as documented on the wiki 
(https://wiki.contextgarden.net/MPgraph) but without success.

I guess I am doing something wrong. Could someone help me see my error?

Thanks,

-- 
Jean-Philippe Rey
jean-philippe@centralesupelec.fr
91192 Gif-sur-Yvette Cedex - France
Empreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51


test-mpgraph.log
Description: Binary data
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] drop shadows with metapost/ metafun

2021-01-02 Thread Henning Hraban Ramm


> Am 29.12.2020 um 22:56 schrieb Garulfo :
> 
> Which process would you advice to add « drop shadows » to any kind of metafun 
> / metapost figures like:
> picture p;
> p := textext("MetaPost is fun!") shifted (10cm,10cm);
> 
> 
> My current understanding of the required steps :
> 
> 
> 1- fill p with the shadow color
> 
> 2- write it to an external metapost file (with savebuffer ?) ready for png 
> export (outputformat := "png »;)
> 
> 3- with lua, os.execute, and imagemagick prepare the shadow
>   - extent the png file with a transparent background, to have room for 
> blurring 
>   - blur it
> 
> 4- import this png in context / Metapost (externalfigure), and center it with 
> p figure
> 
> 5- shift it according to the desired shadows distance and angle
> 
> 6- apply the initial bounding box of p to the shadow, draw the shadow, draw 
> the p picture 
> 
> 
> Actually, all this seems long and tedious, and contrasts with the already 
> existing links between MetaPost / MetaFun and cairo + libpng.

I don’t know if that helps, but I’m using a stack of transparent objects to 
simulate drop shadows:
https://wiki.contextgarden.net/Drop_shadows

No pixel images required. But I’d like to have a real text shadow instead of 
that box shadow.


Happy New Year!
Hraban
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] drop shadows with metapost/ metafun

2020-12-31 Thread Aditya Mahajan
On Fri, 1 Jan 2021, Aditya Mahajan wrote:

> On Tue, 29 Dec 2020, Garulfo wrote:
> 
> > Which process would you advice to add « drop shadows » to any kind of 
> > metafun / metapost figures like:
>
> > Actually, all this seems long and tedious, and contrasts with the already 
> > existing links between MetaPost / MetaFun and cairo + libpng.
> 
> There was a drops module by Peter Rolf, which provides exactly these features:
> 
> https://mailman.ntg.nl/pipermail/ntg-context/2016/084242.html
> 
> It is not part of modules.contextgarden.net and the url in the previous post 
> is no longer valid. 
> 
> I am CC:ing Peter and perhaps he can point to the updated location for the 
> module. 

Also, if you don't want the shadows to be too nice, you can also translate the 
fake shadows used by tikz to metapost:

https://adityam.github.io/context-blog/post/drop-shadow-with-lifted-corners/

Aditya___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] drop shadows with metapost/ metafun

2020-12-31 Thread Aditya Mahajan
On Tue, 29 Dec 2020, Garulfo wrote:

> Which process would you advice to add « drop shadows » to any kind of metafun 
> / metapost figures like:
> picture p;
> p := textext("MetaPost is fun!") shifted (10cm,10cm);
> 
> My current understanding of the required steps :
> 
> 
> 1- fill p with the shadow color
> 
> 2- write it to an external metapost file (with savebuffer ?) ready for png 
> export (outputformat := "png »;)
> 
> 3- with lua, os.execute, and imagemagick prepare the shadow
>   - extent the png file with a transparent background, to have room for 
> blurring 
>   - blur it
> 
> 4- import this png in context / Metapost (externalfigure), and center it with 
> p figure
> 
> 5- shift it according to the desired shadows distance and angle
> 
> 6- apply the initial bounding box of p to the shadow, draw the shadow, draw 
> the p picture 
> 
> 
> Actually, all this seems long and tedious, and contrasts with the already 
> existing links between MetaPost / MetaFun and cairo + libpng.

There was a drops module by Peter Rolf, which provides exactly these features:

https://mailman.ntg.nl/pipermail/ntg-context/2016/084242.html

It is not part of modules.contextgarden.net and the url in the previous post is 
no longer valid. 

I am CC:ing Peter and perhaps he can point to the updated location for the 
module. 

Aditya___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] drop shadows with metapost/ metafun

2020-12-29 Thread Garulfo
Which process would you advice to add « drop shadows » to any kind of metafun / 
metapost figures like:
picture p;
p := textext("MetaPost is fun!") shifted (10cm,10cm);

My current understanding of the required steps :


1- fill p with the shadow color

2- write it to an external metapost file (with savebuffer ?) ready for png 
export (outputformat := "png »;)

3- with lua, os.execute, and imagemagick prepare the shadow
  - extent the png file with a transparent background, to have room for 
blurring 
  - blur it

4- import this png in context / Metapost (externalfigure), and center it with p 
figure

5- shift it according to the desired shadows distance and angle

6- apply the initial bounding box of p to the shadow, draw the shadow, draw the 
p picture 


Actually, all this seems long and tedious, and contrasts with the already 
existing links between MetaPost / MetaFun and cairo + libpng.

Thanks again for your help.___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bugs using \startTEXpage ... \stopTEXpage, Metapost and text

2020-12-06 Thread Pablo Rodriguez
On 12/6/20 3:29 PM, Jairo A. del Rio wrote:
> [...]
> gives a normal output in MkIV, but buggy output in LMTX. It seems only
> TeX commands in Metapost (textext, thetextext, etc.) are affected. Am I
> missing something?

Hi Jairo,

the sample can be much simpler:

  \starttext
  \startMPcode
  draw textext("some text");
  \stopMPcode
  \stoptext

This might be related to the issue that I reported about text scaling in
lmt_followtext
(https://mailman.ntg.nl/pipermail/ntg-context/2020/100573.html).

Just in case it helps,

Pablo
--
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Bugs using \startTEXpage ... \stopTEXpage, Metapost and text

2020-12-06 Thread Jairo A. del Rio
Hi. The following:

\starttext
%Using \startMPpage instead doesn't help
\startTEXpage[width=1920px,height=1080px,margin=1em]
\startplacefigure[location=force,number=no]
\startMPcode
draw textext("some text");
\stopMPcode
\stopplacefigure
\stopTEXpage
\stoptext

gives a normal output in MkIV, but buggy output in LMTX. It seems only TeX
commands in Metapost (textext, thetextext, etc.) are affected. Am I missing
something?

Thank you in advance.

Regards,

Jairo :)
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] embed metapost figure into document

2020-11-09 Thread Sylvain Hubert
On Mon, 9 Nov 2020 at 23:40, Jairo A. del Rio 
wrote:

> Hi, Sylvain.
>
> LuaMetaTeX and LuaTeX, the engines used by ConTeXt nowadays, use an
> embedded library, so external compilations/files are not necessary. Just
> out of curiosity, wouldn't it be easier to use a ConTeXt environment? E.g.:
>
> \starttext
> \startMPcode %\startuseMPgraphic{} if you want to reuse your graphic
> with \useMPgraphic{}
> draw fullcircle scaled cm
> %withcolor black % black is default
> ;
> \stopMPcode %\stopuseMPgraphic
> \stoptext
>
> More info here:
> https://wiki.contextgarden.net/MetaFun_-_MetaPost_in_ConTeXt
> To actually answer your question, if you actually want to load a Metapost
> graphic externally generated, you should have something like:
>
> %nice.mp
> %"begin ... endfig", as well as "end" are important
> beginfig (1);
> draw fullcircle scaled cm
> %withcolor black
> ;
> endfig;
> end
>
> so when you compile it via
>
> mpost nice.mp
>
> (obviously supposing you have Metapost installed) you'll get a file called
> nice.1 and
>
> \starttext
>
> \externalfigure[nice.1][width=4cm]
>
> \stoptext
>
> will work. However, as you can see, ConTeXt deals with such minutiae for
> you and extends Metapost capabilities too, so the second alternative is not
> the ConTeXt way to go.
>
> I hope it helps.
>
> Jairo :)
>

Hi Jairo,

Thank you very much for the suggestion and the thorough explanation.

I extracted the metapost code to a new file because I felt it would be a
bit lengthy and noisy to stay with the text content.

But you're right, an extra compilation step is not any better. I should
probably use \component figure.tex, in place of \externalfigure[figure.1]

Sylvain
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] embed metapost figure into document

2020-11-09 Thread Jairo A. del Rio
Hi, Sylvain.

LuaMetaTeX and LuaTeX, the engines used by ConTeXt nowadays, use an
embedded library, so external compilations/files are not necessary. Just
out of curiosity, wouldn't it be easier to use a ConTeXt environment? E.g.:

\starttext
\startMPcode %\startuseMPgraphic{} if you want to reuse your graphic
with \useMPgraphic{}
draw fullcircle scaled cm
%withcolor black % black is default
;
\stopMPcode %\stopuseMPgraphic
\stoptext

More info here: https://wiki.contextgarden.net/MetaFun_-_MetaPost_in_ConTeXt
To actually answer your question, if you actually want to load a Metapost
graphic externally generated, you should have something like:

%nice.mp
%"begin ... endfig", as well as "end" are important
beginfig (1);
draw fullcircle scaled cm
%withcolor black
;
endfig;
end

so when you compile it via

mpost nice.mp

(obviously supposing you have Metapost installed) you'll get a file called
nice.1 and

\starttext

\externalfigure[nice.1][width=4cm]

\stoptext

will work. However, as you can see, ConTeXt deals with such minutiae for
you and extends Metapost capabilities too, so the second alternative is not
the ConTeXt way to go.

I hope it helps.

Jairo :)

El lun., 9 de nov. de 2020 a la(s) 16:59, Sylvain Hubert (
champign...@gmail.com) escribió:

> Dear List,
>
> I'm trying to embed a metapost image into the document. According the MetaFun
> manual <http://www.pragma-ade.com/general/manuals/metafun-p.pdf>,
> "embedding such a graphic is done by:
> \externalfigure[graphic.123][width=4cm]", but the following example
> produces an empty page:
>
> % test.mkxl
> \starttext
> \externalfigure[test.123][width=4cm]
> \stoptext
>
> % test.123
> draw fullcircle scaled cm withcolor black;
>
> Does anyone know how to properly embed a metapost image into a context
> document?
>
> Thanks!
>
> Best,
> Sylvain
>
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] embed metapost figure into document

2020-11-09 Thread Sylvain Hubert
Dear List,

I'm trying to embed a metapost image into the document. According the MetaFun
manual <http://www.pragma-ade.com/general/manuals/metafun-p.pdf>,
"embedding such a graphic is done by:
\externalfigure[graphic.123][width=4cm]", but the following example
produces an empty page:

% test.mkxl
\starttext
\externalfigure[test.123][width=4cm]
\stoptext

% test.123
draw fullcircle scaled cm withcolor black;

Does anyone know how to properly embed a metapost image into a context
document?

Thanks!

Best,
Sylvain
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] About Metapost and patterns, tessellations, fractals, etc.

2020-09-07 Thread Jairo A. del Rio
Hi, list! I have a problem with some graphics in Metapost. I've tried to
replicate the Koch curve cited here using ConTeXt:

https://en.wikipedia.org/wiki/L-system

To my own amusement, the patterns seem to appear. However, when I try with
a number from 6, ConTeXt stops doing anything or output looks wrong (see
attached PDF, please).

\startluacode
userdata = userdata or {}

function userdata.koch(n)

local init = "F"
local base = init
  local replacement = "F+F-F-F+F"

for i = 1, n do
init = init:gsub(base, replacement)
end

return init

end

function userdata.kochlen(n)
return string.len(userdata.koch(n))
end

function userdata.kochchar(k, n)
return string.sub(userdata.koch(n),k,k)
end

function MP.kochlen(n)
mp.print(userdata.kochlen(n))
end

function MP.kochchar(k,n)
mp.quoted(userdata.kochchar(k,n))
end

\stopluacode
\startMPpage[instance=doublefun]

def koch_curve(expr n, u) =

save p; save q;
save angle;

pair p, last; path q; numeric angle;
p:= origin;
q := origin;
angle := 0;

for i = 1 upto lua.MP.kochlen(n):
if lua.MP.kochchar(i,n) = "F":
q := q -- ((point infinity of q) + dir(angle));
else:
if lua.MP.kochchar(i,n) = "+":
angle := (angle + 90) mod 360;
else:
if lua.MP.kochchar(i,n) = "-":
angle := (angle - 90) mod 360;
fi
fi
fi
endfor;
draw q scaled u;
enddef;

koch_curve(5, 5mm);
%koch_curve(6, 5mm); does not give a right output

\stopMPpage

Maybe there's a fabulous trick to make it work with larger numbers, but I
don't know it. I'm aware of a TikZ library for Lindenmayer systems, but
it's not a possibility for me in this case (I add the remark just in case).

Thank you in advance,

Jairo :)


error.pdf
Description: Adobe PDF document
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-02 Thread Fabrice Couvreur
Hello,
That's okay, I'll compile the files with mpost and do an image insert. Thanks
for your help.
Fabrice

Le mar. 1 sept. 2020 à 19:32, Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> a écrit :

> Taco Hoekwater schrieb am 01.09.2020 um 19:12:
>
> Hi,
>
>
> On 1 Sep 2020, at 16:46, Hans Hagen   
> wrote:
>
> On 9/1/2020 3:04 PM, Fabrice Couvreur wrote:
>
> Hi Taco,
> Thank you for your help. I specify that this extension works perfectly by 
> compiling the following file.
>
> A logfile of a failed run would have been more helpful in trying to track 
> down the problem. But I did notice that there is a LaTeX file loaded in your 
> succesful run. So perhaps the extension depends on LaTeX
>
>
> I looked for the file online [1] and it uses LaTeX commands (even
> begin/end blocks) for all text boxes.
>
> [1] https://melusine.eu.org/syracuse/poulecl/mp-scratch/
>
> Wolfgang
>
>
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-01 Thread Wolfgang Schuster

Taco Hoekwater schrieb am 01.09.2020 um 19:12:

Hi,


On 1 Sep 2020, at 16:46, Hans Hagen  wrote:

On 9/1/2020 3:04 PM, Fabrice Couvreur wrote:

Hi Taco,
Thank you for your help. I specify that this extension works perfectly by 
compiling the following file.

A logfile of a failed run would have been more helpful in trying to track down 
the problem. But I did notice that there is a LaTeX file loaded in your 
succesful run. So perhaps the extension depends on LaTeX


I looked for the file online [1] and it uses LaTeX commands (even 
begin/end blocks) for all text boxes.


[1] https://melusine.eu.org/syracuse/poulecl/mp-scratch/

Wolfgang

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-01 Thread Taco Hoekwater
Hi,

> On 1 Sep 2020, at 16:46, Hans Hagen  wrote:
> 
> On 9/1/2020 3:04 PM, Fabrice Couvreur wrote:
>> Hi Taco,
>> Thank you for your help. I specify that this extension works perfectly by 
>> compiling the following file.

A logfile of a failed run would have been more helpful in trying to track down 
the problem. But I did notice that there is a LaTeX file loaded in your 
succesful run. So perhaps the extension depends on LaTeX?
> 
>  input "mp-scratch.mp" ;
> 
> maybe the path you look for is not part of the search path either
> 
>   mtxrun --expand-path MPINPUTS
> 
> Hans
> 
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-01 Thread Hans Hagen

On 9/1/2020 3:04 PM, Fabrice Couvreur wrote:

Hi Taco,
Thank you for your help. I specify that this extension works perfectly 
by compiling the following file.


input mp-scratch;

Scratchversion:=3;

beginfig(1);
   draw Drapeau;
   draw Repeter("4");
   draw Avancer("100");
   draw Tournerd("90");
   draw FinBlocRepeter;
   endfig;
end


But what you are proposing unfortunately does not work.

what if you add a suffix:

  input "mp-scratch.mp" ;

maybe the path you look for is not part of the search path either

   mtxrun --expand-path MPINPUTS

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-01 Thread Fabrice Couvreur
Hi Taco,
Thank you for your help. I specify that this extension works perfectly by
compiling the following file.

input mp-scratch;

Scratchversion:=3;

beginfig(1);
  draw Drapeau;
  draw Repeter("4");
  draw Avancer("100");
  draw Tournerd("90");
  draw FinBlocRepeter;
  endfig;
end


But what you are proposing unfortunately does not work.
Fabrice

Le mar. 1 sept. 2020 à 14:25, Taco Hoekwater  a écrit :

> Hi,
>
> I think you need this:
>
> \startMPinclusions
>   input mp-scratch;
> \stopMPinclusions
>
> \startMPcode
>   Scratchversion:=3;
>   ….
>
> If that also doesn’t work, perhaps attach the log file / terminal output
> to a new message.
>
> Best wishes,
> Taco
>
> > On 1 Sep 2020, at 13:07, Fabrice Couvreur 
> wrote:
> >
> > Hello
> > Is it possible to import a metapost extension into a file compiled with
> the lmtx engine ?
> > I tried unsuccessfully with this example :
> >
> >  begin test.tex
> >
> > \starttext
> > \startMPcode
> >   input mp-scratch;
> >
> > Scratchversion:=3;
> >
> > draw Drapeau;
> > draw Repeter("4");
> > draw Avancer("50");
> > draw Tournerd("90");
> > draw FinBlocRepeter;
> >
> > \stopMPcode
> > \stoptext
> >
> >  end test.tex
> >
> > Thanks
> > Fabrice
> >
> ___
> > 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://context.aanhet.net
> > archive  : https://bitbucket.org/phg/context-mirror/commits/
> > wiki : http://contextgarden.net
> >
> ___
>
> Taco Hoekwater
> Elvenkind BV
>
>
>
>
>
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
>
> ___
>
This is MetaPost, version 2.00 (TeX Live 2020) (kpathsea version 6.3.2)  1 SEP 2020 15:01
**scratch-1.mp
(/home/viserion/texlive/2020/texmf-dist/metapost/base/mpost.mp
(/home/viserion/texlive/2020/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) ) (./scratch-1.mp
(/home/viserion/texmf/metapost/mp-scratch.mp
(/home/viserion/texmf/metapost/LATEXScratch.mp)
(/home/viserion/texmf/metapost/Mouvement.mp)
(/home/viserion/texmf/metapost/Apparence.mp)
(/home/viserion/texmf/metapost/Sons.mp) (/home/viserion/texmf/metapost/Stylo.mp
) (/home/viserion/texmf/metapost/Controle.mp)
(/home/viserion/texmf/metapost/Evenements.mp)
(/home/viserion/texmf/metapost/Bloc.mp)
(/home/viserion/texmf/metapost/Divers.mp)
(/home/viserion/texmf/metapost/Capteurs.mp)
(/home/viserion/texmf/metapost/Variable.mp)) (./mptextmp.mp) (./mptextmp.mp)
>> 34.55159
>> 55.29037 (./mptextmp.mp) (./mptextmp.mp)
>> 105.50436 (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp)
(./mptextmp.mp) (./mptextmp.mp)
>> 39.74248
>> 63.32898 (./mptextmp.mp) (./mptextmp.mp)
>> 84.05197 (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp)
(./mptextmp.mp) (./mptextmp.mp)
>> 56.92798
>> 92.35968 (./mptextmp.mp) (./mptextmp.mp)
>> 112.43477 (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp) (./mptextmp.mp)
(./mptextmp.mp) (./mptextmp.mp)
>> 97.13678
>> 127.64769 (./mptextmp.mp) (./mptextmp.mp)
>> 171.08908 (./mptextmp.mp) [1{psfonts.map}{crlt_csjzgd.enc}] )
1 output file written: scratch-1.1

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Import a metapost extension

2020-09-01 Thread Taco Hoekwater
Hi,

I think you need this:

\startMPinclusions
  input mp-scratch;
\stopMPinclusions

\startMPcode
  Scratchversion:=3;
  ….

If that also doesn’t work, perhaps attach the log file / terminal output to a 
new message.

Best wishes,
Taco

> On 1 Sep 2020, at 13:07, Fabrice Couvreur  wrote:
> 
> Hello
> Is it possible to import a metapost extension into a file compiled with the 
> lmtx engine ?
> I tried unsuccessfully with this example :
> 
>  begin test.tex
> 
> \starttext
> \startMPcode
>   input mp-scratch;
> 
> Scratchversion:=3;
> 
> draw Drapeau;
> draw Repeter("4");
> draw Avancer("50");
> draw Tournerd("90");
> draw FinBlocRepeter;
>  
> \stopMPcode
> \stoptext
> 
>  end test.tex
> 
> Thanks
> Fabrice
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___

Taco Hoekwater
Elvenkind BV




___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Import a metapost extension

2020-09-01 Thread Fabrice Couvreur
Hello
Is it possible to import a metapost extension into a file compiled with the
lmtx engine ?
I tried unsuccessfully with this example :

 begin test.tex

\starttext
\startMPcode
  input mp-scratch;

Scratchversion:=3;

draw Drapeau;
draw Repeter("4");
draw Avancer("50");
draw Tournerd("90");
draw FinBlocRepeter;

\stopMPcode
\stoptext

 end test.tex

Thanks
Fabrice
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to properly pass TeX/Lua data to MetaPost/MetaFun?

2020-08-09 Thread Jairo A. del Rio
Nice, I'm reading results right now. Thank you a lot, Hans.

Jairo :)

El dom., 9 de ago. de 2020 a la(s) 13:05, Hans Hagen (j.ha...@xs4all.nl)
escribió:

> On 8/9/2020 8:03 PM, Jairo A. del Rio wrote:
> > Oh, thank you a lot, Hans, that's a really cleaner way than mine. One
> > more question, is there something similar to EmWidth for \textwidth or
> > \linewidth? Better, a better way to access TeX dimensions? Thank you
> again.
> When you grep for EmWidth ...
>
> LineWidth
> TextWidth
>
> and plenty more like that
>
> Hans
>
> -
>Hans Hagen | PRAGMA ADE
>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to properly pass TeX/Lua data to MetaPost/MetaFun?

2020-08-09 Thread Hans Hagen

On 8/9/2020 8:03 PM, Jairo A. del Rio wrote:
Oh, thank you a lot, Hans, that's a really cleaner way than mine. One 
more question, is there something similar to EmWidth for \textwidth or 
\linewidth? Better, a better way to access TeX dimensions? Thank you again.

When you grep for EmWidth ...

LineWidth
TextWidth

and plenty more like that

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to properly pass TeX/Lua data to MetaPost/MetaFun?

2020-08-09 Thread Jairo A. del Rio
Oh, thank you a lot, Hans, that's a really cleaner way than mine. One more
question, is there something similar to EmWidth for \textwidth or
\linewidth? Better, a better way to access TeX dimensions? Thank you again.

Jairo :)

El dom., 9 de ago. de 2020 a la(s) 12:46, Hans Hagen (j.ha...@xs4all.nl)
escribió:

> On 8/9/2020 5:39 PM, Jairo A. del Rio wrote:
> > Hi, list! I'm doing the following to scale squares and other stuff in
> > MetaPost/MetaFun. Although the following kinda works (maybe I'm just
> > lucky with this), I want to know how to do a better piece from it. I'm
> > concerned with passing data from Lua and TeX to Metapost and better ways
> > to do it in ConTeXt. Thank you in advance.
> >
> > \starttext
> > My text
> >
> > \startMPinitializations
> > numeric myunit;
> > myunit := \the\dimexpr1em\relax;
> > \stopMPinitializations
> > \startluacode
> >
> > userdata = userdata or {}
> > userdata.dummydata = { {1, 2}, {3, 4} }
> >
> > context.startMPcode()
> >
> > for j=1,#userdata.dummydata do
> > for i=1,#userdata.dummydata[1] do
> > context("draw unitsquare scaled myunit shifted ((%d,%d)*myunit);",
> > userdata.dummydata[i][j], userdata.dummydata[i][j])
> > end
> > end
> >
> > context.stopMPcode()
> >
> > \stopluacode
> > \stoptext
> Something:
>
> \starttext
>
> \startluacode
>
>  userdata = userdata or {}
>  userdata.dummydata = { {1, 2}, {3, 4} }
>
>  function MP.GetI()
>  mp.print(#userdata.dummydata)
>  end
>  function MP.GetJ(i)
>  mp.print(#userdata.dummydata[i])
>  end
>  function MP.GetIJ(i,j)
>  mp.pair(userdata.dummydata[i][j],userdata.dummydata[i][j])
>  end
>
> \stopluacode
>
> \startMPcode
>  numeric myunit ; myunit := EmWidth;
>  for i = 1 upto lua.MP.GetI() :
>  for j = 1 upto lua.MP.GetJ(i) :
>  draw unitsquare scaled myunit shifted (myunit *
> (lua.MP.GetIJ(i,j)));
>  endfor ;
>  endfor ;
> \stopMPcode
>
> \stoptext
>
> There are of course also other ways but this is more educational as start.
>
> Hans
>
> -
>Hans Hagen | PRAGMA ADE
>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to properly pass TeX/Lua data to MetaPost/MetaFun?

2020-08-09 Thread Hans Hagen

On 8/9/2020 5:39 PM, Jairo A. del Rio wrote:
Hi, list! I'm doing the following to scale squares and other stuff in 
MetaPost/MetaFun. Although the following kinda works (maybe I'm just 
lucky with this), I want to know how to do a better piece from it. I'm 
concerned with passing data from Lua and TeX to Metapost and better ways 
to do it in ConTeXt. Thank you in advance.


\starttext
My text

\startMPinitializations
numeric myunit;
myunit := \the\dimexpr1em\relax;
\stopMPinitializations
\startluacode

userdata = userdata or {}
userdata.dummydata = { {1, 2}, {3, 4} }

context.startMPcode()

for j=1,#userdata.dummydata do
for i=1,#userdata.dummydata[1] do
context("draw unitsquare scaled myunit shifted ((%d,%d)*myunit);", 
userdata.dummydata[i][j], userdata.dummydata[i][j])

end
end

context.stopMPcode()

\stopluacode
\stoptext

Something:

\starttext

\startluacode

userdata = userdata or {}
userdata.dummydata = { {1, 2}, {3, 4} }

function MP.GetI()
mp.print(#userdata.dummydata)
end
function MP.GetJ(i)
mp.print(#userdata.dummydata[i])
end
function MP.GetIJ(i,j)
mp.pair(userdata.dummydata[i][j],userdata.dummydata[i][j])
end

\stopluacode

\startMPcode
numeric myunit ; myunit := EmWidth;
for i = 1 upto lua.MP.GetI() :
for j = 1 upto lua.MP.GetJ(i) :
draw unitsquare scaled myunit shifted (myunit * 
(lua.MP.GetIJ(i,j)));

endfor ;
endfor ;
\stopMPcode

\stoptext

There are of course also other ways but this is more educational as start.

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] How to properly pass TeX/Lua data to MetaPost/MetaFun?

2020-08-09 Thread Jairo A. del Rio
Hi, list! I'm doing the following to scale squares and other stuff in
MetaPost/MetaFun. Although the following kinda works (maybe I'm just lucky
with this), I want to know how to do a better piece from it. I'm concerned
with passing data from Lua and TeX to Metapost and better ways to do it in
ConTeXt. Thank you in advance.

\starttext
My text

\startMPinitializations
numeric myunit;
myunit := \the\dimexpr1em\relax;
\stopMPinitializations
\startluacode

userdata = userdata or {}
userdata.dummydata = { {1, 2}, {3, 4} }

context.startMPcode()

for j=1,#userdata.dummydata do
for i=1,#userdata.dummydata[1] do
context("draw unitsquare scaled myunit shifted ((%d,%d)*myunit);",
userdata.dummydata[i][j], userdata.dummydata[i][j])
end
end

context.stopMPcode()

\stopluacode
\stoptext

Jairo :)
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-11 Thread Gerben Wierda


> On 9 Jul 2020, at 08:37, Aditya Mahajan  wrote:
> 
> On Wed, 8 Jul 2020, Gerben Wierda wrote:
> 
>> I found out this in the PDF spec:
>> 
>> The minimum page size should be 3 by 3 units in default user space; the 
>> maximum should be 14,400 by 14,400 units.
> 
> So, does the following work:
> 
> \startMPpage[instance=doublefun, offset=2pt]
>  draw (0,0)--(100,0) dashed withdots;
> \stopMPpage

Yes.

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-09 Thread Gerben Wierda
The minimum is a relative one:

It is page 650 in the (normative) Annex C Implementation Limits for PDF readers 
and writers:

Additionally, conforming writers should adhere to the following constraints, 
and conforming readers should accommodate PDF files that obey the constraints. 
The minimum page size should be 3 by 3 units in default user space; the maximum 
should be 14,400 by 14,400 units. In versions of PDF earlier than 1.6, the size 
of the default user space unit was fixed at 1⁄72 inch, yielding a minimum of 
approximately 0.04 by 0.04 inch and a maximum of 200 by 200 inches. Beginning 
with PDF 1.6, the size of the unit may be set on a page-by-page basis; the 
default remains at 1/ 72 inch. 

In other words: you need to change the unit per page so the page is at least 
3x3 and maximally 14400x14400.


> On 9 Jul 2020, at 12:10, Hans Hagen  wrote:
> 
> On 7/9/2020 9:08 AM, Taco Hoekwater wrote:
>>> On 9 Jul 2020, at 08:32, Hans Hagen  wrote:
>>> 
>>> On 7/8/2020 8:14 PM, Gerben Wierda wrote:
 I found out this in the PDF spec:
 The minimum page size should be 3 by 3 units in default user space; the
>>> 
>>> I never noticed that ... what section/paragraph in the spec?
>> It’s in the implementation limits for Acrobat, not in the normative section.
> 
> Great. That used to be 1 bp so now it's more. As it happens, we do have a 
> check for this in context so we can adapt it ... but, as this 3 bp is kind of 
> arbitrary and because 3 bp becomes a float and thereby ends up slightly less 
> than the integer 3 we can best play safe and revert to the usual tex joke, so 
> i now set the minumum to
> 
>  \luaexpr{math.pi}\onebasepoint
> 
> which then gives:
> 
>  /MediaBox [ 0 0 3.141539539 3.141539539 ] because after all, any rediculous 
> minimum will do and that way a user can still figure out that it's a value 
> set by context.
> 
> Hans
> 
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-09 Thread Hans Hagen

On 7/9/2020 9:08 AM, Taco Hoekwater wrote:




On 9 Jul 2020, at 08:32, Hans Hagen  wrote:

On 7/8/2020 8:14 PM, Gerben Wierda wrote:

I found out this in the PDF spec:
The minimum page size should be 3 by 3 units in default user space; the


I never noticed that ... what section/paragraph in the spec?


It’s in the implementation limits for Acrobat, not in the normative section.


Great. That used to be 1 bp so now it's more. As it happens, we do have 
a check for this in context so we can adapt it ... but, as this 3 bp is 
kind of arbitrary and because 3 bp becomes a float and thereby ends up 
slightly less than the integer 3 we can best play safe and revert to the 
usual tex joke, so i now set the minumum to


  \luaexpr{math.pi}\onebasepoint

which then gives:

  /MediaBox [ 0 0 3.141539539 3.141539539 ] because after all, any 
rediculous minimum will do and that way a user can still figure out that 
it's a value set by context.


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-09 Thread Aditya Mahajan

On Wed, 8 Jul 2020, Gerben Wierda wrote:


I found out this in the PDF spec:

The minimum page size should be 3 by 3 units in default user space; the maximum 
should be 14,400 by 14,400 units.


So, does the following work:

\startMPpage[instance=doublefun, offset=2pt]
  draw (0,0)--(100,0) dashed withdots;
\stopMPpage

Aditya
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-09 Thread Hans Hagen

On 7/8/2020 8:14 PM, Gerben Wierda wrote:

I found out this in the PDF spec:

The minimum page size should be 3 by 3 units in default user space; the 


I never noticed that ... what section/paragraph in the spec?


maximum should be 14,400 by 14,400 units.


So we should bump tex's maxima ...


Apparently, Adobe InDesign demands that in a hard way.
Or maybe it just cannot handle zero's. The last time I ever ran into an 
issue was that a scale should not be zero (so we always have 0.1 at 
least). But I only have an old acrobat professional so I can't check the 
latest demands.


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-08 Thread Gerben Wierda
I found out this in the PDF spec:

The minimum page size should be 3 by 3 units in default user space; the maximum 
should be 14,400 by 14,400 units.

Apparently, Adobe InDesign demands that in a hard way.

G

> On 8 Jul 2020, at 01:08, Jairo A. del Rio  wrote:
> 
> Evince and Okular (Linux) open the PDF output without warnings nor issues.
> 
> Jairo :)
> 
> El mar., 7 de jul. de 2020 a la(s) 17:50, Gerben Wierda (gerben.wie...@rna.nl 
> ) escribió:
> The following code:
> 
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0) dashed withdots;
> \stopMPpage
> 
> When run through LuaMetaTeX produces a PDF about which Acrobat complains:
> 
>   The dimensions of this page are out-of-range. Page content might be 
> truncated.
> 
> and Adobe InDesign cannot handle it at all (displays empty). 
> 
> The error message stays with
> 
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0)—(100,2) dashed withdots;
> \stopMPpage
> 
> but disappears with
> 
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0)—(100,3) dashed withdots;
> \stopMPpage
> 
> 
> Additionally, on the Adobe forums I have been told:
> 
>   Also, the color space is device gray (not RGB or CMYK)
> 
> which might be a more generic problem with LMTX output, I don’t know. It 
> might also be an Adobe problem. Previw.app on macOS handles the result 
> without problems.
> 
> ConTeXt standalone:
> 
> This is LuaMetaTeX, Version 2.06.02 
> open source > level 1, order 1, name 'cont-yes.mkiv'
> system  > 
> system  > ConTeXt  ver: 2020.05.12 16:21 MKIV beta  fmt: 2020.5.16  
> int: english/english
> 
> 
> G
> 
> 
> ___
> 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://context.aanhet.net 
> archive  : https://bitbucket.org/phg/context-mirror/commits/ 
> 
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-07 Thread Jairo A. del Rio
Evince and Okular (Linux) open the PDF output without warnings nor issues.

Jairo :)

El mar., 7 de jul. de 2020 a la(s) 17:50, Gerben Wierda (
gerben.wie...@rna.nl) escribió:

> The following code:
>
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0) dashed withdots;
> \stopMPpage
>
> When run through LuaMetaTeX produces a PDF about which Acrobat complains:
>
> The dimensions of this page are out-of-range. Page content might be
> truncated.
>
> and Adobe InDesign cannot handle it at all (displays empty).
>
> The error message stays with
>
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0)—(100,2) dashed withdots;
> \stopMPpage
>
> but disappears with
>
> \startMPpage[instance=doublefun]
>   draw (0,0)--(100,0)—(100,3) dashed withdots;
> \stopMPpage
>
>
> Additionally, on the Adobe forums I have been told:
>
> Also, the color space is device gray (not RGB or CMYK)
>
> which might be a more generic problem with LMTX output, I don’t know. It
> might also be an Adobe problem. Previw.app on macOS handles the result
> without problems.
>
> ConTeXt standalone:
>
> This is LuaMetaTeX, Version 2.06.02
> open source > level 1, order 1, name 'cont-yes.mkiv'
> system  >
> system  > ConTeXt  ver: 2020.05.12 16:21 MKIV beta  fmt:
> 2020.5.16  int: english/english
>
>
> G
>
>
>
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Minimum METAPOST code produces problematic PDF

2020-07-07 Thread Gerben Wierda
The following code:

\startMPpage[instance=doublefun]
  draw (0,0)--(100,0) dashed withdots;
\stopMPpage

When run through LuaMetaTeX produces a PDF about which Acrobat complains:

The dimensions of this page are out-of-range. Page content might be 
truncated.

and Adobe InDesign cannot handle it at all (displays empty). 

The error message stays with

\startMPpage[instance=doublefun]
  draw (0,0)--(100,0)—(100,2) dashed withdots;
\stopMPpage

but disappears with

\startMPpage[instance=doublefun]
  draw (0,0)--(100,0)—(100,3) dashed withdots;
\stopMPpage


Additionally, on the Adobe forums I have been told:

Also, the color space is device gray (not RGB or CMYK)

which might be a more generic problem with LMTX output, I don’t know. It might 
also be an Adobe problem. Previw.app on macOS handles the result without 
problems.

ConTeXt standalone:

This is LuaMetaTeX, Version 2.06.02 
open source > level 1, order 1, name 'cont-yes.mkiv'
system  > 
system  > ConTeXt  ver: 2020.05.12 16:21 MKIV beta  fmt: 2020.5.16  
int: english/english


G


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] 'debug' version of METAPOST draw?

2020-05-28 Thread Keith McKay
Would Chapter 11, section 11.1 Showing Paths of the MetaPost manual, be 
any help here?


Below is a MWE of a random path of curves and straight lines. The points 
are shown using drawpoints. The arrow path and control lines are also 
shown and are better described in the Metapost manual.


MWE%%%

\setuppapersize [A4,landscape]

\starttext

\startMPpage[instance=doublefun]

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

path p ;

path pat;

pat := (5cm,5cm);

for a = 1 step 1 until 10:

x:= uniformdeviate(10) +10;

y:= uniformdeviate(10) +10;

if odd a:

pat := pat .. (x*cm,y*cm);

else:

pat := pat -- (x*cm,y*cm);

fi;

draw pat withpen pencircle scaled 5mm withcolor .5green;

endfor;

drawarrowpath pat;

drawpoints pat;

drawcontrollines pat withcolor .625red ;

StopPage;

\stopMPpage

\stoptext

%%% end MWE %

A better coder than me may be able to incorporate it into what you require.

Best Wishes

Keith McKay

On 28/05/2020 12:33, Gerben Wierda wrote:

I would like to be able (during development) to draw paths where the points of 
the path (and maybe thing slike directions) are visualised. E.g. a path where 
each pair in teh path is also drawn as a dot and maybe teh directions drawn as 
small arrows.

Does someone have such a beast lying around?

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] 'debug' version of METAPOST draw?

2020-05-28 Thread Gerben Wierda
I would like to be able (during development) to draw paths where the points of 
the path (and maybe thing slike directions) are visualised. E.g. a path where 
each pair in teh path is also drawn as a dot and maybe teh directions drawn as 
small arrows.

Does someone have such a beast lying around?

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] metapost boxes error

2020-05-20 Thread Aditya Mahajan

On Wed, 20 May 2020, jk...@inradius.net wrote:


Is there a different approach to use boxes.mp?

MNWE:

\startMPpage
input boxes.mp;
 boxit.bl("left");
 boxit.br("right");
 br.sw - bl.ne = (20,0);
 drawboxed(bl,br);
\stopMPpage


Move `input boxes` outside the `\startMPpage`.


\startMPdefinitions
  input boxes.mp;
\stopMPdefinitions

\starttext
\startMPpage
  boxit.bl("left");
  boxit.br("right");
  br.sw - bl.ne = (20,0);
  drawboxed(bl,br);
\stopMPpage
\stoptext


Aditya
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] metapost boxes error

2020-05-20 Thread jk...@inradius.net
Is there a different approach to use boxes.mp?

MNWE:

\startMPpage
input boxes.mp;
  boxit.bl("left");
  boxit.br("right");
  br.sw - bl.ne = (20,0);
  drawboxed(bl,br);
\stopMPpage

LOG snippets:

system  > ConTeXt  ver: 2020.04.10 19:11 MKIV beta  fmt: 2020.4.19  
int: english/english

metapost log> loading metafun, including plain.mp version 1.004 for metafun 
iv and xl
metapost log> 
metapost log> >> _dojoin
metapost log> ! Isolated expression.




___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Looking for a way to use lua to output console/debug messages from MetaPost instead of 'show'

2020-05-18 Thread Gerben Wierda
I often need some debugging info to find out what is going on in my METAPOST 
code (as I often do not have exact knowledge of what some things do). 
MetaPost’s ‘show’ command has limited formatting functionality (e.g. I would 
like to add a number as a string to a show message instead of putting it out as 
number and let ‘show' make a lot of lines out of it). 

I would like to instead use a lua function and I think I recall having seen 
somewhere the use of a call like lua( ….) or lua.foo.bar() in a 
MetaPost/MetaFun/LMTX example but I cannot find it anymore. 

Is it possible to do a lua() call from within MetaPost within LMTX and if so, 
what is the way to do it? This below is the state of my misguided attempts:

\startluacode
function warnWithLabelIfVerbose( str, ... )
  texio.write_nl( str .. string.format(...))
end
\stopluacode

\startMPdefinitions{doublefun}
%def somefunction ( expr str, number) =
%  lua.warnWithLabel( "LABEL: ", "%s %d", str, number);
%enddef;
\stopMPdefinitions

\startMPpage[instance=doublefun]
lua.texio.write_nl( "HELLO!"); % This works
%lua.texio.write( "HELLO!\%n"); % This doesn't
%string outs; outs := lua.string.format( "HELLO! \%s \%0.3f", "aap", 12.6);
%somefunction( "aap", 12.6);
\stopMPpage

Thx,

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using transparency in METAPOST within textext()

2020-05-14 Thread Gerben Wierda
Thank you. That works.

> On 14 May 2020, at 17:13, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 14.05.2020 um 11:47:
>> Is it possible to get a transparent background in a textext()? The following 
>> minimal example doesn’t work.
>> \starttext
>> \setupMPpage
>>   [background=color,
>>backgroundcolor=gray]
>> \startMPpage
>> draw textext("\definecolor[labelbackground][a=0.2,r=1,g=1,b=1]
> 
> \definecolor[labelbackground][a=1,t=0.2,r=1,g=1,b=1]
> 
> Wolfgang


G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using transparency in METAPOST within textext()

2020-05-14 Thread Wolfgang Schuster

Gerben Wierda schrieb am 14.05.2020 um 11:47:
Is it possible to get a transparent background in a textext()? The 
following minimal example doesn’t work.


\starttext
\setupMPpage
   [background=color,
    backgroundcolor=gray]
\startMPpage
draw 
textext("\definecolor[labelbackground][a=0.2,r=1,g=1,b=1]


\definecolor[labelbackground][a=1,t=0.2,r=1,g=1,b=1]

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Using transparency in METAPOST within textext()

2020-05-14 Thread Gerben Wierda
Is it possible to get a transparent background in a textext()? The following 
minimal example doesn’t work.

\starttext
\setupMPpage
  [background=color,
   backgroundcolor=gray]
\startMPpage
draw 
textext("\definecolor[labelbackground][a=0.2,r=1,g=1,b=1]\framed[height=1.2em,background=color,backgroundcolor=labelbackground,foregroundcolor=black]{Text
 in Label}");
\stopMPpage

\stoptext


Thx.

G


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] \goto works but links don't when passed via textext() in METAPOST

2020-05-10 Thread Gerben Wierda
I am trying to get an URL link in a textext() via METAPOST. I’ve got this 
before \starttext (or after, tried both):

\setupinteraction
   [state=start,
color=blue,
style=bold]

The intended link shows up in blue and bold, but it is not clickable.

I’ve turned ConTeXt tracing on and see this when the text is passed to METAPOST:

cld > tex > f : 8 : picture pic; x:=1233.000; y:=913.000; 
w:=180.000; h:=407.000;pic := Label( w, h, (1.000,1.000,0.784), 1.0, 1.000, 
(0.000,0.000,0.000), 1.000, "dashed evenly", 1.000, (0.000,0.000,0.000), 1.000, 
"", "\definebodyfont[11pt][rm][default=Regular at 
11pt]\switchtobodyfont[11pt]\setupinterlinespace[12.1pt]\framed[align=flushleft,frame=off,offset=none,width=170.000bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\tf The elements are shown in colors where blue represents 
active structure, yellow behaviour, and green passive structure. See 
\goto{here}[url(https://ea.rna.nl/2011/06/05/on-the-use-of-colours-in-archimate/)].\crlf{}\crlf{}
  {\bf Color codes:}\crlf{}\crlf{}  - \colored[mared]{\bf Red}{} and 
\colored[maviolet]{\bf Violet}{} stand for a 'higher' layer element used as an 
abstract representation of a lower layer element. When the target is the 
Business Layer, it implies automated business behavior (marked 
violet).\crlf{}\crlf{}  - \colored[maorange]{\bf Orange}{} and 
\colored[mablue]{\bf Blue}{} are used to model 'downward' serving, e.g. 
Business Layer serving the Technology Layer.\crlf{}\crlf{}  - 
\colored[magreen]{\bf Green}{} stands for class relations inside the metamodel. 
Important conseqence: relations of a parent (in the meta-model) Specialization 
are valid for {\it all} children (in the meta-model). This does not happen when 
Specialization is used in an actual model. There are in fact two fully 
different specializations in ArchiMate (see the book, including the free 
excerpt, for a full explanation)\\}}", "up", "center", "center") shifted (x, 
-y);draw pic;path AllPathIds_idCDCEH;  AllPathIds_idCDCEH := pathpart pic; pair 
AllNodeCenters_idCDCEH; AllNodeCenters_idCDCEH := center pic;

The red is what is being typeset, the \goto is part of that.

And later this when METAPOST passes it on to TeX via textext(): 

cld > tex > f : 8 : \definebodyfont [11pt][rm][default=Regular at 
11pt]\switchtobodyfont [11pt]\setupinterlinespace [12.1pt]\framed 
[align=flushleft,frame=off,offset=none,width=170.000bp]{\colored [r=0.000, 
g=0.000, b=0.000]{\tf The elements are shown in colors where blue represents 
active structure, yellow behaviour, and green passive structure. See \goto 
{here}[url(https://ea.rna.nl/2011/06/05/on-the-use-of-colours-in-archimate/)].\crlf
 {}\crlf {} {\bf Color codes:}\crlf {}\crlf {} - \colored [mared]{\bf Red}{} 
and \colored [maviolet]{\bf Violet}{} stand for a 'higher' layer element used 
as an abstract representation of a lower layer element. When the target is the 
Business Layer, it implies automated business behavior (marked violet).\crlf 
{}\crlf {} - \colored [maorange]{\bf Orange}{} and \colored [mablue]{\bf 
Blue}{} are used to model 'downward' serving, e.g. Business Layer serving the 
Technology Layer.\crlf {}\crlf {} - \colored [magreen]{\bf Green}{} stands for 
class relations inside the metamodel. Important conseqence: relations of a 
parent (in the meta-model) Specialization are valid for {\it all} children (in 
the meta-model). This does not happen when Specialization is used in an actual 
model. There are in fact two fully different specializations in ArchiMate (see 
the book, including the free excerpt, for a full explanation)\\}}

Still correct. But the end result doesn’t have a working hyperlink. Outside the 
route to METAPOST, the \goto statement does produce a working link.

Should this work when passed via textext()?

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST subpath rounding issue

2020-05-10 Thread Gerben Wierda

> On 10 May 2020, at 00:01, Bruce Horrocks  wrote:
> 
>> You can save extracting the xparts and yparts by using direct subtraction of 
>> pairs and comparing with (0,0) like this:
> 
> Aaaargh, no, ignore that, it's nonsense. It's amazing how you can stare at 
> something for minutes but only see the flaw the moment you press send. Sorry 
> for the noise.

Instead, I would like to thank you for thinking about it and trying to help. 
Wrestling with it (and making mistakes) is part of all that (I’ve probably made 
more than most).

G

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST subpath rounding issue

2020-05-09 Thread Bruce Horrocks
> You can save extracting the xparts and yparts by using direct subtraction of 
> pairs and comparing with (0,0) like this:

Aaaargh, no, ignore that, it's nonsense. It's amazing how you can stare at 
something for minutes but only see the flaw the moment you press send. Sorry 
for the noise.

--
Bruce Horrocks
Hampshire, UK

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST subpath rounding issue

2020-05-09 Thread Bruce Horrocks


> On 8 May 2020, at 13:58, Gerben Wierda  wrote:
> 
>> On 8 May 2020, at 00:46, n...@scorecrow.com wrote:
>> 
>>> On 7 May 2020, at 20:28, Gerben Wierda  wrote:
>>> 
>>> I have a METAPOST algorithm that splits a path at a certain time in two, 
>>> does something with both ends (not the ends where they were split) and then 
>>> rejoins them.
>>> 
>>> In very rare cases this crashes, because the subpath doesn’t work as 
>>> expected.
>>> 
>>>  firstPart := subpath (0,halfWayTime) of workingConn;
>>>  secondPart := subpath (halfWayTime,pathTimeLen) of workingConn;
>>> 
>>> may sometimes result in something like this:
>>> 
>>> metapost log> >> Path at line 0:
>>> metapost log    > (273,-427)..controls (259.506666,-427) and 
>>> (246.013335,-427)
>>> metapost log>  ..(232.520001,-427)
>>> metapost log> 
>>> metapost log> >> Path at line 0:
>>> metapost log> (232.519998,-427)..controls 
>>> (161.680001,-427) and (90.84000
>>> metapost log> 03,-427)
>>> metapost log>  ..(20,-427)
>>> 
>>> As can be seen in these (rare) cases the two calls to subpath result in a 
>>> different point resulting from both. so, when I later try to rejoin them 
>>> with & it fails:
>>> 
>>> metapost log> ! Paths don't touch; '&' will be changed to '..'.
>>> metapost log>  
>>> 
>>> Which means subpath doesn’t always exactly do what I expect it to do (and 
>>> many explanations, but not the official manual) state. Again, this is rare.
>>> 
>>> I’ve done this to work around it but I wondered if there was a better 
>>> (reliable) solution
>>> 
>>>  save cutFirstPart; path cutFirstPart; cutFirstPart := firstPart 
>>> maxcutbefore fromPicOutline;
>>>  save cutSecondPart; path cutSecondPart; cutSecondPart := secondPart 
>>> maxcutafter toPicOutline;
>>>  if ((xpart point 0 of cutSecondPart) <> (xpart point infinity of 
>>> cutFirstPart))
>>>or ((ypart point 0 of cutSecondPart) <> (ypart point infinity of 
>>> cutFirstPart)):
>>>resultConn := cutFirstPart--cutSecondPart;
>>>  else:
>>>resultConn := cutFirstPart & cutSecondPart;
>>>  fi
>> 
>> A crude test of 
>> 
>>  path pb;
>>  pb:=(5.5cm,0cm)--(5.5cm,0cm)--(10.5cm,0cm);
>>  draw pb;
>> 
>> gives no errors so why not just join using -- all the time and save the test?
> 
> Because the double exact points are also creating (different) problems in my 
> algorithm as they make the path have 'no direction' at that point (direction 
> is (0,0).

You can save extracting the xparts and yparts by using direct subtraction of 
pairs and comparing with (0,0) like this:

\starttext
\startMPcode
path cutFirstPart,cutSecondPart;

cutFirstPart := (0,0) -- (232.520001,-427);
cutSecondPart := (232.519998,-427) -- (999,-427);
%cutFirstPart := (0,0) -- (232.520001,-427);
%cutSecondPart := (232.520001,-427) -- (999,-427);

if (point infinity of cutFirstPart) - (point 0 of cutSecondPart) = (0,0) :
  label("same", (1cm,1cm))
else :
  label("different", (1cm,1cm))
fi;
\stopMPcode
\stoptext

*Except* that the example doesn't work with floats that are so close. Changing 
232.52_etc to 332.52_etc works as expected. I'm hoping that this is a "feature" 
of the parser reading in the example at a lower precision than the number of 
decimals provided. For your code, where the different values are created by 
calculation, the two pairs should be recognised as different.

--
Bruce Horrocks
Hampshire, UK

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST subpath rounding issue

2020-05-08 Thread Gerben Wierda


> On 8 May 2020, at 00:46, n...@scorecrow.com wrote:
> 
> 
> 
>> On 7 May 2020, at 20:28, Gerben Wierda  wrote:
>> 
>> I have a METAPOST algorithm that splits a path at a certain time in two, 
>> does something with both ends (not the ends where they were split) and then 
>> rejoins them.
>> 
>> In very rare cases this crashes, because the subpath doesn’t work as 
>> expected.
>> 
>>  firstPart := subpath (0,halfWayTime) of workingConn;
>>  secondPart := subpath (halfWayTime,pathTimeLen) of workingConn;
>> 
>> may sometimes result in something like this:
>> 
>> metapost log> >> Path at line 0:
>> metapost log> (273,-427)..controls (259.50,-427) and 
>> (246.013335,-427)
>> metapost log>  ..(232.520001,-427)
>> metapost log> 
>> metapost log> >> Path at line 0:
>> metapost log> (232.519998,-427)..controls 
>> (161.680001,-427) and (90.84000
>> metapost log> 03,-427)
>> metapost log>  ..(20,-427)
>> 
>> As can be seen in these (rare) cases the two calls to subpath result in a 
>> different point resulting from both. so, when I later try to rejoin them 
>> with & it fails:
>> 
>> metapost log> ! Paths don't touch; '&' will be changed to '..'.
>> metapost log>  
>> 
>> Which means subpath doesn’t always exactly do what I expect it to do (and 
>> many explanations, but not the official manual) state. Again, this is rare.
>> 
>> I’ve done this to work around it but I wondered if there was a better 
>> (reliable) solution
>> 
>>  save cutFirstPart; path cutFirstPart; cutFirstPart := firstPart 
>> maxcutbefore fromPicOutline;
>>  save cutSecondPart; path cutSecondPart; cutSecondPart := secondPart 
>> maxcutafter toPicOutline;
>>  if ((xpart point 0 of cutSecondPart) <> (xpart point infinity of 
>> cutFirstPart))
>>or ((ypart point 0 of cutSecondPart) <> (ypart point infinity of 
>> cutFirstPart)):
>>resultConn := cutFirstPart--cutSecondPart;
>>  else:
>>resultConn := cutFirstPart & cutSecondPart;
>>  fi
> 
> A crude test of 
> 
>  path pb;
>  pb:=(5.5cm,0cm)--(5.5cm,0cm)--(10.5cm,0cm);
>  draw pb;
> 
> gives no errors so why not just join using -- all the time and save the test?

Because the double exact points are also creating (different) problems in my 
algorithm as they make the path have 'no direction' at that point (direction is 
(0,0).

G

> 
> --
> Bruce Horrocks
> Hampshire, UK
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] METAPOST subpath rounding issue

2020-05-07 Thread Gerben Wierda
I have a METAPOST algorithm that splits a path at a certain time in two, does 
something with both ends (not the ends where they were split) and then rejoins 
them.

In very rare cases this crashes, because the subpath doesn’t work as expected.

  firstPart := subpath (0,halfWayTime) of workingConn;
  secondPart := subpath (halfWayTime,pathTimeLen) of workingConn;

may sometimes result in something like this:

metapost log> >> Path at line 0:
metapost log> (273,-427)..controls (259.50,-427) and 
(246.013335,-427)
metapost log>  ..(232.520001,-427)
metapost log> 
metapost log> >> Path at line 0:
metapost log> (232.519998,-427)..controls (161.680001,-427) 
and (90.84000
metapost log> 03,-427)
metapost log>  ..(20,-427)

As can be seen in these (rare) cases the two calls to subpath result in a 
different point resulting from both. so, when I later try to rejoin them with & 
it fails:

metapost log> ! Paths don't touch; '&' will be changed to '..'.
metapost log>  

Which means subpath doesn’t always exactly do what I expect it to do (and many 
explanations, but not the official manual) state. Again, this is rare.

I’ve done this to work around it but I wondered if there was a better 
(reliable) solution

  save cutFirstPart; path cutFirstPart; cutFirstPart := firstPart 
maxcutbefore fromPicOutline;
  save cutSecondPart; path cutSecondPart; cutSecondPart := secondPart 
maxcutafter toPicOutline;
  if ((xpart point 0 of cutSecondPart) <> (xpart point infinity of 
cutFirstPart))
or ((ypart point 0 of cutSecondPart) <> (ypart point infinity of 
cutFirstPart)):
resultConn := cutFirstPart--cutSecondPart;
  else:
resultConn := cutFirstPart & cutSecondPart;
  fi

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST subpath rounding issue

2020-05-07 Thread ntg


> On 7 May 2020, at 20:28, Gerben Wierda  wrote:
> 
> I have a METAPOST algorithm that splits a path at a certain time in two, does 
> something with both ends (not the ends where they were split) and then 
> rejoins them.
> 
> In very rare cases this crashes, because the subpath doesn’t work as expected.
> 
>   firstPart := subpath (0,halfWayTime) of workingConn;
>   secondPart := subpath (halfWayTime,pathTimeLen) of workingConn;
> 
> may sometimes result in something like this:
> 
> metapost log> >> Path at line 0:
> metapost log> (273,-427)..controls (259.506666,-427) and 
> (246.013335,-427)
> metapost log    >  ..(232.520001,-427)
> metapost log> 
> metapost log> >> Path at line 0:
> metapost log> (232.519998,-427)..controls 
> (161.680001,-427) and (90.84000
> metapost log> 03,-427)
> metapost log>  ..(20,-427)
> 
> As can be seen in these (rare) cases the two calls to subpath result in a 
> different point resulting from both. so, when I later try to rejoin them with 
> & it fails:
> 
> metapost log> ! Paths don't touch; '&' will be changed to '..'.
> metapost log>  
> 
> Which means subpath doesn’t always exactly do what I expect it to do (and 
> many explanations, but not the official manual) state. Again, this is rare.
> 
> I’ve done this to work around it but I wondered if there was a better 
> (reliable) solution
> 
>   save cutFirstPart; path cutFirstPart; cutFirstPart := firstPart 
> maxcutbefore fromPicOutline;
>   save cutSecondPart; path cutSecondPart; cutSecondPart := secondPart 
> maxcutafter toPicOutline;
>   if ((xpart point 0 of cutSecondPart) <> (xpart point infinity of 
> cutFirstPart))
> or ((ypart point 0 of cutSecondPart) <> (ypart point infinity of 
> cutFirstPart)):
> resultConn := cutFirstPart--cutSecondPart;
>   else:
> resultConn := cutFirstPart & cutSecondPart;
>   fi

A crude test of 

  path pb;
  pb:=(5.5cm,0cm)--(5.5cm,0cm)--(10.5cm,0cm);
  draw pb;

gives no errors so why not just join using -- all the time and save the test?

--
Bruce Horrocks
Hampshire, UK

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using \startuseMPgraphic inside a textext() in METAPOST?

2020-04-27 Thread Hans Hagen

On 4/27/2020 10:47 AM, Gerben Wierda wrote:
I am in METAPOST which is inside TeX and I’d like (in METAPOST, not in 
TeX) to let a string follow a path. Adapting from the MetaFun manual 
around page 250, I tried this:


\starttext

\startMPpage[instance=doublefun]
pic p;
p := textext("\startuseMPgraphic[instance=doublefun]{followtokens}path 
RotPath ; RotPath := fullcircle ;\stopuseMPgraphic\followtokens{I am 
creating a line of text here}");

draw pic;
\stopMPpage

\stoptext

But that does not work. Is there a way I can from within my METAPOST 
code get  string (TeX code) to follow a path I have? In my case, I 
cannot escape outside the \startMPpage- -\stopMPpage environment, as the 
actual path is constructed there and the text following the path should 
be on that page.

search for lmt_followtext in the luametafun manual

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Using \startuseMPgraphic inside a textext() in METAPOST?

2020-04-27 Thread Gerben Wierda
I am in METAPOST which is inside TeX and I’d like (in METAPOST, not in TeX) to 
let a string follow a path. Adapting from the MetaFun manual around page 250, I 
tried this:

\starttext

\startMPpage[instance=doublefun]
pic p;
p := textext("\startuseMPgraphic[instance=doublefun]{followtokens}path RotPath 
; RotPath := fullcircle ;\stopuseMPgraphic\followtokens{I am creating a line of 
text here}");
draw pic;
\stopMPpage

\stoptext

But that does not work. Is there a way I can from within my METAPOST code get  
string (TeX code) to follow a path I have? In my case, I cannot escape outside 
the \startMPpage- -\stopMPpage environment, as the actual path is constructed 
there and the text following the path should be on that page.

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Solution: METAPOST textext() eats my \pars. Was: Setting vertical spacing of lines inside a \framed[align=]

2020-04-25 Thread Gerben Wierda
On a hunch, I found a solution. I added \\ instead of \par at the end and goit 
exactly what I wanted.

\enabletrackers[context.trace]
\starttext

%\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000,
%b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}

\startMPpage[instance=doublefun]
draw 
textext("\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}\par}");
draw 
(textext("\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\\}}") shifted (200,0));
\stopMPpage


\stoptext


G

> On 25 Apr 2020, at 00:51, Gerben Wierda  wrote:
> 
>> On 24 Apr 2020, at 18:40, Thomas A. Schmitz > <mailto:thomas.schm...@uni-bonn.de>> wrote:
>> 
>> 
>> 
>>> On 24. Apr 2020, at 18:19, Gerben Wierda >> <mailto:gerben.wie...@rna.nl>> wrote:
>>> 
>>> \starttext
>>> 
>>> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>>>  g=0.000,
>>> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[20pt] \rm 
>>> [My]\\Application\\(Component)}}
>>> 
>>> \stoptext
>>> 
>>> and if I change the value to 0.6, only the first line break gets packed 
>>> somewhat. But I can’t get the entire paragraph inside the frame packed. I 
>>> played around with the placing of setupinterlinespace in that snippet 
>>> above, but nothing really works so far.
>>> 
>> 
>> At the end of your frame, you need an explicit \par to make the change of 
>> linespacing work:
>> 
>> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>>  g=0.000,
>> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[14pt] \rm 
>> [My]\\Application\\(Component)\par }}
> 
> Thank you, that works. (Can’t put in the images to show, as this gets my 
> message over 100k)
> 
> But it turns out, I have an additional problem because I am doing this inside 
> a textext() from METAPOST and that seems to strip the \pars again. Tracking 
> ConTeXt:
> 
> cld > tex > f : 8 : picture pic; x:=33.000; y:=53.000; 
> w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, 
> (0.686,1.000,1.000), 0.200, 1.000, (0.000,0.000,0.000), 1.000, 0.700, 
> (0.000,0.000,0.000), 1.000, 
> "\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>  g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
> [My]\\Application\\(Component)\par}}\par") shifted (x, -y); draw pic;path 
> AllNodeIds_idIC;  AllNodeIds_idIC := pathpart pic; pair AllNodeCenters_idIC; 
> AllNodeCenters_idIC := center pic;
> 
> which looks OK (this is lmtx passing the string to ConTeXt using the lua 
> context() call). The \pars are still there.
> 
> Then later, when METAPOST is at it and that same string is used to put into 
> textext(), it results in:
> 
> cld > tex > w : - : \MPLIBsetNtextX{3}{\framed 
> [align=flushright,frame=on,offset=none,width=106.400bp]{\colored [r=0.000, 
> g=0.000, b=0.000]{\switchtobodyfont [11.0pt]\setupinterlinespace [11.5pt] \rm 
> [My]\\Application\\(Component)}}}
> 
> 
> Minimal example:
> 
> \enabletrackers[context.trace]
> \starttext
> 
> % Works OK:
> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>  g=0.000,
> b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
> [My]\\Application\\(Component)\par}}
> 
> % Doesn’t work:
> \startMPpage[instance=doublefun]
> draw 
> textext("\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>  g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
> [My]\\Application\\(Component)\par}}\par");
> \stopMPpage
> 
> 
> \stoptext
> 
> So, now I’m looking for a way to prevent textext() to eat my \pars
> 
> G
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] METAPOST textext() eats my \pars. Was: Setting vertical spacing of lines inside a \framed[align=]

2020-04-24 Thread Gerben Wierda
> On 24 Apr 2020, at 18:40, Thomas A. Schmitz  <mailto:thomas.schm...@uni-bonn.de>> wrote:
> 
> 
> 
>> On 24. Apr 2020, at 18:19, Gerben Wierda > <mailto:gerben.wie...@rna.nl>> wrote:
>> 
>> \starttext
>> 
>> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>>  g=0.000,
>> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[20pt] \rm 
>> [My]\\Application\\(Component)}}
>> 
>> \stoptext
>> 
>> and if I change the value to 0.6, only the first line break gets packed 
>> somewhat. But I can’t get the entire paragraph inside the frame packed. I 
>> played around with the placing of setupinterlinespace in that snippet above, 
>> but nothing really works so far.
>> 
> 
> At the end of your frame, you need an explicit \par to make the change of 
> linespacing work:
> 
> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>  g=0.000,
> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[14pt] \rm 
> [My]\\Application\\(Component)\par }}

Thank you, that works. (Can’t put in the images to show, as this gets my 
message over 100k)

But it turns out, I have an additional problem because I am doing this inside a 
textext() from METAPOST and that seems to strip the \pars again. Tracking 
ConTeXt:

cld > tex > f : 8 : picture pic; x:=33.000; y:=53.000; w:=133.000; 
h:=53.000;pic := ApplicationComponentLogo( w, h, (0.686,1.000,1.000), 0.200, 
1.000, (0.000,0.000,0.000), 1.000, 0.700, (0.000,0.000,0.000), 1.000, 
"\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}\par") shifted (x, -y); draw pic;path 
AllNodeIds_idIC;  AllNodeIds_idIC := pathpart pic; pair AllNodeCenters_idIC; 
AllNodeCenters_idIC := center pic;

which looks OK (this is lmtx passing the string to ConTeXt using the lua 
context() call). The \pars are still there.

Then later, when METAPOST is at it and that same string is used to put into 
textext(), it results in:

cld > tex > w : - : \MPLIBsetNtextX{3}{\framed 
[align=flushright,frame=on,offset=none,width=106.400bp]{\colored [r=0.000, 
g=0.000, b=0.000]{\switchtobodyfont [11.0pt]\setupinterlinespace [11.5pt] \rm 
[My]\\Application\\(Component)}}}


Minimal example:

\enabletrackers[context.trace]
\starttext

% Works OK:
\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000,
b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}

% Doesn’t work:
\startMPpage[instance=doublefun]
draw 
textext("\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}\par");
\stopMPpage


\stoptext

So, now I’m looking for a way to prevent textext() to eat my \pars

G

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] METAPOST textext() eats my \pars. Was: Setting vertical spacing of lines inside a \framed[align=]

2020-04-24 Thread Gerben Wierda


> On 24 Apr 2020, at 18:40, Thomas A. Schmitz  <mailto:thomas.schm...@uni-bonn.de>> wrote:
> 
> 
> 
>> On 24. Apr 2020, at 18:19, Gerben Wierda > <mailto:gerben.wie...@rna.nl>> wrote:
>> 
>> \starttext
>> 
>> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>>  g=0.000,
>> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[20pt] \rm 
>> [My]\\Application\\(Component)}}
>> 
>> \stoptext
>> 
>> and if I change the value to 0.6, only the first line break gets packed 
>> somewhat. But I can’t get the entire paragraph inside the frame packed. I 
>> played around with the placing of setupinterlinespace in that snippet above, 
>> but nothing really works so far.
>> 
> 
> At the end of your frame, you need an explicit \par to make the change of 
> linespacing work:
> 
> \framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
>  g=0.000,
> b=0.000]{\switchtobodyfont[11.0pt] \setupinterlinespace[14pt] \rm 
> [My]\\Application\\(Component)\par }}

Thank you, that works: 



But it turns out, I have an additional problem because I am doing this inside a 
textext() from METAPOST and that seems to strip the \pars again. Tracking 
ConTeXt:

cld > tex > f : 8 : picture pic; x:=33.000; y:=53.000; w:=133.000; 
h:=53.000;pic := ApplicationComponentLogo( w, h, (0.686,1.000,1.000), 0.200, 
1.000, (0.000,0.000,0.000), 1.000, 0.700, (0.000,0.000,0.000), 1.000, 
"\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}\par") shifted (x, -y); draw pic;path 
AllNodeIds_idIC;  AllNodeIds_idIC := pathpart pic; pair AllNodeCenters_idIC; 
AllNodeCenters_idIC := center pic;

which looks OK (this is lmtx passing the string to ConTeXt using the lua 
context() call). The \pars are still there.

Then later, when METAPOST is at it and that same string is used to put into 
textext(), it results in:

cld > tex > w : - : \MPLIBsetNtextX{3}{\framed 
[align=flushright,frame=on,offset=none,width=106.400bp]{\colored [r=0.000, 
g=0.000, b=0.000]{\switchtobodyfont [11.0pt]\setupinterlinespace [11.5pt] \rm 
[My]\\Application\\(Component)}}}

The result of which is



Minimal example:

\enabletrackers[context.trace]
\starttext

% Works OK:
\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000,
b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}

% Doesn’t work:
\startMPpage[instance=doublefun]
draw 
textext("\framed[align=flushright,frame=on,offset=none,width=106.400bp]{\colored[r=0.000,
 g=0.000, b=0.000]{\switchtobodyfont[11.0pt]\setupinterlinespace[11.5pt] \rm 
[My]\\Application\\(Component)\par}}\par");
\stopMPpage


\stoptext

So, now I’m looking for a way to prevent textext() to eat my \pars

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-22 Thread Gerben Wierda
> On 22 Apr 2020, at 09:30, Taco Hoekwater  wrote:
> 
> Hi,
> 
>> On 21 Apr 2020, at 17:52, Gerben Wierda  wrote:
>> 
>>> pair a ; a := arrowHead intersection_point connection ;
> 
> Hans’ example also works with “intersectionpoint”: the differences between 
> intersectionpoint
> and intersection_point are minimal except if there is no intersection at all.
> 
> The trick is that Hans does not use cutafter. cutafter is designed to cut off 
> as little as 
> possible, it is a cutbefore on both paths reversed. So, uses the last 
> intersection point of 
> the paths, and in this case it will therefore use the top of the arrowhead. 
> 
> In contrast, intersectionpoint finds the first intersection on the 
> non-reversed paths, which 
> is the base of the arrowhead.
> 
> Alternatively (in this case), you could move the arrowhead up a tiny amount, 
> so that there is 
> only one intersection between the connection and arrowHead.

In fact I did something like this, except that I first shortened the line path 
so it ends in the middle of the triangle before doing a cutafter (twice in both 
directions and taking the one which cuts the most). This works reliably.

I gave up on another approach (which repeatedly cut a little bit from the path 
until it wasn’t intersecting anymore, then taking the one form thelast 
successful intersection)  as I also have paths that connect a path-cycle to 
itself. A ‘cut until it just doesn’t intersect anymore' would eat up the entire 
path in that case until only a single point is left.

G

> 
> Best wishes,
> Taco
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-22 Thread luigi scarso
On Wed, Apr 22, 2020 at 9:30 AM Taco Hoekwater  wrote:

>
> In contrast, intersectionpoint finds the first intersection on the
> non-reversed paths, which
> is the base of the arrowhead.
>
>
IIrc ,  it's the first in shuffle order

@ Incidentally, if the given cubics intersect more than once, the process
just sketched will not necessarily find the lexicographically smallest pair
$(t_1,t_2)$. The solution actually obtained will be smallest in ``shuffled
order''; i.e., if $t_1=(.a_1a_2\ldots a_{16})_2$ and
$t_2=(.b_1b_2\ldots b_{16})_2$, then we will minimize
$a_1b_1a_2b_2\ldots a_{16}b_{16}$, not
$a_1a_2\ldots a_{16}b_1b_2\ldots b_{16}$.
Shuffled order agrees with lexicographic order if all pairs of solutions
$(t_1,t_2)$ and $(t_1',t_2')$ have the property that $t_1___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-22 Thread Taco Hoekwater
Hi,

> On 21 Apr 2020, at 17:52, Gerben Wierda  wrote:
> 
>> pair a ; a := arrowHead intersection_point connection ;

Hans’ example also works with “intersectionpoint”: the differences between 
intersectionpoint
and intersection_point are minimal except if there is no intersection at all.

The trick is that Hans does not use cutafter. cutafter is designed to cut off 
as little as 
possible, it is a cutbefore on both paths reversed. So, uses the last 
intersection point of 
the paths, and in this case it will therefore use the top of the arrowhead. 

In contrast, intersectionpoint finds the first intersection on the non-reversed 
paths, which 
is the base of the arrowhead.

Alternatively (in this case), you could move the arrowhead up a tiny amount, so 
that there is 
only one intersection between the connection and arrowHead.

Best wishes,
Taco
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-21 Thread Hans Hagen

On 4/21/2020 5:52 PM, Gerben Wierda wrote:

Pretty deep into MP now. Even looked up the reference in John Hobby’s 
manual to the METAFONT book, but that reference did not help.
in the end it all has to do with accuracy and rounding ... the 
intersection_point trickery is probably less sensitive for that


but it's so long ago that i mp-tool was written that that part of my 
mind probably has been overwritten, obscured or wiped


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-21 Thread Gerben Wierda


> On 21 Apr 2020, at 14:41, Hans Hagen  wrote:
> 
> On 4/21/2020 1:29 PM, Gerben Wierda wrote:
[snip]
> 
> \startMPpage[instance=doublefun]
> 
> path arrowHead;
> arrowHead :=
>(542,-77.000186920166016)..controls 
> (545.37,-77.000186920166016) and
>(548.63,-77.000186920166016) 
> ..(552,-77.000186920166016)..controls
>(550.37,-73.666853586832687) and
>(548.63,-70.333520253499344) 
> ..(547,-67.000186920166016)..controls
>(545.37,-70.333520253499344) and
>(543.63,-73.666853586832687) ..cycle;
> 
> path connection;
> connection :=
>  (420.4959106445,-367)..controls (420.66670256708773,-367) and
>  (421.55543111,-367) ..(422.0851913427,-367)..controls
>  (425.3917170194,-367) and (428.698242696,-367)
>  ..(432.0047683727,-367)..controls (442.0015894574,-367) and
>  (451.9984105426,-367) ..(461.9952316273,-367)..controls
>  (464.76142345324098,-367) and (467,-364.76142382108867)
>  ..(467,-361.9997656772)..controls (467,-293.218926) and
>  (467,-226.781074) ..(467,-158.0002343228)..controls
>  (467,-155.23857623850762) and (469.23857634039018,-153)
>  ..(472.0014901161,-153)..controls (495.3338300389,-153) and
>  (518.6661699617,-153) ..(541.9985098839,-153)..controls
>  (544.76142368504975,-153) and (547,-150.76142367339932)
>  ..(547,-147.9983662815)..controls (547,-125.9994554271) and
>  (547,-104.0005445727) ..(547,-82.00163371837)..controls
>  (547,-78.68047283764) and (547,-75.35931195691)
>  ..(547,-72.03815107618)..controls (547,-70.98183460417) and
>  (547,-68.666792551813217) ..(547,-67.000186920166016);
> 
> pair a ; a := arrowHead intersection_point connection ;
> 
> draw connection cutafter arrowHead   withcolor red   withpen 
> pencircle scaled 2mm ;
> draw connection cutafter (reverse arrowHead) withcolor green withpen 
> pencircle scaled 1mm ;
> 
> draw arrowHead;
> 
> draw a withcolor blue withpen pencircle scaled 3mm ;
> 
> currentpicture := currentpicture shifted (-bbwidth(currentpicture), 0) ;
> 
> draw connection cutafter a ;
> 
> draw arrowHead;
> 
> 
> \stopMPpage

Hi Hans, thanks.

I am completely in the dark why your intersection_point works (and thus if it 
will keep working in all circumstances).

I’d like to understand what is going on here. Why does intersection_point work 
where cutafter does not? After all, both are based on the same 
intersectiontimes primitive to find the intersection and they should thus find 
the same one: the ’perfect’ intersection which is the end point of the path 
that is to be cut. 

I’d like to understand this, because otherwise I might run into the same 
problem again later with slightly different paths involved. The first algo that 
I was using worked fine in most cases, as well, then I created one that worked 
with paths with ‘internal spikes’ and now I run into this where two comparable 
situations behaved differently and my question copied the one that didn’t work. 
And while this example from you works, I need to have something that is 100% 
reliable.

What METAPOST comes with is:

path cuttings;  % what got cut off

tertiarydef a cutbefore b =  % tries to cut as little as possible
  begingroup save t;
  (t, whatever) = a intersectiontimes b;
  if t<0:
cuttings:=point 0 of a;
a
  else: cuttings:= subpath (0,t) of a;
subpath (t,length a) of a
  fi
  endgroup
enddef;

tertiarydef a cutafter b =
  reverse (reverse a  cutbefore  b)
  hide(cuttings:=reverse cuttings)
enddef;

secondarydef p intersectionpoint q =
 begingroup save x_,y_; (x_,y_)=p intersectiontimes q;
 if x_<0: errmessage("The paths don't intersect"); origin
 else: .5[point x_ of p, point y_ of q] fi endgroup
enddef;

What is in MetaFun is:

boolean intersection_found ;

secondarydef p intersection_point q =
begingroup
save x_, y_ ;
(x_,y_) = p intersectiontimes q ;
if x_< 0 :
intersection_found := false ;
center p % origin
else :
intersection_found := true ;
.5[point x_ of p, point y_ of q]
fi
endgroup
enddef ;

The thing I can think of is cutting a bit, trying if it still intersects and if 
it does repeat and if it doesn’t take the previous result. I can’t rely on the 
length of cuttings being 0, because this is true in the case of no intersection 
(cuttings equals (0,0)) as well as a ‘perfect’ intersection at the end of the 
path (cuttings is the point at the end of the path). I could rely on cuttings 
being the path (0,0) but how do I compare paths (and not pairs)?

G 

Pretty deep into MP now. Even looked up the reference in John Hobby’s manual to 
the METAFONT book, but that reference did not help.


_

Re: [NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-21 Thread Hans Hagen

On 4/21/2020 1:29 PM, Gerben Wierda wrote:
I have these two paths, but cutting doesn’t work because the path to be 
cut takes the wrong intersection regardless of how I direct the path to 
be cut after (reverse or not).


The path to cut after is a triangle with the base horizontal and the 
path to cut is a vertical line. The top of the triangle is the endpoint 
of the line and is selected as intersection by cutafter. This happens 
also if I reverse the triangle path, strangely enough. I have an 
alternative cutting algorithm, but that cuts as long as the length of 
cuttings is not 0, which is the case at the top too, so it won’t cut 
further.


I need a reliable algorithm to make a ‘maximum cutafter’. What might be 
a good approach?


G

path arrowHead;
arrowHead :=
   (542,-77.000186920166016)..controls 
(545.37,-77.000186920166016) and 
(548.63,-77.000186920166016)
   ..(552,-77.000186920166016)..controls 
(550.37,-73.666853586832687)

   and (548.63,-70.333520253499344)
   ..(547,-67.000186920166016)..controls 
(545.37,-70.333520253499344)

   and (543.63,-73.666853586832687)
   ..cycle;

path connection;
connection :=
   (420.4959106445,-367)..controls (420.66670256708773,-367) and 
(421.55543111,-367)
   ..(422.0851913427,-367)..controls (425.3917170194,-367) and 
(428.698242696,-367)
   ..(432.0047683727,-367)..controls (442.0015894574,-367) and 
(451.9984105426,-367)
   ..(461.9952316273,-367)..controls (464.76142345324098,-367) and 
(467,-364.76142382108867)
   ..(467,-361.9997656772)..controls (467,-293.218926) and 
(467,-226.781074)
   ..(467,-158.0002343228)..controls (467,-155.23857623850762) and 
(469.23857634039018,-153)
   ..(472.0014901161,-153)..controls (495.3338300389,-153) and 
(518.6661699617,-153)
   ..(541.9985098839,-153)..controls (544.76142368504975,-153) and 
(547,-150.76142367339932)
   ..(547,-147.9983662815)..controls (547,-125.9994554271) and 
(547,-104.0005445727)
   ..(547,-82.00163371837)..controls (547,-78.68047283764) and 
(547,-75.35931195691)
   ..(547,-72.03815107618)..controls (547,-70.98183460417) and 
(547,-68.666792551813217)

   ..(547,-67.000186920166016);

show connection cutafter arrowHead;
show connection cutafter (reverse arrowHead);


\startMPpage[instance=doublefun]

path arrowHead;
arrowHead :=
(542,-77.000186920166016)..controls 
(545.37,-77.000186920166016) and
(548.63,-77.000186920166016) 
..(552,-77.000186920166016)..controls

(550.37,-73.666853586832687) and
(548.63,-70.333520253499344) 
..(547,-67.000186920166016)..controls

(545.37,-70.333520253499344) and
(543.63,-73.666853586832687) ..cycle;

path connection;
connection :=
  (420.4959106445,-367)..controls (420.66670256708773,-367) and
  (421.55543111,-367) ..(422.0851913427,-367)..controls
  (425.3917170194,-367) and (428.698242696,-367)
  ..(432.0047683727,-367)..controls (442.0015894574,-367) and
  (451.9984105426,-367) ..(461.9952316273,-367)..controls
  (464.76142345324098,-367) and (467,-364.76142382108867)
  ..(467,-361.9997656772)..controls (467,-293.218926) and
  (467,-226.781074) ..(467,-158.0002343228)..controls
  (467,-155.23857623850762) and (469.23857634039018,-153)
  ..(472.0014901161,-153)..controls (495.3338300389,-153) and
  (518.6661699617,-153) ..(541.9985098839,-153)..controls
  (544.76142368504975,-153) and (547,-150.76142367339932)
  ..(547,-147.9983662815)..controls (547,-125.9994554271) and
  (547,-104.0005445727) ..(547,-82.00163371837)..controls
  (547,-78.68047283764) and (547,-75.35931195691)
  ..(547,-72.03815107618)..controls (547,-70.98183460417) and
  (547,-68.666792551813217) ..(547,-67.000186920166016);

pair a ; a := arrowHead intersection_point connection ;

draw connection cutafter arrowHead   withcolor red   withpen 
pencircle scaled 2mm ;
draw connection cutafter (reverse arrowHead) withcolor green withpen 
pencircle scaled 1mm ;


draw arrowHead;

draw a withcolor blue withpen pencircle scaled 3mm ;

currentpicture := currentpicture shifted (-bbwidth(currentpicture), 0) ;

draw connection cutafter a ;

draw arrowHead;


\stopMPpage

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 

[NTG-context] METAPOST: How do I get this 'max' cutafter to work?

2020-04-21 Thread Gerben Wierda
I have these two paths, but cutting doesn’t work because the path to be cut 
takes the wrong intersection regardless of how I direct the path to be cut 
after (reverse or not).

The path to cut after is a triangle with the base horizontal and the path to 
cut is a vertical line. The top of the triangle is the endpoint of the line and 
is selected as intersection by cutafter. This happens also if I reverse the 
triangle path, strangely enough. I have an alternative cutting algorithm, but 
that cuts as long as the length of cuttings is not 0, which is the case at the 
top too, so it won’t cut further.

I need a reliable algorithm to make a ‘maximum cutafter’. What might be a good 
approach?

G

path arrowHead;
arrowHead :=
  (542,-77.000186920166016)..controls (545.37,-77.000186920166016) 
and (548.63,-77.000186920166016)
  ..(552,-77.000186920166016)..controls (550.37,-73.666853586832687)
  and (548.63,-70.333520253499344)
  ..(547,-67.000186920166016)..controls (545.37,-70.333520253499344)
  and (543.63,-73.666853586832687)
  ..cycle;

path connection;
connection :=
  (420.4959106445,-367)..controls (420.66670256708773,-367) and 
(421.55543111,-367)
  ..(422.0851913427,-367)..controls (425.3917170194,-367) and 
(428.698242696,-367)
  ..(432.0047683727,-367)..controls (442.0015894574,-367) and 
(451.9984105426,-367)
  ..(461.9952316273,-367)..controls (464.76142345324098,-367) and 
(467,-364.76142382108867)
  ..(467,-361.9997656772)..controls (467,-293.218926) and 
(467,-226.781074)
  ..(467,-158.0002343228)..controls (467,-155.23857623850762) and 
(469.23857634039018,-153)
  ..(472.0014901161,-153)..controls (495.3338300389,-153) and 
(518.6661699617,-153)
  ..(541.9985098839,-153)..controls (544.76142368504975,-153) and 
(547,-150.76142367339932)
  ..(547,-147.9983662815)..controls (547,-125.9994554271) and 
(547,-104.0005445727)
  ..(547,-82.00163371837)..controls (547,-78.68047283764) and 
(547,-75.35931195691)
  ..(547,-72.03815107618)..controls (547,-70.98183460417) and 
(547,-68.666792551813217)
  ..(547,-67.000186920166016);

show connection cutafter arrowHead;
show connection cutafter (reverse arrowHead);


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST/MetaFun withtransparency doesn't accept my pair primary argument, what am I doing wrong?

2020-04-10 Thread Gerben Wierda
As I only use one transparency method anyway I could also fix this by passing a 
numeric instead of a pair and use the standard withtransparency (I don’t like 
overriding a standard MetaFun method, one never knows what might break in 
future updates).

vardef Foo( expr w, h, fillColor, fillTransparency) =
  show "FOO:", w, h, fillColor, fillTransparency;
  save pic; picture pic;
  save circ; path circ;
  circ := (fullcircle xyscaled (h,h));
  pic := image (
fill (circ shifted (w-h/2,-h/2)) withcolor fillColor withtransparency 
(1,fillTransparency);
  );
  pic
enddef;

picture pic;
pic := Foo( 150, 50, (0.686,1.000,1.000), 0.5);
draw pic;
\stopMPpage
\stoptext


> On 9 Apr 2020, at 18:06, Hans Hagen  wrote:
> 
> On 4/9/2020 4:58 PM, Gerben Wierda wrote:
>> \starttext
>> \startMPpage[instance=doublefun]
>> vardef Foo( expr w, h, fillColor, fillTransparency) =
>>   show "FOO:", w, h, fillColor, fillTransparency;
>>   save pic; picture pic;
>>   save circ; path circ;
>>   circ := (fullcircle xyscaled (h,h));
>>   pic := image (
>> fill (circ shifted (w-h/2,-h/2)) withcolor fillColor withtransparency 
>> fillTransparency;
>>   );
>>   pic
>> enddef;
>> pic := Foo( 150, 50, (0.686,1.000,1.000), (1,1.000));
>> draw pic;
>> \stopMPpage
>> \stoptext
> 
> Maybe this definition is better then but I need to test it more
> 
> \starttext
> \startMPpage[instance=doublefun]
> 
> def withtransparency expr t =
>if pair t :
>withprescript "tr_alternative="  & decimal 
> transparency_alternative_to_number(xpart t)
>withprescript "tr_transparency=" & decimal ypart t
>else :
>mfun_with_transparency (transparency_alternative_to_number(t))
>fi
> enddef ;
> 
> def mfun_with_transparency (expr a) expr t =
>withprescript "tr_alternative="  & decimal a
>withprescript "tr_transparency=" & decimal t
> enddef ;
> 
> vardef Foo ( expr w, h, fillColor, fillTransparency) =
>  image (
>fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
>withcolor fillColor
>withtransparency fillTransparency
>;
>  )
> enddef;
> 
> vardef FooX ( expr w, h, fillColor) =
>  image (
>fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
>withcolor fillColor
>withtransparency (normaltransparent, .5)
>;
>  )
> enddef;
> 
> vardef FooY ( expr w, h, fillColor) =
>  image (
>fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
>withcolor fillColor
>withtransparency normaltransparent .5
>;
>  )
> enddef;
> 
> draw Foo  ( 350, 50, (0.5,1,0), (1,.5));
> draw FooX ( 250, 50, (1,0.5,1));
> draw FooY ( 150, 50, (1,1,0.5));
> 
> \stopMPpage
> \stoptext
> 
> 
> -- 
> 
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST/MetaFun withtransparency doesn't accept my pair primary argument, what am I doing wrong?

2020-04-09 Thread Hans Hagen

On 4/9/2020 4:58 PM, Gerben Wierda wrote:

\starttext
\startMPpage[instance=doublefun]

vardef Foo( expr w, h, fillColor, fillTransparency) =
   show "FOO:", w, h, fillColor, fillTransparency;
   save pic; picture pic;
   save circ; path circ;
   circ := (fullcircle xyscaled (h,h));
   pic := image (
     fill (circ shifted (w-h/2,-h/2)) withcolor fillColor 
withtransparency fillTransparency;

   );
   pic
enddef;

pic := Foo( 150, 50, (0.686,1.000,1.000), (1,1.000));
draw pic;
\stopMPpage
\stoptext


Maybe this definition is better then but I need to test it more

\starttext
\startMPpage[instance=doublefun]

def withtransparency expr t =
if pair t :
withprescript "tr_alternative="  & decimal 
transparency_alternative_to_number(xpart t)

withprescript "tr_transparency=" & decimal ypart t
else :
mfun_with_transparency (transparency_alternative_to_number(t))
fi
enddef ;

def mfun_with_transparency (expr a) expr t =
withprescript "tr_alternative="  & decimal a
withprescript "tr_transparency=" & decimal t
enddef ;

vardef Foo ( expr w, h, fillColor, fillTransparency) =
  image (
fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
withcolor fillColor
withtransparency fillTransparency
;
  )
enddef;

vardef FooX ( expr w, h, fillColor) =
  image (
fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
withcolor fillColor
withtransparency (normaltransparent, .5)
;
  )
enddef;

vardef FooY ( expr w, h, fillColor) =
  image (
fill fullcircle xyscaled (h,h) shifted (w-h/2,-h/2)
withcolor fillColor
withtransparency normaltransparent .5
;
  )
enddef;

draw Foo  ( 350, 50, (0.5,1,0), (1,.5));
draw FooX ( 250, 50, (1,0.5,1));
draw FooY ( 150, 50, (1,1,0.5));

\stopMPpage
\stoptext


--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] METAPOST/MetaFun withtransparency doesn't accept my pair primary argument, what am I doing wrong?

2020-04-09 Thread Gerben Wierda
I have refactored my code to use withtransparency and separate parameters for 
colors, sizes, transparency, etc. But I’m running into a problem. The 
fillTransparency parameter is a pair primary (as can be seen from the show 
command)

Here is a pretty minimum example (in reality there are multiple colors and 
transparencies passed on):

\starttext
\startMPpage[instance=doublefun]

vardef Foo( expr w, h, fillColor, fillTransparency) =
  show "FOO:", w, h, fillColor, fillTransparency;
  save pic; picture pic;
  save circ; path circ;
  circ := (fullcircle xyscaled (h,h));
  pic := image (
fill (circ shifted (w-h/2,-h/2)) withcolor fillColor withtransparency 
fillTransparency;
  );
  pic
enddef;

pic := Foo( 150, 50, (0.686,1.000,1.000), (1,1.000));
draw pic;
\stopMPpage
\stoptext

and the result is:

metapost log> >> "FOO:"
metapost log> >> 150
metapost log> >> 50
metapost log> >> (0.68605,1,1)
metapost log> >> (1,1)
metapost log    > ! Missing argument to withtransparency.
metapost log>  
metapost log>    ((1,1))
metapost log>  ...005,1,1))withtransparency((1,1))
metapost log>   ;
metapost log> image->...ture;currentpicture:=nullpicture;(TEXT3)
metapost log    >       
;currentpicture.if.str(SUF...
metapost log> 
metapost log> Foo->...)withcolor(EXPR4)withtransparency(EXPR5);)
metapost log>   
;pic.endgroup
metapost log> <*> ...o( 150, 50, (0.686,1.000,1.000), (1,1.000))
metapost log>   ; draw pic; 
;

What am I doing wrong here?

Thanks,

G

PS. Given the complaint about asking both here and on tex.stackexchange, which 
of the two is the best place?___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bounding box of picture returned by textext() in METAPOST

2020-04-05 Thread Gerben Wierda
Nobody?

> On 4 Apr 2020, at 22:58, Gerben Wierda  wrote:
> 
> I have this METAPOST macro:
> 
> vardef makeTeXLabel( expr w, h, name) =
>   if debugProgram or debugLabels: show "NAME makeTeXLabel:", name, tostring 
> 0.8w, tostring 0.8h; fi
>   save p; picture p;
>   p := textext( "\startframedtext[middle]" &
> "[align=middle,frame=on" &
> ",width=" & tostring 0.8w & "bp" &
> ",height=" & tostring 0.8h & "bp]" &
> name & "\stopframedtext");
>   save b; path b; b := boundingbox p;
>   save dim; pair dim;
>   dim := (urcorner b) - (llcorner b);
>   save width, height; numeric width, height;
>   width := xpart dim;
>   height = ypart dim;
>   if debugLabels: show "PLACE:", w, h, width, height; fi
>   if (width > 0.8w) or (height > 0.8h):
> if (width > height):
>   if debugLabels: show "XSCALING:", (0.8w/width,0.8w/width); fi
>   p:= p xyscaled (0.8w/width,0.8w/width);
>     else:
>   if debugLabels: show "YSCALING:", (0.8h/height,0.8h/height); fi
>   p:= p xyscaled (0.8h/height,0.8h/height);
> fi
>   fi
>   p
> enddef;
> 
> It gets called with w=133 and h=53 (I am working in METAPOST native units, so 
> bp)
> 
> So, the textext() command gets something like 106bp x 42bp, which seems to be 
> the case:
> 
> metapost log> >> "NAME makeTeXLabel:"
> metapost log> >> "My 'Application' Function"
> metapost log> >> "106.41"
> cld > tex > w : - : \MPLIBsetNtextX{1}{\startframedtext 
> [middle][align=middle,frame=on,width=106.400001bp,height=42.4000006bp]My
>  'Application' Function\stopframedtext }
> cld > tex > F : - : \startblankhandling
> cld > tex > w : - : \setblankcategory{6}
> cld > tex > F : - : \flushblankhandling
> cld > tex > F : - : \stopblankhandling
> metapost log> >> "42.406"
> metapost log> >> "PLACE:"
> metapost log> >> 133
> metapost log> >> 53
> metapost log> >> 511.0865990822
> metapost log> >> 42.3051402
> 
> But the bounding box is 511bp wide (something like 7in or 18cm, probably 
> textwidth) but I’m asking for a box that is 106bp wide.
> 
> What happens here? And how do I get it right? 
> 
> G
> 
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Solved: Minimum example of problem getting curly braces printed in METAPOST

2020-04-05 Thread Hans Hagen

On 4/3/2020 5:36 PM, Gerben Wierda wrote:

Thanks to Taco, the solution was to simply use:

function doubleQuotableEscapedConTeXtString( str)
   local rep = {
       [1] =  { '{', '{\\textbraceleft}' },
       [2] =  { '}', '{\\textbraceright}' },
       [3] =  { '#', '{\\texthash}' },
       [4] =  { '$', '{\\textdollar}' },
       [5] =  { '&', '{\\textampersand}' },
       [6] =  { '%', '{\\textpercent}' },
       [7] =  { '\\','{\\textbackslash}' },
       [8] =  { '|', '{\\textbar}' },
       [9] =  { '_', '{\\textunderscore}' },
       [10] = { '~', '{\\textasciitilde}' },
       [11] = { '^', '{\\textasciicircum}' },
       [12] = { '"', "\"&\"" },
   }
   return lpeg.replacer(rep):match(str)
end

And the string becomes something that can safely be given toi METAPOST 
and safely handled by TeX when called from METAPOST via textext()

more efficient

local rep = lpeg.replacer {
  { '{', '{\\textbraceleft}' },
  { '}', '{\\textbraceright}' },
  { '#', '{\\texthash}' },
  { '$', '{\\textdollar}' },
  { '&', '{\\textampersand}' },
  { '%', '{\\textpercent}' },
  { '\\','{\\textbackslash}' },
  { '|', '{\\textbar}' },
  { '_', '{\\textunderscore}' },
  { '~', '{\\textasciitilde}' },
  { '^', '{\\textasciicircum}' },
  { '"', "\"&\"" },
}

function doubleQuotableEscapedConTeXtString( str)
return rep:match(str)
end

this is probably also ok:

local rep = {
["\""] = "\\char34 ",
["#"]  = "\\char35 ",
["$"]  = "\\char36 ",
["%"]  = "\\char37 ",
["&"]  = "\\char38 ",
["\\"] = "\\char92 ",
["^"]  = "\\char94 ",
["_"]  = "\\char95 ",
["{"]  = "\\char123 ",
["|"]  = "\\char124 ",
["}"]  = "\\char125 ",
["~"]  = "\\char126 ",
}

function doubleQuotableEscapedConTeXtString(str)
return (string.gsub(str,".",rep))
end


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Bounding box of picture returned by textext() in METAPOST

2020-04-04 Thread Gerben Wierda
I have this METAPOST macro:

vardef makeTeXLabel( expr w, h, name) =
  if debugProgram or debugLabels: show "NAME makeTeXLabel:", name, tostring 
0.8w, tostring 0.8h; fi
  save p; picture p;
  p := textext( "\startframedtext[middle]" &
"[align=middle,frame=on" &
",width=" & tostring 0.8w & "bp" &
",height=" & tostring 0.8h & "bp]" &
name & "\stopframedtext");
  save b; path b; b := boundingbox p;
  save dim; pair dim;
  dim := (urcorner b) - (llcorner b);
  save width, height; numeric width, height;
  width := xpart dim;
  height = ypart dim;
  if debugLabels: show "PLACE:", w, h, width, height; fi
  if (width > 0.8w) or (height > 0.8h):
if (width > height):
  if debugLabels: show "XSCALING:", (0.8w/width,0.8w/width); fi
  p:= p xyscaled (0.8w/width,0.8w/width);
else:
  if debugLabels: show "YSCALING:", (0.8h/height,0.8h/height); fi
  p:= p xyscaled (0.8h/height,0.8h/height);
fi
  fi
  p
enddef;

It gets called with w=133 and h=53 (I am working in METAPOST native units, so 
bp)

So, the textext() command gets something like 106bp x 42bp, which seems to be 
the case:

metapost log> >> "NAME makeTeXLabel:"
metapost log> >> "My 'Application' Function"
metapost log> >> "106.41"
cld > tex > w : - : \MPLIBsetNtextX{1}{\startframedtext 
[middle][align=middle,frame=on,width=106.41bp,height=42.406bp]My
 'Application' Function\stopframedtext }
cld > tex > F : - : \startblankhandling
cld > tex > w : - : \setblankcategory{6}
cld > tex > F : - : \flushblankhandling
cld > tex > F : - : \stopblankhandling
metapost log> >> "42.406"
metapost log> >> "PLACE:"
metapost log> >> 133
metapost log> >> 53
metapost log> >> 511.0865990822
metapost log> >> 42.3051402

But the bounding box is 511bp wide (something like 7in or 18cm, probably 
textwidth) but I’m asking for a box that is 106bp wide.

What happens here? And how do I get it right? 

G


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Solved: Minimum example of problem getting curly braces printed in METAPOST

2020-04-03 Thread Gerben Wierda
Thanks to Taco, the solution was to simply use:

function doubleQuotableEscapedConTeXtString( str)
  local rep = {
  [1] =  { '{', '{\\textbraceleft}' },
  [2] =  { '}', '{\\textbraceright}' },
  [3] =  { '#', '{\\texthash}' },
  [4] =  { '$', '{\\textdollar}' },
  [5] =  { '&', '{\\textampersand}' },
  [6] =  { '%', '{\\textpercent}' },
  [7] =  { '\\','{\\textbackslash}' },
  [8] =  { '|', '{\\textbar}' },
  [9] =  { '_', '{\\textunderscore}' },
  [10] = { '~', '{\\textasciitilde}' },
  [11] = { '^', '{\\textasciicircum}' },
  [12] = { '"', "\"&\"" },
  }
  return lpeg.replacer(rep):match(str)
end

And the string becomes something that can safely be given toi METAPOST and 
safely handled by TeX when called from METAPOST via textext()

G


> On 2 Apr 2020, at 14:05, Gerben Wierda  wrote:
> 
> Here is a minimum example of a problem that I have in getting curly braces 
> printed in METAPOST in code that is generated by lua.
> 
> Any help is welcome.
> 
> \usemodule[scite]
> \setupxml
>  [entities=yes]
> 
> 
> \startluacode
> 
> function warn( ... )
>   texio.write_nl("-> " .. string.format(...))
> end
> 
> local function mpLabelString( xmlLabelString)
>   -- Returns a string where each " is replaced by a METAPOST compatible 
> result, except for outer double quotes"
>   rep = {
>   [1] = { "\"", "\"&\""   },
>   -- DOESN'T WORK: [2] = { "\\", "" },
>   }
>   local tmpString = string.formatters( "%!tex!", xmlLabelString)
>   warn( "STRING.FORMAT XML \"%s\"", xmlLabelString)
>   warn( "STRING.FORMAT TeX-ed \"%s\"", tmpString)
>   warn( "STRING.FORMAT Replaced \"%s\"", lpeg.replacer(rep):match(tmpString))
>   return lpeg.replacer(rep):match(tmpString)
> end
> 
> function warnAndConTeXt( ...)
>   warn( ...)
>   context( ...)
> end
> 
> function moduledata.test( filename)
>   local labelString
>   context( "The string to typeset is:\\par\\type-{Label} \"a\" [Text]!-")
>   context( "\\par The attempts are:")
>   context( "\\par1. \\type-Label Text-")
>   context( "\\par2. \\type-Label [Text]!-")
>   context( "\\par3. \\type-Label \"a\" [Text]!-")
>   context( "\\par4. \\type-{Label} [Text]!-")
>   context( "\\par5. \\type-{Label} \"a\" [Text]!-")
>   context.startMPpage { instance = "doublefun" }
>   context( "picture pic;")
>   labelString = "1. Label Text OK"
>   warnAndConTeXt( "pic := Foo( 0, 0, 150, 50, \"%s\");", mpLabelString( 
> labelString))
>   labelString = "2. Label [Text]! OK"
>   warnAndConTeXt( "pic := Foo( 0, -75, 150, 50, \"%s\");", mpLabelString( 
> labelString))
>   labelString = "3. Label \"a\" [Text]! OK"
>   warnAndConTeXt( "pic := Foo( 0, -150, 150, 50, \"%s\");", mpLabelString( 
> labelString))
>   labelString = "4. {Label} [Text]! MISSING curly braces"
>   warnAndConTeXt( "pic := Foo( 0, -225, 150, 50, \"%s\");", mpLabelString( 
> labelString))
>   labelString = "5. {Label} \"a\" [Text]! MISSING curly braces"
>   warnAndConTeXt( "pic := Foo( 0, -300, 150, 50, \"%s\");", mpLabelString( 
> labelString))
>   context( "drawdot (0,0) withpen pencircle scaled 4 withcolor red;")
>   context.stopMPpage()
> end
> \stopluacode
> 
> \usemodule[article-basic]
> %\enabletrackers[metapost.tracingall,metapost.lua,metapost.runs,metapost.textexts,metapost.scrintersectionPoints,metapost.runs,metapost.graphics,metapost.terminal]
> 
> \starttext
> 
> \definefontfamily[mainface][rm][Optima]
> \setupbodyfont[mainface,10pt]
> 
> \startMPinclusions[+]{doublefun}
> 
> \stopMPinclusions
> 
> \startMPdefinitions{doublefun}
> vardef makeTeXLabel( expr w, h, name) =
>   show "NAME makeTeXLabel:", name;
>   save p; picture p ;
>   save s; string s;
>   s := "\framed{" & name & "}"; % Curly braces will be missing. I need this 
> to work.
>   % s := "\type-" & name & "-"; % Curly braces are displayed, but this must 
> become a vbox in the end, so can't use it
>   show "SCAN:", s;
>   p := textext( s);
>   p
> enddef;
> 
> vardef Foo( expr xpos, ypos, width, height, str) =
>   show "NAME Foo:", str; % Backslashes are already gone here
>   save pic; picture pic;
>   pic := makeTeXLabel( width, height, str) s

[NTG-context] Minimum example of problem getting curly braces printed in METAPOST

2020-04-02 Thread Gerben Wierda
Here is a minimum example of a problem that I have in getting curly braces printed in METAPOST in code that is generated by lua.Any help is welcome.\usemodule[scite]\setupxml [entities=yes]\startluacodefunction warn( ... )  texio.write_nl("-> " .. string.format(...))endlocal function mpLabelString( xmlLabelString)  -- Returns a string where each " is replaced by a METAPOST compatible result, except for outer double quotes"  rep = {      [1] = { "\"", "\"&\""   },      -- DOESN'T WORK: [2] = { "\\", "" },  }  local tmpString = string.formatters( "%!tex!", xmlLabelString)  warn( "STRING.FORMAT XML \"%s\"", xmlLabelString)  warn( "STRING.FORMAT TeX-ed \"%s\"", tmpString)  warn( "STRING.FORMAT Replaced \"%s\"", lpeg.replacer(rep):match(tmpString))  return lpeg.replacer(rep):match(tmpString)endfunction warnAndConTeXt( ...)  warn( ...)  context( ...)endfunction moduledata.test( filename)  local labelString  context( "The string to typeset is:\\par\\type-{Label} \"a\" [Text]!-")  context( "\\par The attempts are:")  context( "\\par1. \\type-Label Text-")  context( "\\par2. \\type-Label [Text]!-")  context( "\\par3. \\type-Label \"a\" [Text]!-")  context( "\\par4. \\type-{Label} [Text]!-")  context( "\\par5. \\type-{Label} \"a\" [Text]!-")  context.startMPpage { instance = "doublefun" }  context( "picture pic;")  labelString = "1. Label Text OK"  warnAndConTeXt( "pic := Foo( 0, 0, 150, 50, \"%s\");", mpLabelString( labelString))  labelString = "2. Label [Text]! OK"  warnAndConTeXt( "pic := Foo( 0, -75, 150, 50, \"%s\");", mpLabelString( labelString))  labelString = "3. Label \"a\" [Text]! OK"  warnAndConTeXt( "pic := Foo( 0, -150, 150, 50, \"%s\");", mpLabelString( labelString))  labelString = "4. {Label} [Text]! MISSING curly braces"  warnAndConTeXt( "pic := Foo( 0, -225, 150, 50, \"%s\");", mpLabelString( labelString))  labelString = "5. {Label} \"a\" [Text]! MISSING curly braces"  warnAndConTeXt( "pic := Foo( 0, -300, 150, 50, \"%s\");", mpLabelString( labelString))  context( "drawdot (0,0) withpen pencircle scaled 4 withcolor red;")  context.stopMPpage()end\stopluacode\usemodule[article-basic]%\enabletrackers[metapost.tracingall,metapost.lua,metapost.runs,metapost.textexts,metapost.scrintersectionPoints,metapost.runs,metapost.graphics,metapost.terminal]\starttext\definefontfamily[mainface][rm][Optima]\setupbodyfont[mainface,10pt]\startMPinclusions[+]{doublefun}\stopMPinclusions\startMPdefinitions{doublefun}vardef makeTeXLabel( expr w, h, name) =  show "NAME makeTeXLabel:", name;  save p; picture p ;  save s; string s;  s := "\framed{" & name & "}"; % Curly braces will be missing. I need this to work.  % s := "\type-" & name & "-"; % Curly braces are displayed, but this must become a vbox in the end, so can't use it  show "SCAN:", s;  p := textext( s);  penddef;vardef Foo( expr xpos, ypos, width, height, str) =  show "NAME Foo:", str; % Backslashes are already gone here  save pic; picture pic;  pic := makeTeXLabel( width, height, str) shifted (xpos, ypos);  draw pic;  picenddef;\stopMPdefinitions\ctxlua{moduledata.test("My ArchiMate Model Export BES.xml")}\typefile[option=TEX]{test11.tex}\stoptextThe question is: how can I get this to work? The strings that have to be printed inside the METAPOST picture come from an XML and can contain about anything. But in the end that string will have to be vertically typeset as a paragraph, hence I cannot use \type (which works).

test11.tex
Description: Binary data
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-02 Thread Gerben Wierda
Actually, the backslashes disappear before the call to textext()

G

> On 1 Apr 2020, at 23:44, Aditya Mahajan  wrote:
> 
> On Wed, 1 Apr 2020, Gerben Wierda wrote:
>> 
>> My route is probably to complex anyway, but what can I do for the curly 
>> braces to be actually typeset?
> 
> MkII had a feature called \sometxt
> http://dl.contextgarden.net/myway/sometxt.pdf
> 
> I wonder if that still works in MkIV.
> 
> Aditya
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Aditya Mahajan

On Wed, 1 Apr 2020, Gerben Wierda wrote:


My route is probably to complex anyway, but what can I do for the curly braces 
to be actually typeset?


MkII had a feature called \sometxt
http://dl.contextgarden.net/myway/sometxt.pdf

I wonder if that still works in MkIV.

Aditya
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Gerben Wierda
I have lua code that generates this for METAPOST:

ApplicationComponentLogo( w, h, "withcolor (0.686,1.000,1.000) withtransparency 
(1,0.200)", "withcolor (0.000,0.000,0.000) withtransparency (1,1.000) withpen 
pencircle scaled 1.000", "\{Hello\}, "&"(a)"&" [World]!") shifted 
(x, -y); draw pic;

The string to be typeset, eventually is this: 

{Hello}, "(a)" [World]!

So, with double quotes in the string. The function creating the actual string 
to pass to METAPOST (above) is this:

local function mpLabelString( xmlLabelString)
  -- Returns a string where each " is replaced by a METAPOST compatible result, 
except for outer double quotes"
  rep = {
  [1] = { "\"", "\"&\""   },
  }
  local tmpString = string.formatters( "%!tex!", xmlLabelString)
  return lpeg.replacer(rep):match(tmpString)
end

That works. Then, in METAPOST the vardef ‘ApplicationComponentLogo’  calls a 
vardef makeTeXLabel 

draw makeTeXLabel( w, h, name) shifted (w/2,0);

which, for now, simplified does this:

vardef makeTeXLabel( expr w, h, name) =
  save p; picture p ;
  save s; string s;
  s := "\framed{" & name & "}”;
  % s := "\type-" & name & "-";
  p := textext( s);
  p
enddef;

But, this is what is in string s before it is sent to textext():

\framed {{Hello}, "(a)" [World]!}

In other words, the escapes on the curly braces are lost and now the curly 
braces are ignored by TeX. 

I tried adding a doubling of the backslahes to the replacement:

  rep = {
  [1] = { "\"", "\"&\""   },
  [2] = { "\\", "" },
  }

But then the string that is typeset (and given to textext()) becomes 

\framed {\\{Hello\\}, "(a)" [World]!}

And the result in the output is the same. No curly braces.

My route is probably to complex anyway, but what can I do for the curly braces 
to be actually typeset?

G___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Gerben Wierda
We should move this to the thread

What alternative for scantokens( "btex " & texcommands & " etex”)?

I’ve put my vardef there. The calls to this vardef are created by lua code.

I need to fix two things: use a string variable to build a btex-etex construct 
and be able to use (almost) any character in that variable. 

I can adapt the strings, if I know what I have to replace things with. I can 
manipulate the strings while still in lua. But if I change it and then via MP 
hand it to a \type{} statement in ConTeXt the replacement will be typeset 
literally. So, it will be pretty complex. If I drop the use of \type{} inside 
the btex-etex I have to ‘escape' everything that TeX doesn’t see as normal text 
catcode. That, again might play havoc with breaking words across lines later.

G

> On 29 Mar 2020, at 15:09, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 29.03.2020 um 15:06:
>>> On 29 Mar 2020, at 14:35, Wolfgang Schuster 
>>> >> <mailto:wolfgang.schuster.li...@gmail.com>> wrote:
>>> 
>>> Gerben Wierda schrieb am 29.03.2020 um 14:30:
>>>>> On 29 Mar 2020, at 12:58, Wolfgang Schuster 
>>>>> >>>> <mailto:wolfgang.schuster.li...@gmail.com>> wrote:
>>>>> 
>>>>> Gerben Wierda schrieb am 29.03.2020 um 12:52:
>>>>>> I am using MetaFun (Lua code) to create METAPOST commands from an XML 
>>>>>> file. One of the issues I am running into that in METAPOST I have to 
>>>>>> handle strings with " characters in them and METAPOST doesn’t like 
>>>>>> those. The argument using the string
>>>>>> Foo "Bar” Foo
>>>>> 
>>>>> ^^^
>>>>> 
>>>>> Use correct left quotation marks or \quotation{…}.
>>>> I’m not hard coding the string, I’m reading it from an XML. So, whatever I 
>>>> do, I need to do it by manipulating the string.
>>>> E.g. if the string I read contains
>>>> Foo "Bar” Foo
>>>> your suggestion means  I have to programmatically change that to
>>>> Foo \quotation{Bar} Foo
>>>> which is too complicated, given that I don’t have regular expression 
>>>> replace at my disposal.
>>>> I might be able to change al “ instances into something else by walking 
>>>> through the string and building a new one.
>>> 
>>> Your example uses " before Bar and not “ which is the problem.
>> Yes, I am aware that that is my problem. It is just that I do not have the 
>> luxury to decide myself what will be put in the string. It must work for any 
>> string. So, I will have to be putting that string to \type and make sure 
>> that is used as the label.
> 
> Does btex .. etex help or can't you change the strings and replace the 
> quotation marks before you pass them to MetaPost?
> 
> \starttext
> 
> \startMPcode
> draw textext.urt("One");
> draw btex "Two" etex shifted (0,15);
> label.urt("Three",(0,30));
> label.urt(btex "Four" etex,(0,45));
> \stopMPcode
> 
> \stoptext
> 
> Wolfgang

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Wolfgang Schuster

Gerben Wierda schrieb am 29.03.2020 um 15:06:



On 29 Mar 2020, at 14:35, Wolfgang Schuster 
<mailto:wolfgang.schuster.li...@gmail.com>> wrote:


Gerben Wierda schrieb am 29.03.2020 um 14:30:
On 29 Mar 2020, at 12:58, Wolfgang Schuster 
<mailto:wolfgang.schuster.li...@gmail.com>> wrote:


Gerben Wierda schrieb am 29.03.2020 um 12:52:
I am using MetaFun (Lua code) to create METAPOST commands from an 
XML file. One of the issues I am running into that in METAPOST I 
have to handle strings with " characters in them and METAPOST 
doesn’t like those. The argument using the string

Foo "Bar” Foo


^^^

Use correct left quotation marks or \quotation{…}.
I’m not hard coding the string, I’m reading it from an XML. So, 
whatever I do, I need to do it by manipulating the string.

E.g. if the string I read contains
Foo "Bar” Foo
your suggestion means  I have to programmatically change that to
Foo \quotation{Bar} Foo
which is too complicated, given that I don’t have regular expression 
replace at my disposal.
I might be able to change al “ instances into something else by 
walking through the string and building a new one.


Your example uses " before Bar and not “ which is the problem.


Yes, I am aware that that is my problem. It is just that I do not have 
the luxury to decide myself what will be put in the string. It must work 
for any string. So, I will have to be putting that string to \type and 
make sure that is used as the label.


Does btex .. etex help or can't you change the strings and replace the 
quotation marks before you pass them to MetaPost?


\starttext

\startMPcode
draw textext.urt("One");
draw btex "Two" etex shifted (0,15);
label.urt("Three",(0,30));
label.urt(btex "Four" etex,(0,45));
\stopMPcode

\stoptext

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Gerben Wierda


> On 29 Mar 2020, at 14:35, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 29.03.2020 um 14:30:
>>> On 29 Mar 2020, at 12:58, Wolfgang Schuster 
>>>  wrote:
>>> 
>>> Gerben Wierda schrieb am 29.03.2020 um 12:52:
>>>> I am using MetaFun (Lua code) to create METAPOST commands from an XML 
>>>> file. One of the issues I am running into that in METAPOST I have to 
>>>> handle strings with " characters in them and METAPOST doesn’t like those. 
>>>> The argument using the string
>>>> Foo "Bar” Foo
>>> 
>>> ^^^
>>> 
>>> Use correct left quotation marks or \quotation{…}.
>> I’m not hard coding the string, I’m reading it from an XML. So, whatever I 
>> do, I need to do it by manipulating the string.
>> E.g. if the string I read contains
>> Foo "Bar” Foo
>> your suggestion means  I have to programmatically change that to
>> Foo \quotation{Bar} Foo
>> which is too complicated, given that I don’t have regular expression replace 
>> at my disposal.
>> I might be able to change al “ instances into something else by walking 
>> through the string and building a new one.
> 
> Your example uses " before Bar and not “ which is the problem.

Yes, I am aware that that is my problem. It is just that I do not have the 
luxury to decide myself what will be put in the string. It must work for any 
string. So, I will have to be putting that string to \type and make sure that 
is used as the label.

G

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Gerben Wierda


> On 29 Mar 2020, at 12:58, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 29.03.2020 um 12:52:
>> I am using MetaFun (Lua code) to create METAPOST commands from an XML file. 
>> One of the issues I am running into that in METAPOST I have to handle 
>> strings with " characters in them and METAPOST doesn’t like those. The 
>> argument using the string
>> Foo "Bar” Foo
> 
> ^^^
> 
> Use correct left quotation marks or \quotation{…}.

I’m not hard coding the string, I’m reading it from an XML. So, whatever I do, 
I need to do it by manipulating the string.

E.g. if the string I read contains

Foo "Bar” Foo

your suggestion means  I have to programmatically change that to

Foo \quotation{Bar} Foo

which is too complicated, given that I don’t have regular expression replace at 
my disposal.

I might be able to change al “ instances into something else by walking through 
the string and building a new one.

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Wolfgang Schuster

Gerben Wierda schrieb am 29.03.2020 um 14:30:




On 29 Mar 2020, at 12:58, Wolfgang Schuster  
wrote:

Gerben Wierda schrieb am 29.03.2020 um 12:52:

I am using MetaFun (Lua code) to create METAPOST commands from an XML file. One of 
the issues I am running into that in METAPOST I have to handle strings with " 
characters in them and METAPOST doesn’t like those. The argument using the string
Foo "Bar” Foo


 ^^^

Use correct left quotation marks or \quotation{…}.


I’m not hard coding the string, I’m reading it from an XML. So, whatever I do, 
I need to do it by manipulating the string.

E.g. if the string I read contains

Foo "Bar” Foo

your suggestion means  I have to programmatically change that to

Foo \quotation{Bar} Foo

which is too complicated, given that I don’t have regular expression replace at 
my disposal.

I might be able to change al “ instances into something else by walking through 
the string and building a new one.


Your example uses " before Bar and not “ which is the problem.

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-29 Thread Wolfgang Schuster

Gerben Wierda schrieb am 29.03.2020 um 10:47:




On 28 Mar 2020, at 19:04, Wolfgang Schuster  
wrote:

Gerben Wierda schrieb am 28.03.2020 um 18:58:

Actually, I would already be helped with a way to convert this string:
My “Büsiness"  sérvice
into something that can be typeset by ConTeXt. Using embedded lua is fine.


Does enabling entities help?

\setupxml
  [entities=yes]


This is not in the manual. Is it documented somewhere?


I added it to the syntax of the \setupxml command.

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Gerben Wierda
I am using MetaFun (Lua code) to create METAPOST commands from an XML file. One 
of the issues I am running into that in METAPOST I have to handle strings with 
" characters in them and METAPOST doesn’t like those. The argument using the 
string

Foo "Bar” Foo

turns into

someCall( "Foo “Bar” Foo”)

I guess I have to change the string into something with explicit character 
codes for the " characters, maybe?

In a later stage, these strings will be typeset by the ConTeXt side of things 
so they fit into a certain area within the METAPOST picture.

What is my best approach?

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-29 Thread Gerben Wierda
I tried this and it worked. 

Next issue: if the string has a “ character in it, METAPOST cannot handle it. 
New question for the list...

G

> On 29 Mar 2020, at 10:47, Gerben Wierda  wrote:
> 
> 
> 
>> On 28 Mar 2020, at 19:04, Wolfgang Schuster 
>>  wrote:
>> 
>> Gerben Wierda schrieb am 28.03.2020 um 18:58:
>>> Actually, I would already be helped with a way to convert this string:
>>> My “Büsiness"  sérvice
>>> into something that can be typeset by ConTeXt. Using embedded lua is fine.
>> 
>> Does enabling entities help?
>> 
>> \setupxml
>> [entities=yes]
> 
> This is not in the manual. Is it documented somewhere?
> 
> G
> 
>> 
>> Wolfgang
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How do I handle strings with " characters in it in METAPOST?

2020-03-29 Thread Wolfgang Schuster

Gerben Wierda schrieb am 29.03.2020 um 12:52:

I am using MetaFun (Lua code) to create METAPOST commands from an XML file. One of 
the issues I am running into that in METAPOST I have to handle strings with " 
characters in them and METAPOST doesn’t like those. The argument using the string

Foo "Bar” Foo


 ^^^

Use correct left quotation marks or \quotation{...}.

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-29 Thread Gerben Wierda


> On 28 Mar 2020, at 19:04, Wolfgang Schuster 
>  wrote:
> 
> Gerben Wierda schrieb am 28.03.2020 um 18:58:
>> Actually, I would already be helped with a way to convert this string:
>>  My “Büsiness"  sérvice
>> into something that can be typeset by ConTeXt. Using embedded lua is fine.
> 
> Does enabling entities help?
> 
> \setupxml
>  [entities=yes]

This is not in the manual. Is it documented somewhere?

G

> 
> Wolfgang

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-28 Thread Wolfgang Schuster

Gerben Wierda schrieb am 28.03.2020 um 18:58:

Actually, I would already be helped with a way to convert this string:

My “Büsiness"  sérvice

into something that can be typeset by ConTeXt. Using embedded lua is fine.


Does enabling entities help?

\setupxml
  [entities=yes]

Wolfgang
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-28 Thread Gerben Wierda
Actually, I would already be helped with a way to convert this string:

My “Büsiness"  sérvice

into something that can be typeset by ConTeXt. Using embedded lua is fine.

G

> On 28 Mar 2020, at 02:01, Gerben Wierda  wrote:
> 
> I have strings I get from an XML that I want to turn into labels for objects 
> in a METAPOST picture (using MetaFun). These strings can have arbitrary 
> characters (like accents) and some characters are coded. Examples of how 
> these are coded:
> 
>   My "Application” Fünction
> 
>   [My] Application (Component)
> 
>   Business  service
> 
> Besides the text, I know what the intended size (e.g. 10) and style (e.g. 
> bold or italics) is.
> 
> I have the string and I have a size of a box it needs to be fitted in and I 
> have set a default font. Preferably, I’d like to code these in a box of the 
> aspect ratio of the box it needs to fit in. So, for instance, I have a box 
> that is 50 (high) by 130 (wide) and
> - if the text fits in the box, just typeset it. Break the words (yes or no)
> - if the size set does not fit in the box, make it smaller so it fits. 
> Initially this is optional as the boxes will be of the size in which the text 
> fits.
> - I might want to use some pattern to split it into multiple lines. E.g. if 
> the last part of the string is “(some text)” put it on a last line by itself 
> and if the first part of the string is “[some text]” put it on a first line 
> by itself
> 
> I am using Lua to generate METAPOST which are written by ‘context’ commands.
> 
> I am not that experienced and I am looking for tips on a strategy to do this.
> 
> Thanks in advance,
> 
> G
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] I could use some ideas for a strategy to get these kind of labels in a METAPOST picture

2020-03-27 Thread Gerben Wierda
I have strings I get from an XML that I want to turn into labels for objects in 
a METAPOST picture (using MetaFun). These strings can have arbitrary characters 
(like accents) and some characters are coded. Examples of how these are coded:

My "Application” Fünction

[My] Application (Component)

Business  service

Besides the text, I know what the intended size (e.g. 10) and style (e.g. bold 
or italics) is.

I have the string and I have a size of a box it needs to be fitted in and I 
have set a default font. Preferably, I’d like to code these in a box of the 
aspect ratio of the box it needs to fit in. So, for instance, I have a box that 
is 50 (high) by 130 (wide) and
- if the text fits in the box, just typeset it. Break the words (yes or no)
- if the size set does not fit in the box, make it smaller so it fits. 
Initially this is optional as the boxes will be of the size in which the text 
fits.
- I might want to use some pattern to split it into multiple lines. E.g. if the 
last part of the string is “(some text)” put it on a last line by itself and if 
the first part of the string is “[some text]” put it on a first line by itself

I am using Lua to generate METAPOST which are written by ‘context’ commands.

I am not that experienced and I am looking for tips on a strategy to do this.

Thanks in advance,

G
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?

2020-03-16 Thread Aditya Mahajan

On Mon, 16 Mar 2020, Gerben Wierda wrote:


This worked when I was just doing METAPOST. Now, I am using my lua code to 
produce the METAPOST code that produces the pictures. And the picture itself is 
put in a file for METAPOST as follows:

File test4-mplib-run-001.mp:

% begin graphic: n=0

; beginfig(1) ; defaultfont:="name:dejavuserif*default"; 
CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black 
enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( 
w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; 
h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; 
y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path 
p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := 
(393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ;
% end graphic

This apparently is tried to get run through METAPOST separately and that 
clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is 
the result of the following setup:

\starttext
\startMPdefinitions (or inclusions, no difference)
% ApplicationComponentLogo is defined here with a vardef
\stopMPdefinitions
\ctxlua{foo(“filename”)}% produces a series of
%context.startMPpage { instance = 
"doublefun” }
%several of:
%   context( METAPOST statements in a 
string)
%context.stopMPpage()
\stoptext

How do I get my MPdefinitions available in those METAPOST runs?


Since you are using \startMPpage[instace=doublefun], you need to do the 
definitions for doublefun instance: so use


\startMPdefinitions{doublefun}
...
\stopMPdefinitions

Aditya___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?

2020-03-16 Thread Gerben Wierda
This worked when I was just doing METAPOST. Now, I am using my lua code to 
produce the METAPOST code that produces the pictures. And the picture itself is 
put in a file for METAPOST as follows:

File test4-mplib-run-001.mp:

% begin graphic: n=0

; beginfig(1) ; defaultfont:="name:dejavuserif*default"; 
CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor 
=black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic 
:= ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw 
pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( 
w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; 
y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, 
-y); draw pic;path p; p := 
(200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := 
(393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ;
% end graphic

This apparently is tried to get run through METAPOST separately and that 
clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is 
the result of the following setup:

\starttext
\startMPdefinitions (or inclusions, no difference)
% ApplicationComponentLogo is defined here with a vardef
\stopMPdefinitions
\ctxlua{foo(“filename”)}% produces a series of
%context.startMPpage { instance = 
"doublefun” }
%several of:
%   context( METAPOST statements in a 
string)
%context.stopMPpage()
\stoptext

How do I get my MPdefinitions available in those METAPOST runs?

G

> On 13 Mar 2020, at 14:59, Hans Hagen  wrote:
> 
> On 3/13/2020 2:33 PM, Aditya Mahajan wrote:
>> On Fri, 13 Mar 2020, Taco Hoekwater wrote:
>>> Hi,
>>> 
>>> 
>>> 
>>>> On 13 Mar 2020, at 12:53, Gerben Wierda  wrote:
>>>> 
>>>> Suppose I have this code:
>>>> 
>>>> 
>>>> Can I reuse that varied across follow-up MPPages?
>>> 
>>> Sure, put the vardef inside \startMPinclusions:
>> or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the 
>> difference between inclusions and definitions, now).
> definitions: once
> inclusions : every time
> 
> -
>  Hans Hagen | PRAGMA ADE
>  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST vardef returning multiple and non-numeric types as a single answer?

2020-03-16 Thread Gerben Wierda
Maybe a nice little explanation (educational with good examples) of ‘how to use 
pass by reference’ and ‘building and using complex data structures’ would be 
useful for people. Say, some ‘patterns’.

G  

> On 16 Mar 2020, at 10:38, Hans Hagen  wrote:
> 
> that said, after muy share of mp programming i would not have thought about 
> the text y as pass by reference, also because it's only true for these pseudo 
> arrays (maybe suffixes also work)

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] METAPOST vardef returning multiple and non-numeric types as a single answer?

2020-03-16 Thread Gerben Wierda


> On 16 Mar 2020, at 10:23, Taco Hoekwater  wrote:
> 
> 
> 
>> On 16 Mar 2020, at 10:10, Taco Hoekwater  wrote:
>> 
>> 
>> 
>>> On 16 Mar 2020, at 09:53, Gerben Wierda  wrote:
>>> 
>>> Hola! So, the arguments passed to macros are by reference and not by value? 
>>> I could have known of course, they are simple expansions, but I’d like to 
>>> be sure. IfI assign to a variable inside a vardef macro and that variable 
>>> is not ’save’d I’m changing the original?
>> 
>> Yes. (A simple test would have confirmed that)
> 
> Oops, sorry, no! I was wrong on that… it must be too early for me.

Coffee! Thanks anyway, Taco, your help is really appreciated.

> 
>  vardef Foo(text y) = 
>scantokens(y&":=5”);
>  enddef;
>  Foo("x");
> 
> This would work, but that is weird.

Which is somewhat intuitive to parse as a human. I understand it as that after 
the last statement x has the value 5.

> This also works, and that is why
> I had the erroneous memory that it would work always:
> 
>  vardef Foo(expr a)(text y) = 
>y[a] := 5;
>  enddef;
>  numeric foo[]; 
>  foo[1] = 6;
>  Foo(1,foo);

This was initially complete gobbledegook to me. But I now think that after the 
last statement foo[1] equals 5. Very weird/counterintuitive that y[a] := 5 
works here without the use of scantokens. The first one is less weird to me 
because scantokens actually calls the METAPOST parser on a string as if read 
from a file.

> or you could use global variables, of course.
> 
> Main point: Metapost is not an easy language to grasp. If you want to
> really understand how it works, you should study the Metafont book by DEK.

I actually have that book and did a try small bit of METAFONT long, long ago to 
create a logo in it. Maybe that explains things better. (Unearthing the book 
for later use…)

> As you can clearly see, even experienced users are likely to make mistakes.

The main problem with all of this (ConTeXt, METAPOST, etc.) remains the 
learning curve and the lack of good and up-to-date educational materials. I.e. 
the METAPOST manual is terse, probably because it relies on people 
understanding the background that is in the METAFONT book.

And, if one is used to thinking in terms of functional programming, all that 
‘expansion’ stuff (‘replacement’  programming?) is very counterintuitive for 
me. Lua then adds a functional model to the mix (or I think it does). Very hard 
to make progress. I learned Python in a day and produced a complex program in a 
matter of weeks. This is far less easy. And not being able so far to see what 
intermediate results lea to errors adds to the slow going.

I.e., the whole chapter on vardef in the METAFONT book is 

G

> 
> 
> Best wishes,
> Taco
> 
> 
> 
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


<    1   2   3   4   5   6   7   8   9   10   >