About macro numberstriped ()

Hello, I notice a strange behavior of the macro numberstriped ( ). Thanks. Fabrice \starttext \switchtobodyfont[9pt] \startMPcode path p, q, r, b ; p := unitsquare xyscaled (4cm,4cm) ; z[0] = (2cm,0cm) ; z[1] = (2cm,4cm) ; z[2] = (0cm,2cm) ; q := llcorner p--z[0]--z[1]--z[2]--cycle ; r := unitsquare xyscaled (1cm,1cm) shifted(0,3cm) ; b := unitsquare xyscaled (3cm,3cm) shifted(1cm,0) ; draw p ; draw r withcolor red; draw r numberstriped (.25,20,5) withcolor magenta ; draw b numberstriped (.25,20,5) withcolor magenta ; label.llft("D", p) ; label.lrt("C", p) ; label.ulft("A", p) ; label.urt("B", p) ; label.urt("P", lrcorner r) ; label.lft("Q", llcorner r) ; label.top("M", urcorner r) ; \stopMPcode \stoptext

On 9/27/2022 7:49 PM, Fabrice Couvreur via ntg-context wrote:
\starttext \startMPcode path p, q, r, b ; path p ; p := unitsquare xyscaled (4cm,4cm) ; draw p ; draw p withpattern image ( draw (llcorner unitsquare -- urcorner unitsquare) scaled 5mm ; % how to get the corner dots ) withpatternscale 1/16 withpen pencircle scaled 1mm ; \stopMPcode \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 -----------------------------------------------------------------

