Mercurial > hg > forks > multipaint-js
changeset 133:f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 08 Aug 2018 11:06:33 +0300 |
parents | e32cc01bdb23 |
children | def42459c9a4 |
files | Interface.pde draw_inputs.pde draw_outputs.pde draw_smart.pde events.pde exporters.pde multipaint.pde preview.pde |
diffstat | 8 files changed, 152 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- a/Interface.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/Interface.pde Wed Aug 08 11:06:33 2018 +0300 @@ -1152,30 +1152,34 @@ } -void update_ui() { - if (g_iconmode == 1) { +void update_ui(boolean forced) +{ + if (g_iconmode == 1) + { for (int i = 0; i <= 80000; i++) { g_icons[i] = g_map[i]; } } - if (g_repanel <= 0) g_repanel++; + if (g_repanel <= 0) + g_repanel++; + messagebox(width - 12 * 8 * g_uizoom, height - 4 * 8 * g_uizoom); // when tooltipping, the panels are not really // drawn but used for easy coordinate reference - if (g_repanel > 0) { + if (g_repanel > 0 && !forced) + { icontable(width - 32 * g_uizoom, 0, 0, 0); icontable(272 * g_uizoom, height - 32 * g_uizoom, 1, 0); + //icontable(0,0,3,0); if (machine == PLUS4M || machine == PLUS4) { icontable(240 * g_uizoom, height - 32 * g_uizoom, 2, 0); } return; } - if (g_repanel > 0) return; - icontable(width - 32 * g_uizoom - 1, 0, 0, 1); icontable(272 * g_uizoom, height - 32 * g_uizoom, 1, 1); palettebox(g_uizoom * 324 + 4, height - 32 * g_uizoom, width - (96 * g_uizoom) - 4); @@ -1350,7 +1354,7 @@ if (g_rubbermode == 1) { // rubberband mode rubx = x; - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { rubx = chop2(x); } if (fylli() == 1) {
--- a/draw_inputs.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/draw_inputs.pde Wed Aug 08 11:06:33 2018 +0300 @@ -55,13 +55,12 @@ int getmultic(int x1, int y1, int mode) //mode 0=screen 1=brush { - //returns the multicolor color on point x1,y1 - int ad, looks, mmc, source1, source2; ad = 1024 + x1 + y1 * X; - if (g_multic == 2) { + if (g_multic == 2) + { if (mode == 0) return g_map[ad]; if (mode == 1) return g_brush[ad]; } @@ -152,14 +151,15 @@ val = 0; sad = 1024 + xx + yy * X; ad = 65536 + int(xx / 8) + yy * MX; + chek = int(g_map[sad]); - if (chek == 100 || chek == 200) return chek; + if (chek == 100 || chek == 200) + return chek; - if (mode == 0) { + if (mode == 0) ssap = int(g_map[sad]); - } else { + else ssap = int(g_brush[sad]); - } if (ssap == 1) { if (mode == 0) { @@ -191,15 +191,13 @@ } void infersize() { - int xx, yy, cp, molox, okay; + int xx, yy, cp, okay; int bx, by; storeparameters(); xx = 0; - molox = 1; okay = 0; - if (g_multic == 1 || g_hzoomer == 2) molox = 2; cp = easygetcolor(0, 0); - for (xx = 0; xx < X; xx = xx + molox) { + for (xx = 0; xx < X; xx = xx + g_pixelw) { if (easygetcolor(xx, 0) == cp && okay == 0) { g_animx = xx; } else { @@ -215,7 +213,7 @@ } } - g_animx = g_animx + molox; + g_animx = g_animx + g_pixelw; g_animy = g_animy + 1; if (g_animx > 63 || g_animy > 63 || g_animx <= 2 || g_animy <= 2) { message("BAD SIZE|See manual"); @@ -230,7 +228,7 @@ g_bsourcex = g_animx; g_bsourcey = 0; - g_bsourcex2 = g_animx + g_animx - molox; + g_bsourcex2 = g_animx + g_animx - g_pixelw; g_bsourcey2 = g_animy - 1; g_animframes = 0; g_animno = 1; @@ -238,7 +236,7 @@ for (yy = 0; yy <= Y; yy = yy + g_animy) { for (xx = 0; xx <= X; xx = xx + g_animx) { okay = 1; - for (bx = 0; bx < g_animx; bx = bx + molox) { + for (bx = 0; bx < g_animx; bx = bx + g_pixelw) { for (by = 0; by < g_animy; by++) { if (easygetcolor(xx + bx, yy + by) != cp) okay = 0; } @@ -263,8 +261,6 @@ void animbrush_do() { int bx, by; int horisize; - int molox = 1; - if (g_multic == 1) molox = 2; horisize = int(X / g_animx); g_animno = g_animno + 1; if (g_animno > g_animframes) g_animno = 1; @@ -272,7 +268,7 @@ bx = g_animno - (by * horisize); g_bsourcex = bx * g_animx; g_bsourcey = by * g_animy; - g_bsourcex2 = g_bsourcex + g_animx - molox; + g_bsourcex2 = g_bsourcex + g_animx - g_pixelw; g_bsourcey2 = g_bsourcey + g_animy - 1; } @@ -283,11 +279,9 @@ } int get_raster(int xx, int yy) { - int molox = 1; - if (g_multic == 1 || g_hzoomer == 2) molox = 2; - xx = xx + g_raster_offset_x * molox; + xx = xx + g_raster_offset_x * g_pixelw; yy = yy + g_raster_offset_y; - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { xx = int(xx / 2); } int mx = chop8(xx);
--- a/draw_outputs.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/draw_outputs.pde Wed Aug 08 11:06:33 2018 +0300 @@ -51,7 +51,7 @@ //foundational brush control //whether hard coded, circular or bitmap brush int calc, mb; - int a1, b1, s1, x0, y0, midx, midy, molox, passes, ofx, ofy; + int a1, b1, s1, x0, y0, midx, midy, passes, ofx, ofy; ofx = x; ofy = y; mb = g_button; @@ -95,7 +95,6 @@ if (g_btype == 9) { //bitmap brush passes = 2; - molox = 1; int tempox, tempoy, tempx, tempy, moloy; moloy = 1; tempox = g_bsourcex; @@ -117,15 +116,14 @@ } int orient; orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')]; - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { x = chop2(x); - molox = 2; passes = 1; } for (int pp = 1; pp <= passes; pp++) { for (int yy = tempoy; yy <= tempy; yy = yy + moloy) { - for (int xx = tempox; xx <= tempx; xx = xx + molox) { + for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw) { s1 = int(g_brush[1024 + xx + yy * X]); if (g_multic == 0) s1 = getabsa(xx, yy, 1); if (g_multic > 0) s1 = getmultibrush(xx, yy); @@ -156,7 +154,7 @@ if (g_data[int('c')] == 1 || g_shift) { if (orient == 10) y0 = y0 + 1; - if (orient == 11) y0 = y0 + g_gridy - molox; + if (orient == 11) y0 = y0 + g_gridy - g_pixelw; if (orient == 100) x0 = x0 + 1; if (orient == 101) x0 = x0 + g_gridx - 1; if (orient == 110) { @@ -165,7 +163,7 @@ } if (orient == 111) { x0 = x0 + g_gridx - 1; - y0 = y0 + g_gridy - molox; + y0 = y0 + g_gridy - g_pixelw; } } @@ -173,7 +171,7 @@ if (g_multic > 0) { g_farge = s1; if (g_data[int('p')] == 1) g_farge = g_ofarge; - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { if (g_data[int('q')] == 0) makepoint(x0, y0); if (g_data[int('q')] == 1) { makepoint(x0 - x + x0, y + (y0 - y)); @@ -194,7 +192,7 @@ if (mb == RIGHT) { if (g_multic > 0) { - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { if (g_data[int('q')] == 0) clearpoint(x0, y0); if (g_data[int('q')] == 1) { clearpoint(x0 - x + x0, y + (y0 - y)); @@ -247,11 +245,10 @@ void doline(int xfrom, int yfrom, int xto, int yto, int prevent) { //bresenham almost exactly from Wikipedia - int swap, molox, pex, pey; + int swap, pex, pey; boolean steep; - molox = 1; //multicolor 160 pixel reso - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { xfrom = chop2(xfrom); xto = chop2(xto); } @@ -262,10 +259,9 @@ if (prevent == 0) craft(xto, yto, 0); - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { xfrom = int(xfrom / 2); xto = int(xto / 2); - molox = 2; } int x0 = xfrom; @@ -308,15 +304,15 @@ x = x0; while (x != x1) { if (steep) { - if (y * molox != pex || x != pey) { - craft(y * molox, x, 0); - pex = y * molox; + if (y * g_pixelw != pex || x != pey) { + craft(y * g_pixelw, x, 0); + pex = y * g_pixelw; pey = x; } } else { - if (x * molox != pex || y != pey) { - craft(x * molox, y, 0); - pex = x * molox; + if (x * g_pixelw != pex || y != pey) { + craft(x * g_pixelw, y, 0); + pex = x * g_pixelw; pey = y; } } @@ -399,9 +395,7 @@ void rectangle(int x1, int y1, int x2, int y2) { - int x0, y0, molox; - int yt, xt; - int xf, yf; + int x0, y0, yt, xt, xf, yf; xf = chop8(x1); xt = chop8(x2); @@ -411,9 +405,7 @@ yt = yt + 7; xt = xt + 6; - molox = 1; - if (g_multic == 1 || g_hzoomer == 2) molox = 2; if (x2 < x1) { x0 = x2; x2 = x1; @@ -439,7 +431,7 @@ if (g_multic == 1 && g_data[int('d')] == 0) { g_farge = g_map[1]; for (int y = y1; y <= y2; y++) { - for (int x = x1; x <= x2; x = x + molox) { + for (int x = x1; x <= x2; x = x + g_pixelw) { if (x >= xf && y >= yf && x <= xt && y <= yt) { makepoint(x, y); } @@ -449,7 +441,7 @@ g_farge = g_ofarge; if (g_button == RIGHT) g_farge = g_backg; for (int y = y1; y <= y2; y++) { - for (int x = x1; x <= x2; x = x + molox) { + for (int x = x1; x <= x2; x = x + g_pixelw) { makepoint(x, y); } } @@ -531,7 +523,7 @@ } } - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { xx = chop2(xx); } @@ -548,7 +540,7 @@ int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey); int xr = g_bsourcex + x1; int yr = g_bsourcey + y1; - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { x0 = int(xx / ((g_bsourcex2 + 2) - g_bsourcex)); y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey)); x1 = xx - x0 * ((g_bsourcex2 + 2) - g_bsourcex); @@ -897,7 +889,7 @@ g_farge = g_ofarge; return; } - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { xx = chop2(xx); } if (g_data[int('b')] == 1) return; @@ -919,7 +911,7 @@ if (ignore == 0) { g_map[1024 + xx + yy * X] = byte(0); - if (g_multic == 1 || g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(0); + if (g_pixelw == 2) g_map[1024 + xx + yy * X + 1] = byte(0); int xc = int(xx / 8); int yc = int(yy / 8); g_redo[xc + yc * MX] = byte(0); //block update @@ -1017,7 +1009,7 @@ y = int(y / g_gridy) * g_gridy; } - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { x = chop2(x); ox = chop2(ox); } @@ -1050,7 +1042,7 @@ return; } selectcolor(0, getabsa(ox, oy, 0)); - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { ox = chop2(ox); selectcolor(0, getattra(ox, oy, 0)); } @@ -1178,7 +1170,7 @@ if (g_data[int('c')] == 1 || g_shift) { g_rx2--; g_ry2--; - if (g_multic == 1 || g_hzoomer == 2) g_rx2--; + if (g_pixelw == 2) g_rx2--; } } g_rubbermode = 1;
--- a/draw_smart.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/draw_smart.pde Wed Aug 08 11:06:33 2018 +0300 @@ -117,7 +117,7 @@ } -boolean floodfill_mc_plop(int npar, int molox, int xc, int yc) +boolean floodfill_mc_plop(int npar, int xc, int yc) { int ad = 1024 + xc + yc * X; @@ -125,7 +125,7 @@ g_fillmap[ad] == 0) { g_fillmap[ad] = byte(100); - if (molox == 2) + if (g_pixelw == 2) g_fillmap[ad + 1] = byte(0); return true; @@ -136,16 +136,11 @@ void floodfill_mc(int xx, int yy, int mou) { - int x, y, molox, ax, valid, okay, par, npar, zad; + int x, y, ax, valid, okay, par, npar, zad; par = 0; - if (g_multic == 1 || g_hzoomer == 2) - { - molox = 2; + if (g_pixelw == 2) xx = chop2(xx); - } - else - molox = 1; if (mou == LEFT) par = g_farge; @@ -165,27 +160,27 @@ { valid = 0; for (y = 0; y < Y; y++) - for (x = 0; x < X; x += molox) + for (x = 0; x < X; x += g_pixelw) { zad = 1024 + x + y * X; ax = int(g_fillmap[zad]); if (ax >= 100 && ax <= 199) { valid = 1; - if (y > 0 && floodfill_mc_plop(npar, molox, x, y - 1)) + if (y > 0 && floodfill_mc_plop(npar, x, y - 1)) valid = 1; - if (x > molox && floodfill_mc_plop(npar, molox, x - molox, y)) + if (x > g_pixelw && floodfill_mc_plop(npar, x - g_pixelw, y)) valid = 1; - if (x < X - 1 - molox && floodfill_mc_plop(npar, molox, x + molox, y)) + if (x < X - 1 - g_pixelw && floodfill_mc_plop(npar, x + g_pixelw, y)) valid = 1; - if (y < Y - 1 && floodfill_mc_plop(npar, molox, x, y + 1)) + if (y < Y - 1 && floodfill_mc_plop(npar, x, y + 1)) valid = 1; g_fillmap[zad] = byte(200); - if (molox == 2) + if (g_pixelw == 2) g_fillmap[zad + 1] = byte(0); } } @@ -195,7 +190,7 @@ } for (y = 0; y < Y; y++) - for (x = 0; x < X; x += molox) + for (x = 0; x < X; x += g_pixelw) { if (g_fillmap[1024 + x + y * X] == byte(200)) {
--- a/events.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/events.pde Wed Aug 08 11:06:33 2018 +0300 @@ -216,7 +216,7 @@ g_data[int('t')] = 0; g_data[int('n')] = 0; switcher(2); - if (g_multic == 1 || g_hzoomer == 2) { + if (g_pixelw == 2) { g_rx = chop2(g_rx); g_rx2 = chop2(g_rx2); }
--- a/exporters.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/exporters.pde Wed Aug 08 11:06:33 2018 +0300 @@ -3,11 +3,6 @@ // source writer and other export/import functions // remember hexdump -C ! // -String g_formatname, g_formatext; -int[] g_grids = new int[16]; -int OLD = 0; -int NEW = 1; -int g_gridmode = OLD; public class MPWriteCtx @@ -1054,7 +1049,7 @@ if (image.width <= 16 || image.height <= 16) return false; - int balx, baly, xx, yy, x2, y2, rr, gg, bb, avg, molox, i, j, target; + int balx, baly, xx, yy, x2, y2, rr, gg, bb, avg, i, j, target; int cx, cy; int aas, bbs, swap, idefix, avx, avy; int[] pixut = new int[260]; @@ -1082,13 +1077,10 @@ if (g_multic == 2) { limitter = 16; } - molox = 1; + command(int('O')); //special clear screen - if (g_multic == 1 || g_hzoomer == 2) { - molox = 2; - } - balx = int(image.width / X) * molox; + balx = int(image.width / X) * g_pixelw; baly = int(image.height / Y); if (balx < 1) { balx = 1; @@ -1111,7 +1103,7 @@ for (cy = 0; cy < MY * erkki; cy++) for (cx = 0; cx < MX; cx++) for (yy = cy * vertti; yy <= cy * vertti + vertti - 1; yy++) - for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + molox) + for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + g_pixelw) { x2 = int(image.width / X) * xx; y2 = int(image.height / Y) * yy; @@ -1173,7 +1165,7 @@ idx[i] = i; } for (yy = cy * vertti; yy <= cy * vertti + vertti - 1; yy++) { - for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + molox) { + for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + g_pixelw) { x2 = int(image.width / X) * xx; y2 = int(image.height / Y) * yy; rr = 0; @@ -1227,7 +1219,7 @@ i = idx[idefix]; for (yy = cy * vertti; yy <= cy * vertti + vertti - 1; yy++) { - for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + molox) + for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + g_pixelw) { x2 = int(image.width / X) * xx; y2 = int(image.height / Y) * yy; @@ -1269,7 +1261,7 @@ if (idefix == 0) { for (yy = cy * vertti; yy <= cy * vertti + vertti - 1; yy++) - for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + molox) + for (xx = cx * 8; xx <= cx * 8 + 7; xx = xx + g_pixelw) { g_farge = idx[0]; makepoint(xx, yy); @@ -1296,7 +1288,7 @@ for (int xx = 0; xx < X; xx++) { int f; - if (g_multic == 1 || g_hzoomer == 2) + if (g_pixelw == 2) f = getmultic(chop2(xx), yy, 0); else f = getabsa(xx, yy, 0); @@ -1891,4 +1883,10 @@ makecolor(14, 0x23, 0xaf, 0x32); makecolor(15, 0x29, 0xf7, 0xa7); } + + // Compute pixel width + if (g_multic == 1 || g_hzoomer == 2) + g_pixelw = 2; + else + g_pixelw = 1; }
--- a/multipaint.pde Sun Aug 05 14:35:13 2018 +0300 +++ b/multipaint.pde Wed Aug 08 11:06:33 2018 +0300 @@ -18,7 +18,6 @@ int machine = -1; // change this to autoselect int platform = PSJS; - int g_active, g_tooltrigger, g_prevtool; int g_rband, g_rbang, g_boxreconstruct, g_charlimit; int g_animx, g_animy, g_animframes, g_animno, g_animtime, g_animspeed; @@ -26,9 +25,17 @@ boolean g_control = false, g_shift = false, g_dirty; -String filename = "", sfilename = "", g_name, g_exportext = "", +String g_formatname, g_formatext, + filename = "", sfilename = "", + g_name, g_exportext = "", g_exportname = "", g_keymacro = ""; +final int OLD = 0; +final int NEW = 1; +int g_gridmode = OLD; +int g_pixelw = 1; +int[] g_grids = new int[16]; + int[] g_r = new int[266]; int[] g_g = new int[266];
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/preview.pde Wed Aug 08 11:06:33 2018 +0300 @@ -0,0 +1,65 @@ +// The preview window (BACKSPACE key) +// May be changed in the future + +int g_preview = 0; +int g_prevx = 0; +int g_prevy = 0; +int g_phandlex = 0; +int g_phandley = 0; +int g_pgrab = 0; +final int g_pwindow_px = 16, g_pwindow_py = 16; + +int[] g_pwindow = new int[(320 + g_pwindow_px) * (256 + g_pwindow_py)]; + + +void preview_window() +{ + int wix = X + 16; + int ofx = g_prevx; + int ofy = g_prevy; + + if (g_preview == 0) + return; + + for (int y = 0; y < Y + g_pwindow_py; y++) + { + int ad = (ofy + y) * width; + if (y + ofy >= 0 && y + ofy < height) + { + for (int x = 0; x < X + g_pwindow_px; x++) + { + if (x + ofx >= 0 && x + ofx < width) + pixels[ad + x + ofx] = g_pwindow[x + y * wix]; + } + } + } +} + +void preview_box_drag() +{ + g_boxreconstruct = 2; + refresh_all(); + g_repanel = -1; + update_ui(true); +} + + +void update_preview_window() //done at mousereleased +{ + int wix = X + 16; + + if (g_preview == 0) + return; + + for (int y = 0; y < Y + g_pwindow_py; y++) + for (int x = 0; x < X + g_pwindow_py; x++) + { + if (y == 0 || y == Y + 15 || x == 0 || x == X + 15) + g_pwindow[y * wix + x] = g_rgb[257]; + else + if (y < 8 || x < 8 || y >= Y + 8 || x >= X + 8) + g_pwindow[y * wix + x] = g_rgb[g_map[0]]; + else + g_pwindow[y * wix + x] = g_rgb[easygetcolor(x - 8, y - 8)]; + } +}