[NTG-context] update old MP code

Taco Hoekwater taco at bittext.nl
Thu Sep 1 15:40:32 CEST 2022


Hi Hraban,

Adding grouping makes sense:
> 
> def Moire(expr size)(text densities)=

begingroup

>  save dn,a,b,k,labit,n,p,q,s,xs;
>  n := 32;
>  dn := 0;
>  for i := densities:
>    d[incr dn] := abs(i);
>    if i>1: labit[dn]:=1; fi
>  endfor
>  a := min(d[1],d[dn]);
>  b := max(d[1],d[dn]);
>  image(
>    for i=-n upto n:
>     draw (0,i*in/a)--(size,i*in/b);
>      %withpen pencircle scaled 3/5defaultthickness;
>    endfor
>    for i=1 upto dn:
>      k:=(a/d[i]-1)/(a/b-1);
>      if known labit[i]:
>        string s; s:=decimal(d[i]); xs:=0;
>        picture p,q; q := p := depthless(s);
>        if i=dn:
>          q := depthless(s & "  lpi");
>          xs := width(q)-width(p);
>        fi
>        label.top(q, (k*size+1/2xs, n*in/a+1.5mm));
>      fi
>      draw (k*size, n*in/a+1.5mm)--(k*size, k[n*in/a,n*in/b]+.5mm);
>      draw (k*size, -n*in/a-1.5mm)--(k*size, -k[n*in/a,n*in/b]-.5mm);
>    endfor
>  )

endgroup

> enddef;
> draw Moire(57.5mm)(200, 175, 150, 125, 100, 75);
> % ulshiftedto (142mm, 38.5mm);
> \stopreusableMPgraphic


As that at least makes it an expression instead of a statement list.

But also depthless() is never defined?

— 
Taco Hoekwater              E: taco at bittext.nl
genderfluid (all pronouns)





More information about the ntg-context mailing list