Re: [NTG-context] metafun transformation error

2021-06-04 Thread Ajith R
Hi,


> here a ; is missing after the q

That was a silly mistake while making the MWE. 
When I corrected it, the MWE compiled correctly. However, the original code 
didn't have that error and wouldn't compile.
So, I tried another MWE and found out what was causing the error.
In the array I defined, there were two elements with empty string as their 
value. Once I changed those empty strings to some valid string, there was no 
error and the file compiled as expected. Here is the new MWE with one array 
element defined as empty string

\starttext
\switchtobodyfont[30pt]
\startMPpage
StartPage ;
unit := 2 * cm ;
%numeric lm, row, col, bm; 
pair  middle;
row := 1; col := 1; 
picture p, q ; p := nullpicture; q := nullpicture;


string l[], lbl;
l[0] := "" ; l[1]:= "2"; 


for i= 0 upto row:
middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) 
))];
lbl := l[i];
p := thelabel(lbl, middle); 
q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner 
p]);
draw q;


endfor
StopPage ;
\stopMPpage
\stoptext


This will throw an error. If l[0] is defined as, say, "hi", there is no error

I suppose, my work around would be to use a non empty string and then fill that 
cell dark. Is there another way?

Anyway, thanks for your prompt replies and patience.

Thanks a ton for sharing your efforts with the world

ajith
\starttext
\switchtobodyfont[30pt]
\startMPpage
StartPage ;
unit := 2 * cm ;
%numeric lm, row, col, bm; 
pair  middle;
row := 1; col := 1; 
picture p, q ; p := nullpicture; q := nullpicture;

string l[], lbl;
l[0] := "" ; l[1]:= "2"; 

for i= 0 upto row:
middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) ))];
lbl := l[i];
p := thelabel(lbl, middle); 
q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]);
draw q;

endfor
StopPage ;
\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] metafun transformation error

2021-06-04 Thread Hans Hagen

On 6/4/2021 5:08 PM, Ajith R wrote:

Hi,



here a ; is missing after the q


That was a silly mistake while making the MWE.
When I corrected it, the MWE compiled correctly. However, the original code 
didn't have that error and wouldn't compile.
So, I tried another MWE and found out what was causing the error.
In the array I defined, there were two elements with empty string as their 
value. Once I changed those empty strings to some valid string, there was no 
error and the file compiled as expected. Here is the new MWE with one array 
element defined as empty string

\starttext
\switchtobodyfont[30pt]
\startMPpage
StartPage ;
unit := 2 * cm ;
%numeric lm, row, col, bm;
pair  middle;
row := 1; col := 1;
picture p, q ; p := nullpicture; q := nullpicture;


string l[], lbl;
l[0] := "" ; l[1]:= "2";


for i= 0 upto row:
middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) 
))];
lbl := l[i];
p := thelabel(lbl, middle);
q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner 
p]);
draw q;


endfor
StopPage ;
\stopMPpage
\stoptext


This will throw an error. If l[0] is defined as, say, "hi", there is no error

I suppose, my work around would be to use a non empty string and then fill that 
cell dark. Is there another way?

Anyway, thanks for your prompt replies and patience.

Thanks a ton for sharing your efforts with the world

you canot reflect about zero dimensions:

p := thetextext(lbl, middle);
message(0.5[urcorner p, ulcorner p]);
if llcorner p <> urcorner p :
q := p reflectedabout (0.5[urcorner p, ulcorner p], 
0.5[lrcorner p, llcorner p]);

draw q;
fi

-
  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] metafun transformation error

2021-06-04 Thread Ajith R
Hi,


> In order answer that you have to make a MWE that we can run without the 
> need to edit a file.

> Hans

Sorry for having assumed that sharing the code was sufficient as MWE.

Here is the trimmed version that still throws the error 


\startMPpage
StartPage ;


