* metafun transformation error [not found] ` <561884252.127404.1622754117330@mail.yahoo.com> @ 2021-06-04 8:15 ` Ajith R 2021-06-04 9:22 ` Hans Hagen 0 siblings, 1 reply; 6+ messages in thread From: Ajith R @ 2021-06-04 8:15 UTC (permalink / raw) To: ntg-context 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. <to be read again> ; <for(0)> ...lcorner.p];q:=p.reflectedabout(uq,lq); draw.p; ENDFOR <for(0)> ...=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? Thanks, 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: metafun transformation error 2021-06-04 8:15 ` metafun transformation error Ajith R @ 2021-06-04 9:22 ` Hans Hagen 2021-06-04 11:25 ` Ajith R 0 siblings, 1 reply; 6+ messages in thread From: Hans Hagen @ 2021-06-04 9:22 UTC (permalink / raw) To: mailing list for ConTeXt users 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. > <to be read again> > ; > <for(0)> ...lcorner.p];q:=p.reflectedabout(uq,lq); > draw.p; ENDFOR > <for(0)> ...=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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: metafun transformation error 2021-06-04 9:22 ` Hans Hagen @ 2021-06-04 11:25 ` Ajith R 2021-06-04 12:27 ` Hans Hagen 0 siblings, 1 reply; 6+ messages in thread From: Ajith R @ 2021-06-04 11:25 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/plain, Size: 859 bytes --] 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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: errortest.tex --] [-- Type: text/x-tex, Size: 414 bytes --] \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 [-- Attachment #3: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: metafun transformation error 2021-06-04 11:25 ` Ajith R @ 2021-06-04 12:27 ` Hans Hagen 2021-06-04 15:08 ` Ajith R 0 siblings, 1 reply; 6+ messages in thread From: Hans Hagen @ 2021-06-04 12:27 UTC (permalink / raw) To: Ajith R, mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: metafun transformation error 2021-06-04 12:27 ` Hans Hagen @ 2021-06-04 15:08 ` Ajith R 2021-06-04 15:28 ` Hans Hagen 0 siblings, 1 reply; 6+ messages in thread From: Ajith R @ 2021-06-04 15:08 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/plain, Size: 1414 bytes --] 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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: errortest.tex --] [-- Type: text/x-tex, Size: 512 bytes --] \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 [-- Attachment #3: Type: text/plain, Size: 493 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: metafun transformation error 2021-06-04 15:08 ` Ajith R @ 2021-06-04 15:28 ` Hans Hagen 0 siblings, 0 replies; 6+ messages in thread From: Hans Hagen @ 2021-06-04 15:28 UTC (permalink / raw) To: Ajith R, mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-04 15:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <561884252.127404.1622754117330.ref@mail.yahoo.com> [not found] ` <561884252.127404.1622754117330@mail.yahoo.com> 2021-06-04 8:15 ` metafun transformation error Ajith R 2021-06-04 9:22 ` Hans Hagen 2021-06-04 11:25 ` Ajith R 2021-06-04 12:27 ` Hans Hagen 2021-06-04 15:08 ` Ajith R 2021-06-04 15:28 ` Hans Hagen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).