
Hi Keith,
I've been doing some testing to see if bytemaps can be overwritten as a way of reusing them and came up with the code below. The MPpage page 1 should, if my thinking is correct, give three unitsquares coloured red, blue, and green. However it seems the squares are all coloured green. To get what I expected I rewrote the code as in MPpage page 2, but to get the desired outcome I had to create 3 bytemaps. So, does this mean that bytemaps can't be overwritten, or am I missing something?
A monday morning head-against-the-wall-banger, this is what you want i guess: \startMPpage %page 1 color newColor; newbytemap 1 of (250,250,3); numeric p ; p := 0; numeric i ; i := 1; for x := 0 upto 249: for y := 0 upto 249: if i = 1: newColor := \MPcolor{red}; i := 2; elseif i = 2: newColor := \MPcolor{blue}; i := 3; else: newColor := \MPcolor{green}; i := 1; fi; setbyte (x,y) of 1 to (newColor * 255); endfor; endfor; p := p + 259; fill unitsquare scaled 250 shifted(p - 259,0) withbytemap 1; \stopMPpage I can explain when banging does help.
Best Wishes Keith
\starttext \startMPpage %page 1 color newColor; newbytemap 1 of (250,250,3); p := 0; for i = 1 upto 3: for x := 0 upto 249: for y := 0 upto 249: if i = 1: newColor := \MPcolor{red}; elseif i = 2: newColor := \MPcolor{blue}; else: newColor := \MPcolor{green}; fi; setbyte (x,y) of 1 to (newColor * 255); endfor; endfor; p := p + 259; fill unitsquare scaled 250 shifted(p - 259,0) withbytemap 1; endfor; \stopMPpage \startMPpage%page 2 color newColor; p := 0; for i = 1 upto 3: newbytemap i of (250,250,3); for x := 0 upto 249: for y := 0 upto 249: if i = 1: newColor := \MPcolor{red}; elseif i = 2: newColor := \MPcolor{blue}; else: newColor := \MPcolor{green}; fi; setbyte (x,y) of i to (newColor * 255); endfor; endfor; p := p + 259; fill unitsquare scaled 250 shifted(p - 259,0) withbytemap i; endfor; \stopMPpage \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.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 -----------------------------------------------------------------