numeric row, col, unit; 
pair  middle;
row := 1; col := 1;
unit := 2 * cm ;
picture p, q ; p := nullpicture; q := nullpicture;
string l[];
l[0] := "2" ; l[1] := " 4"; 


for i= 0 upto row :
middle := (i * unit, 5cm);
p := thelabel( l[i], middle); 
draw p;
%q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner 
p]);
%draw q
endfor
StopPage ;
\stopMPpage
\stoptext

The file is also attached.
 As I told earlier, an  error is thrown if I uncomment the line that assigns q 
and then draws it.

Thanks for your help,
ajith
\startMPpage
StartPage ;

numeric row, col, unit; 
pair  middle;
row := 1; col := 1;
unit := 2 * cm ;
picture p, q ; p := nullpicture; q := nullpicture;
string l[];
l[0] := "2" ; l[1] := " 4"; 

for i= 0 upto row :
middle := (i * unit, 5cm);
p := thelabel( l[i], middle); 
draw p;
%q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]);
%draw q
endfor
StopPage ;
\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] metafun transformation error

2021-06-04 Thread Hans Hagen

On 6/4/2021 1:25 PM, Ajith R wrote:

Hi,



In order answer that you have to make a MWE that we can run without the
need to edit a file.



Hans


Sorry for having assumed that sharing the code was sufficient as MWE.

Here is the trimmed version that still throws the error


\startMPpage
StartPage ;


numeric row, col, unit;
pair  middle;
row := 1; col := 1;
unit := 2 * cm ;
picture p, q ; p := nullpicture; q := nullpicture;
string l[];
l[0] := "2" ; l[1] := " 4";


for i= 0 upto row :
middle := (i * unit, 5cm);
p := thelabel( l[i], middle);
draw p;
%q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner 
p]);
%draw q


here a ; is missing after the q


endfor
StopPage ;
\stopMPpage
\stoptext

The file is also attached.
  As I told earlier, an  error is thrown if I uncomment the line that assigns q 
and then draws it.

Thanks for your help,
ajith


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




--

-
  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] metafun transformation error

2021-06-04 Thread Hans Hagen

On 6/4/2021 10:15 AM, Ajith R wrote:

Hi all,

I am new to context and need help in solving an error.

I am trying to print some numbers in a grid onto a transparent sheet as mirror images so 
that the numbers are correctly displayed when I view it from the non printed side. The 
numbers have a particular sequence which cannot be obtained from calculations. So, they 
are stored in an array of strings : l[0][0] := "38"; ...

I place them at the centre of the grid squares using the code below:

for i= 0 upto (row - 1):
for j= 0 upto (col - 1):
middle := 0.5[((( i * unit) + lm), ((j * unit) +  bm)), i+1) * unit) + lm), 
(((j +1) * unit) +  bm))];
p := thelabel(l[j][i], middle);
draw p;

% q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner 
p]);
% draw q;
endfor
endfor

This works as expected. But, when I try to reflect the label by means of the 
commented code, I get an error :

tex error       > mp error on line 643 in file 
/home/ajith/Desktop/PlayGround/numgrid.tex:



(xpart T_,ypart T_,-0.00581xpart T_+0.00497ypart T_+0.15294,-0.00497xpart T_

-0.00581ypart T_+0.98824,-0.00497xpart T_-0.00581ypart T_+0.98825,0.00581xpart
T_-0.00497ypart T_-0.15294)
! Transform components aren't all known.

;
 ...lcorner.p];q:=p.reflectedabout(uq,lq);
draw.p; ENDFOR
 ...=p.reflectedabout(uq,lq);draw.p;endfor
ENDFOR
<*> ...lectedabout (uq, lq); draw p; endfor endfor
StopPage ; ;
I'm unable to apply a partially specified transformation
except to a fully known pair or transform.
Proceed, and I'll omit the transformation.


I tried a mock example without the loops and that didn't throw an error.

How can I make it work within the loops?
In order answer that you have to make a MWE that we can run without the 
need to edit a file.


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
___