On 9/28/2022 3:11 PM, Fabrice Couvreur via ntg-context wrote:
Hans (who's dutch is better than his english) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

Hi Hans, When the rectangles are not identical, how to have the same type of hatching in both ? Thanks. Fabrice \starttext \startlinecorrection[blank] \startmidaligned \switchtobodyfont[9pt] \startMPcode path p, q, r, b ; p := unitsquare xyscaled (4cm,4cm) ; z[0] = (2cm,0cm) ; z[1] = (2cm,4cm) ; z[2] = (0cm,2cm) ; q := llcorner p--z[0]--z[1]--z[2]--cycle ; r := unitsquare xyscaled (1cm,1cm) shifted(0,3cm) ; b := unitsquare xyscaled (3cm,3cm) shifted(1cm,0) ; draw r withpattern image ( draw (llcorner unitsquare -- urcorner unitsquare) scaled 5mm ; % how to get the corner dots ) withpatternscale 1/8 withpen pencircle scaled 1pt withcolor cyan; ; draw b withpattern image ( draw (llcorner unitsquare -- urcorner unitsquare) scaled 5mm ; % how to get the corner dots ) withpatternscale 1/16 withpen pencircle scaled 1pt withcolor cyan; ; draw p; draw b; draw r; label.llft("D", p) ; label.lrt("C", p) ; label.ulft("A", p) ; label.urt("B", p) ; label.urt("P", lrcorner r) ; label.lft("Q", llcorner r) ; label.top("M", urcorner r) ; \stopMPcode \stopmidaligned \stoplinecorrection \stoptext Le mer. 28 sept. 2022 à 21:05, Henning Hraban Ramm via ntg-context < ntg-context@ntg.nl> a écrit :

Hi, Initially, there was a bug with maro numberstriped() and Hans suggested another sensible approach to me, but you don't get the same shape of the hatches depending on the dimensions of the squares. Your solution works perfectly but I'm trying to understand the action of the parameters: the first ? the second represents the angle in degrees that the segments make the third represents the gap between two segments Thanks Fabrice Le sam. 1 oct. 2022 à 21:46, Mikael Sundqvist via ntg-context < ntg-context@ntg.nl> a écrit :

On 02/10/2022 10:55, Fabrice Couvreur via ntg-context wrote:
some unexpected side effect show up when the unitsquare is xyscaled to a rectangle like (2.5cm,1cm) it seems related to the angle chosen e.g. \startMPcode path p, q, r, b ; p := unitsquare xyscaled (4cm,4cm) ; q := unitsquare xyscaled (1cm,1cm) shifted(0,3cm) ; r := unitsquare xyscaled (2.5cm,1cm) shifted(1cm,3cm) ; b := unitsquare xyscaled (3cm,3cm) shifted(1cm,0) ; draw r anglestriped (1,35,2) withcolor red; draw q anglestriped (1,35,2) withcolor green; draw b anglestriped (1,35,2) withcolor cyan; draw p; draw q; draw b; draw r; label.llft("D", p) ; label.lrt("C", p) ; label.ulft("A", p) ; label.urt("B", p) ; label.urt("P", lrcorner r) ; label.lft("Q", llcorner r) ; label.top("M", urcorner r) ; \stopMPcode

Not only, it is also true with the code below : \startMPcode path p, q, r, b ; p := unitsquare xyscaled (4cm,4cm) ; z[0] = (2cm,0cm) ; z[1] = (2cm,4cm) ; z[2] = (0cm,2cm) ; q := llcorner p--z[0]--z[1]--z[2]--cycle ; r := unitsquare xyscaled (1cm,1cm) shifted(0,3cm) ; b := (0cm,0cm) -- lrcorner r -- lrcorner p -- cycle; draw r anglestriped (1,45,2) withcolor green; draw b anglestriped (1,45,2) withcolor green; draw b withcolor darkgreen; draw r withcolor darkgreen; draw p; label.llft("B", p) ; label.lrt("C", p) ; label.ulft("A", p) ; label.urt("D", p) ; label.urt("F", lrcorner r) ; label.lft("E", llcorner r) ; label.top("G", urcorner r) ; \stopMPcode Le dim. 2 oct. 2022 à 11:21, Floris van Manen via ntg-context < ntg-context@ntg.nl> a écrit :

On 10/2/2022 11:20 AM, Floris van Manen via ntg-context wrote:
for that you can patch mp-tool.mpxl (l 676): maximum := max (xpart llcorner mask, xpart urcorner mask, ypart llcorner mask, ypart urcorner mask) ; minimum := min (xpart llcorner mask, xpart urcorner mask, ypart llcorner mask, ypart urcorner mask) ; % a hack: maximum := maximum + max(xpart urcorner shape, ypart urcorner shape); minimum := minimum - max(xpart urcorner shape, ypart urcorner shape); a bit overkill but it seems to work 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 -----------------------------------------------------------------

I just tried but I got an empty file...
Do we agree that I have to replace the two lines with the other two ?
Regarding what you proposed, how to get the same type of hatching in both
figures ?
\startMPcode
path p, q, r, b ;
p := unitsquare xyscaled (4cm,4cm) ;
z[0] = (2cm,0cm) ;
z[1] = (2cm,4cm) ;
z[2] = (0cm,2cm) ;
q := llcorner p--z[0]--z[1]--z[2]--cycle ;
r := unitsquare xyscaled (1cm,1cm) shifted(0,3cm) ;
b := (0cm,0cm) -- lrcorner r -- lrcorner p -- cycle;
draw r
withpattern image (
draw (llcorner unitsquare -- urcorner unitsquare) scaled 5mm ;
% how to get the corner dots
)
withpatternscale 1/4
withpen pencircle scaled 1bp
withcolor green
;
draw b
withpattern image (
draw (llcorner unitsquare -- urcorner unitsquare) scaled 5mm ;
% how to get the corner dots
)
withpatternscale 1/16
withpen pencircle scaled 1bp
withcolor green
;
draw b withpen pencircle scaled 1bp withcolor darkgreen;
draw r withpen pencircle scaled 1bp withcolor darkgreen;
draw p;
label.llft("B", p) ;
label.lrt("C", p) ;
label.ulft("A", p) ;
label.urt("D", p) ;
label.urt("F", lrcorner r) ;
label.lft("E", llcorner r) ;
label.top("G", urcorner r) ;
\stopMPcode
Le dim. 2 oct. 2022 à 11:52, Hans Hagen via ntg-context

On 10/2/2022 1:02 PM, Fabrice Couvreur via ntg-context wrote:
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 -----------------------------------------------------------------

On 10/2/2022 3:13 PM, Fabrice Couvreur via ntg-context wrote:
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 -----------------------------------------------------------------

Hi,
On Sun, Oct 2, 2022 at 3:26 PM Hans Hagen via ntg-context
Oh, OK, here it goes. Hans will probably rename things if he adds this. \startMPpage[offset=1dk] vardef Stripe(expr p, a, d) = save thestripe ; picture thestripe ; thestripe := nullpicture ; save diag ; numeric diag ; diag := 0.55*( abs((urcorner boundingbox p) - (llcorner boundingbox p)) ) ; thestripe := image ( draw (-diag,0) -- (diag, 0) && for i = d step d until diag: (-diag, i) -- (diag, i) && (-diag,-i) -- (diag,-i) && endfor nocycle withpen currentpen ; ) ; thestripe := thestripe shifted center boundingbox p ; thestripe := thestripe rotatedaround(center boundingbox p, a) ; clip thestripe to p ; thestripe enddef ; path p ; p := fullcircle scaled 3cm && (unitsquare scaled 2cm shifted (4cm,4cm)) && cycle ; fill p withcolor darkred ; draw Stripe(p,30,.2cm) withcolor darkgreen ; path q ; q := fullsquare randomized 0.3 scaled 3cm yshifted 5cm ; fill q withcolor yellow ; draw Stripe(q,70,.3cm) withcolor red ; draw Stripe(p && q && cycle, -20, .5cm) withcolor "orange" ; draw p ; draw q ; \stopMPpage /Mikael
participants (5)
-
Fabrice Couvreur
-
Floris van Manen
-
Hans Hagen
-
Henning Hraban Ramm
-
Mikael Sundqvist