annotate draw_outputs.pde @ 221:17f635da5180

Merge.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2018 12:30:41 +0300
parents 934934bb1fbb
children 1c9deae71fb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1 // Collect all that "writes" the virtual image in some way or other
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
2 // plus other active manipulations
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
3
156
5d73681b97eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
4 int clampv(int v, int vmin, int vmax)
154
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
5 {
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
6 return (v < vmin) ? vmin : (v > vmax ? vmax : v);
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
7 }
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
8
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
9 int chop2(int v)
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
10 {
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
11 return int(v / 2) * 2;
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
12 }
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
13
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
14 int chop8(int v)
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
15 {
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
16 return int(v / 8) * 8;
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
17 }
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
18
146
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
19 int chopv(int v, int qv)
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
20 {
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
21 return int(v / qv) * qv;
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
22 }
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
23
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
24
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
25 void createpoint(int x, int y, int mo)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
26 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
27 if (mo == LEFT) makepoint(x, y);
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
28 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
29 if (mo == RIGHT) clearpoint(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
31
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
32
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
33 void doborx(int xf, int yf, int xt, int yt)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
34 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
35 //rectangle for brush drawing
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
36 for (int ii = xf; ii <= xt; ii++)
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
37 for (int jj = yf; jj <= yt; jj++)
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
38 createpoint(ii, jj, g_button);
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
39 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
40
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
41
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
42 void docircx(int xf, int yf, int hh, int vv)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
43 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44 //circle for brush drawing
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
45 float prop, fh = hh, fv = vv;
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
46
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
47 if (vv > 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
48 prop = fh / fv;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
49 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50 prop = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
51 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
52 hh++;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
53
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
54 for (int ii = -hh; ii <= hh; ii++)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
55 for (int jj = -vv; jj <= vv; jj++)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
56 {
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
57 if (dist(xf + ii, yf + jj * prop, xf, yf) <= hh - 1)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
58 createpoint(xf + ii, yf + jj, g_button);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
59 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
60 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
61
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
62
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
63 void craft(int x, int y, int c)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
64 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
65 //foundational brush control
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
66 //whether hard coded, circular or bitmap brush
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
67 int calc, mb;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
68 int a1, b1, s1, x0, y0, midx, midy, passes, ofx, ofy;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
69 ofx = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
70 ofy = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71 mb = g_button;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
72 if (g_btype == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
73 if (g_bsize < 4) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
74 //some hardcoded brushes
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75 switch (g_bsize) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
76 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
77 doborx(ofx, ofy, ofx + 1, ofy + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
78 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
79 case 1:
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
80 if (g_data[int('c')] == 1 || g_shift == true) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
81 ofx = ofx + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82 ofy = ofy + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
83 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
84 doborx(ofx - 1, ofy - 1, ofx + 1, ofy + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
85 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86 case 2:
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
87 if (g_data[int('c')] == 1 || g_shift == true) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
88 ofx = ofx + 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 ofy = ofy + 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
90 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
91 doborx(ofx - 2, ofy - 2, ofx + 1, ofy + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
92 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 case 3:
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
94 if (g_data[int('c')] == 1 || g_shift == true) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
95 ofx = ofx + 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
96 ofy = ofy + 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
97 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
98 doborx(ofx - 3, ofy - 3, ofx + 4, ofy + 4);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
99 break;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
100 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 } else { //larger size brushes
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102 calc = g_bsize - 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 calc = calc * calc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 calc = calc + 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 doborx(x - calc, y - calc, x + calc, y + calc);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107 return;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
108 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
109
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
110 if (g_btype == 9) { //bitmap brush
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 passes = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 int tempox, tempoy, tempx, tempy, moloy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113 moloy = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 tempox = g_bsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 tempoy = g_bsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
116 tempx = g_bsourcex2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
117 tempy = g_bsourcey2;
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
118 if (g_data[int('t')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 if (tempx > g_bsourcex + 16) tempx = g_bsourcex + 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120 if (tempy > g_bsourcey + 16) tempy = g_bsourcey + 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
121 }
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
122 midx = int((g_bsourcex2 - g_bsourcex) / 2);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
123 midy = int((g_bsourcey2 - g_bsourcey) / 2);
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
124 if (g_data[int('c')] == 1 || g_shift == true) {
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
125 if (g_data[int('q')] == 1) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
126 // XXX is this g_gridx an error?
146
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
127 midy = chopv(midy, g_gridx);
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
128 midx = chopv(midx, g_gridx);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
129 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
130 }
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
131 int orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')];
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
132 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
133 x = chop2(x);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
134 passes = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
135 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
136
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
137 for (int pp = 1; pp <= passes; pp++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
138 for (int yy = tempoy; yy <= tempy; yy = yy + moloy) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
139 for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
140 s1 = int(g_brush[1024 + xx + yy * X]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
141 if (g_multic == 0) s1 = getabsa(xx, yy, 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
142 if (g_multic > 0) s1 = getmultibrush(xx, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
143 if (s1 != g_backg) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
144 x0 = x + xx - g_bsourcex;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
145 y0 = y + yy - g_bsourcey;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
146
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
147 if (g_data[int('q')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
148 x0 = x - (yy - g_bsourcey2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
149 y0 = y + (xx - g_bsourcex);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
150 x0 = x0 + midx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
151 x0 = x0 - midy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
152 y0 = y0 + midy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
153 y0 = y0 - midx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
154 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
155
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
156 if (g_data[int('x')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
157 x0 = x0 - (x + midx);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
158 x0 = -x0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
159 x0 = x0 + (x + midx);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
160 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
161
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
162 if (g_data[int('y')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
163 y0 = y0 - (y + midy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
164 y0 = -y0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
165 y0 = y0 + (y + midy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
168 if (g_data[int('c')] == 1 || g_shift) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
169 if (orient == 10) y0 = y0 + 1;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
170 if (orient == 11) y0 = y0 + g_gridy - g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171 if (orient == 100) x0 = x0 + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
172 if (orient == 101) x0 = x0 + g_gridx - 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
173 if (orient == 110) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
174 x0 = x0 + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
175 y0 = y0 + 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
176 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
177 if (orient == 111) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
178 x0 = x0 + g_gridx - 1;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
179 y0 = y0 + g_gridy - g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
180 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
182
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
183 if (mb == LEFT) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
184 if (g_multic > 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 g_farge = s1;
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
186 if (g_data[int('p')] == 1) g_farge = g_ofarge;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
187 if (g_pixelw == 2) {
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
188 if (g_data[int('q')] == 0) makepoint(x0, y0);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
189 if (g_data[int('q')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
190 makepoint(x0 - x + x0, y + (y0 - y));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
191 makepoint(x0 - x + x0, y + (y0 - y) + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
192 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
193 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
194 makepoint(x0, y0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
195 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
196 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
197 g_farge = s1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
198 if (zxcolor(g_farge) != zxcolor(g_backg)) {
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
199 if (g_data[int('p')] == 1) g_farge = g_ofarge;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
200 makepoint(x0, y0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
201 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
202 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
203 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
204
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
205 if (mb == RIGHT) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
206 if (g_multic > 0) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
207 if (g_pixelw == 2) {
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
208 if (g_data[int('q')] == 0) clearpoint(x0, y0);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
209 if (g_data[int('q')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
210 clearpoint(x0 - x + x0, y + (y0 - y));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
211 clearpoint(x0 - x + x0, y + (y0 - y) + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
212 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
213 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
214 clearpoint(x0, y0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
215 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
216 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
217 clearpoint(x0, y0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
218 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
219 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
220 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
221 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
222 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
223 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
224 g_farge = g_ofarge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
225 return;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
226 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
227
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
228 if (g_bsize < 4) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
229 switch (g_bsize) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
230 case 0:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
231 createpoint(x, y, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
232 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
233 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
234 createpoint(x, y + 1, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
235 createpoint(x, y - 1, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
236 createpoint(x, y, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
237 createpoint(x - 1, y, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
238 createpoint(x + 1, y, g_button);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
239 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
240 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
241 doborx(x - 1, y - 2, x + 1, y + 2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
242 doborx(x - 2, y - 1, x + 2, y + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
243 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
245 doborx(x - 3, y - 1, x + 3, y + 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
246 doborx(x - 1, y - 3, x + 1, y + 3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
247 doborx(x - 2, y - 2, x + 2, y + 2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
248 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
249 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
250 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
251 calc = g_bsize - 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
252 calc = calc * calc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
253 calc = calc + 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
254 docircx(x, y, calc, calc);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
255 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
256 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
257
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
258
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
259 void do_line(int xfrom, int yfrom, int xto, int yto, int prevent)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
260 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
261 //bresenham almost exactly from Wikipedia
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
262 int swap, pex, pey;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
263 boolean steep;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
264 //multicolor 160 pixel reso
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
265 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
266 xfrom = chop2(xfrom);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
267 xto = chop2(xto);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
268 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
269
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
270 craft(xfrom, yfrom, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
271 pex = xfrom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
272 pey = yfrom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
273
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
274 if (prevent == 0) craft(xto, yto, 0);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
275
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
276 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
277 xfrom = int(xfrom / 2);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
278 xto = int(xto / 2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
279 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
280
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
281 int x0 = xfrom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
282 int y0 = yfrom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
283 int x1 = xto;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
284 int y1 = yto;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
285
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
286 steep = abs(y1 - y0) > abs(x1 - x0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
287
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
288 if (steep) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
289 swap = x0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
290 x0 = y0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
291 y0 = swap;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
292 swap = x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
293 x1 = y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
294 y1 = swap;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
295 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
296
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
297 float deltax = abs(x1 - x0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
298 float deltay = abs(y1 - y0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
299 float error = deltax / 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
300 int ystep;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
301
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
302 if (deltax == 0) return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
303
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
304 int y = y0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
305 int inc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
306
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
307 if (x0 < x1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
308 inc = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
309 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
310 inc = -1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
311 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
312 if (y0 < y1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
313 ystep = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
314 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
315 ystep = -1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
316 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
317 int x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
318 x = x0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
319 while (x != x1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
320 if (steep) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
321 if (y * g_pixelw != pex || x != pey) {
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
322 craft(y * g_pixelw, x, 0);
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
323 pex = y * g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
324 pey = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
325 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
326 } else {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
327 if (x * g_pixelw != pex || y != pey) {
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
328 craft(x * g_pixelw, y, 0);
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
329 pex = x * g_pixelw;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
330 pey = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
331 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
332 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
333
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
334 error = error - deltay;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
335 if (error < 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
336 y = y + ystep;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
337 error = error + deltax;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
338 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
339 x = x + inc;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
340 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
341 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
342
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
343 void do_circle_new(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
344 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
345 int hh, vv;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
346 float prop;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
347 int xf, yf;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
348 float fh, fv;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
349
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
350 if (x2 < x1) x2 = x1 - (x2 - x1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
351 if (y2 < y1) y2 = y1 - (y2 - y1);
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
352
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
353 xf = x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
354 yf = y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
355 hh = x2 - x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
356 vv = y2 - y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
357 fh = hh;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
358 fv = vv;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
359 if (vv > 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
360 prop = fh / fv;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
361 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
362 prop = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
363 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
364 hh++;
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
365 for (int ii = -hh; ii <= hh; ii++)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
366 for (int jj = -vv; jj <= vv; jj++)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
367 {
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
368 if (dist(xf + ii, yf + jj * prop, xf, yf) <= hh - 1)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
369 createpoint(xf + ii, yf + jj, g_button);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
370 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
371 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
372
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
373
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
374 void do_circle(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
375 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
376 float dds, a, t, sx, sy, gear1, gear2, x0, y0;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
377 int prex, prey;
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
378
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
379 dds = dist(x1, y1, x2, y2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
380 gear1 = int(dds);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
381 if (gear1 <= 12) gear1 = 12;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
382 if (gear1 > 120) gear1 = 120;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
383 gear2 = int(gear1 * 2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
384
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
385 if (x2 < x1) x2 = x1 - (x2 - x1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
386 if (y2 < y1) y2 = y1 - (y2 - y1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
387
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
388 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
389 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
390
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
391 if (g_data[int('f')] == 1 && g_btype != 9) {
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
392 if (g_multic == 1 && g_data[int('d')] == 0) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
393 g_farge = g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
394 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1)));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
395 g_farge = g_ofarge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
396 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
397 docircx(x1, y1, abs(x2 - int(x1)), abs(y2 - int(y1)));
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
398 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
399
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
400 prex = 0;
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
401 prey = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
402 for (t = 0; t <= (gear2); t++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
403 a = t / (gear1) * PI;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
404 sx = (x2 - x1) * sin(a);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
405 sy = (y1 - y2) * cos(a);
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
406 if (t > 0) do_line(prex, prey, x1 + int(sx), y1 + int(sy), 1);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
407 prex = (x1 + int(sx));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
408 prey = (y1 + int(sy));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
409 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
410 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
411
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
412
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
413 void do_rectangle(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
414 {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
415 int x0, y0, yt, xt, xf, yf;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
416
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
417 xf = chop8(x1);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
418 xt = chop8(x2);
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
419
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
420 yf = chop8(y1);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
421 yt = chop8(y2);
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
422
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
423 yt = yt + 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
424 xt = xt + 6;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
425
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
426 if (x2 < x1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
427 x0 = x2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
428 x2 = x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
429 x1 = x0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
430 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
431 if (y2 < y1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
432 y0 = y2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
433 y2 = y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
434 y1 = y0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
435 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
436
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
437 if (g_data[int('t')] == 1 && x2 > x1 + 15) x2 = x1 + 16;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
438 if (g_data[int('t')] == 1 && y2 > y1 + 15) y2 = y1 + 16;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
439
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
440 if (g_btype != 9) {
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
441 if (g_data[int('c')] == 1 || g_shift) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
442 if (x2 > x1) x2--;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
443 if (y2 > y1) y2--;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
444 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
445 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
446
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
447 if (g_data[int('f')] == 1 && g_btype != 9) {
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
448 if (g_multic == 1 && g_data[int('d')] == 0) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
449 g_farge = g_map[1];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
450 for (int y = y1; y <= y2; y++) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
451 for (int x = x1; x <= x2; x = x + g_pixelw) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
452 if (x >= xf && y >= yf && x <= xt && y <= yt) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
453 makepoint(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
454 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
455 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
456 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
457 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
458 g_farge = g_ofarge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
459 if (g_button == RIGHT) g_farge = g_backg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
460 for (int y = y1; y <= y2; y++) {
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
461 for (int x = x1; x <= x2; x = x + g_pixelw) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
462 makepoint(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
463 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
464 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
465 }
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
466 if (g_data[int('f')] == 0 || g_btype == 9) {
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
467 if (g_data[int('c')] == 1 && g_btype == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
468 if (x2 > x1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
469 if (g_bsize == 0) x2--;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
470 if (g_bsize == 1) x2 = x2 - 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
471 if (g_bsize == 2) x2 = x2 - 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
472 if (g_bsize == 3) x2++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
473 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
474 if (y2 > y1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
475 if (g_bsize == 0) y2--;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
476 if (g_bsize == 1) y2 = y2 - 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
477 if (g_bsize == 2) y2 = y2 - 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
478 if (g_bsize == 3) y2++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
479 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
480 }
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
481 do_line(x1, y1, x2, y1, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
482 do_line(x1, y1, x1, y2, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
483 do_line(x1, y2, x2, y2, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
484 do_line(x2, y2, x2, y1, 0);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
485 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
486 g_farge = g_ofarge;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
487 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
488
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
489
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
490 void makepoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
491 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
492 //central pixelmaking function
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
493 //has become very messy but what are you gonna do
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
494 int uses[] = new int[8];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
495 int fars[] = new int[8];
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
496 int mirrix = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
497 int mirriy = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
498 int tiler = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
499 int ignore = 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
500 int fari;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
501
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
502 //for the X/Y mirrors & tiler, the function calls itself with x+10000 or y+10000
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
503 //resolved here
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
504 if (xx >= 20000) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
505 xx = xx - 20000;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
506 mirrix = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
507 mirriy = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
508 tiler = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
509 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
510 if (xx >= 10000) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
511 xx = xx - 10000;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
512 mirrix = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
513 mirriy = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
514 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
515 if (yy >= 10000) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
516 yy = yy - 10000;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
517 mirriy = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
518 mirrix = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
519 }
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
520
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
521 if (xx < 0 || yy < 0 || xx >= X || yy >= Y) return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
522
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
523 // adaptive color unless with floodfill (which has its own system)
173
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
524 if (int(g_map[12]) != 5)
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
525 {
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
526 if (g_multic == 2)
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
527 {
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
528 skaveri(xx, yy, g_farge, 0);
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
529 }
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
530 else
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
531 {
173
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
532 if (g_data[int('b')] == 0)
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
533 {
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
534 if (g_multic == 1)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
535 mkaveri(xx, yy, g_farge, 0);
173
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
536 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
537 kaveri(xx, yy, g_farge, 0);
173
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
538 }
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
539 else
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
540 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
541 //old iq
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
542 kaveri_iq(xx, yy, g_farge, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
543 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
544 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
545 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
546
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
547 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
548 xx = chop2(xx);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
549 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
550
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
551 if (g_data[int('r')] == 1) { //simple raster
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
552 if (get_raster(xx, yy) == 0) ignore = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
553 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
554
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
555 if (g_data[int('R')] == 1) { //user defined raster
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
556 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
557
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
558 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
559 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
560 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
561 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
562 int xr = g_bsourcex + x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
563 int yr = g_bsourcey + y1;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
564 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
565 x0 = int(xx / ((g_bsourcex2 + 2) - g_bsourcex));
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
566 y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
567 x1 = xx - x0 * ((g_bsourcex2 + 2) - g_bsourcex);
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
568 x1 = chop2(x1);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
569 y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
570 xr = g_bsourcex + x1;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
571 xr = chop2(xr);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
572 yr = g_bsourcey + y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
573 if (getmultic(xr, yr, 1) == g_backg) ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
574 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
575 if (getabsa(xr, yr, 1) == g_backg) ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
576 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
577 // if(g_brush[1024+xr+yr*X]==0){ignore=1;}
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
578 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
579 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
580
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
581 int xc, yc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
582
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
583 if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
584 int aba, baba, ii, jj, miny, maxy, ojox, ojoy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
585 aba = getattra(xx, yy, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
586 baba = getattra(xx, yy, 1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
587 if (g_multic == 0) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
588 ojox = chop8(xx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
589 ojoy = chop8(yy);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
590 miny = yy - ojoy;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
591 maxy = miny;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
592
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
593 if (g_attrimode == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
594 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
595 maxy = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
596 }
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
597
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
598 if (baba == g_backg) simplepaint(xx, yy, 1, g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
599 if (aba == g_backg) simplepaint(xx, yy, 0, g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
600 ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
601 if (g_farge == baba && g_farge == aba) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
602 for (jj = miny; jj <= maxy; jj++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
603 for (ii = 0; ii < 8; ii++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
604 g_map[1024 + ojox + ojoy * X + ii + jj * X] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
605 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
606 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
607 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
608 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
609 if (aba == g_backg) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
610 ignore = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
611 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
612 ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
613 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
614 }
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
615 xc = int(xx / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
616 yc = int(yy / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
617 g_redo[xc + yc * MX] = byte(0); //block update
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
618 g_remdo[xc + yc * MX] = byte(1); //block update
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
619 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
620
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
621 if (ignore == 0) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
622 xc = int(xx / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
623 yc = int(yy / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
624 g_redo[xc + yc * MX] = byte(0); //block update
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
625 g_remdo[xc + yc * MX] = byte(1); //block update
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
626
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
627 switch (g_multic) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
628 case 0: //1-bit + attribute i.e. spectrum
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
629 fari = g_farge;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
630 if (g_machine == MSX && fari == int(g_map[1])) fari = 0;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
631 if (g_britemode == 1 && fari == 8) fari = 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
632
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
633 if (getattra(xx, yy, 1) == 0 && fari == g_map[1]) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
634 g_map[1024 + xx + yy * X] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
635 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
636 if (getattra(xx, yy, 1) == fari) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
637 g_map[1024 + xx + yy * X] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
638 } else {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
639 int ojox = chop8(xx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
640 int ojoy = chop8(yy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
641 int mac, macpre, maxos;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
642 int maxoy, miny, maxy;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
643 mac = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
644 macpre = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
645 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
646 maxy = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
647 maxos = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
648 if (g_attrimode == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
649 miny = (yy - ojoy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
650 maxy = miny;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
651 maxos = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
652 } //MSX
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
653 for (int j = miny; j <= maxy; j++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
654 for (int i = 0; i < 8; i++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
655 if (g_map[1024 + ojox + ojoy * X + j * X] == 1) macpre++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
656 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
657 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
658 g_map[1024 + xx + yy * X] = byte(1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
659 for (int j = miny; j <= maxy; j++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
660 for (int i = 0; i < 8; i++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
661 if (g_map[1024 + ojox + ojoy * X + i + j * X] == 1) mac++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
662 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
663 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
664 if (mac == maxos) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
665 for (int j = miny; j <= maxy; j++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
666 int vad = 1024 + ojox + (ojoy + j) * X;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
667 for (int i = 0; i < 8; i++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
668 g_map[vad] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
669 vad++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
670 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
671 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
672 simplepaint(xx, yy, 1, fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
673 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
674 simplepaint(xx, yy, 0, fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
675 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
676 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
677 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
678 break;
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
679
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
680 case 1: //c64 style zoomed multicolour
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
681 //foreg
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
682 int looks, skippo;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
683 byte bit1, bit2, valu1, valu2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
684 int metax, metay, mex, mey, metamax;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
685 fari = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
686 int zeroc = int(g_map[1]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
687 int zeroc2 = int(g_map[2]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
688 boolean cut = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
689 if (fari == zeroc) { //shortcut
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
690 g_map[1024 + xx + yy * X] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
691 g_map[1024 + xx + yy * X + 1] = byte(0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
692 cut = true;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
693 }
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
694 if (g_machine == PLUS4M && fari == zeroc2) { //shortcut
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
695 g_map[1024 + xx + yy * X] = byte(1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
696 g_map[1024 + xx + yy * X + 1] = byte(1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
697 cut = true;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
698 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
699 if (cut) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
700 // X Y mirrors
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
701 if (g_data[int('t')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
702 if (tiler == 0) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
703 int ex = int(X / g_gridx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
704 int ey = int(Y / g_gridy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
705 for (int tilx = -ex; tilx <= ex; tilx++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
706 for (int tily = -ey; tily <= ey; tily++) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
707 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
708 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
709 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
710 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
711 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
712 }
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
713 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
714 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
715 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
716 if (mirrix == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
717 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
718 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
719 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
720 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
721 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
722
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
723 uses[0] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
724 uses[1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
725 uses[2] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
726 uses[3] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
727 fars[0] = zeroc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
728 fars[1] = zeroc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
729 fars[2] = zeroc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
730 fars[3] = zeroc;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
731 mex = int(xx / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
732 mey = int(yy / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
733 looks = 65536 + mex + mey * MX;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
734 mex = int(mex * 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
735 mey = int(mey * 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
736 int saps = 1024 + mex + mey * X;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
737
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
738 for (metay = 0; metay <= 7; metay++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
739 for (metax = 0; metax <= 3; metax++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
740 int pars = g_map[saps] + g_map[saps + 1] * 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
741 uses[pars] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
742 if (pars == 0) fars[0] = zeroc;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
743 if (pars == 1) fars[1] = int(g_map[looks]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
744 if (pars == 2) fars[2] = int(g_map[looks + 1000]);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
745 if (pars == 3) {
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
746 if (g_machine == C64M) fars[3] = int(g_map[looks + 2000]);
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
747 if (g_machine == PLUS4M) fars[3] = zeroc2;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
748 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
749 saps = saps + 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
750 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
751 saps = saps - 8 + X;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
752 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
753
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
754 bit1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
755 bit2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
756 skippo = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
757
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
758 // mega-escape, if it's not possible to draw at all don't bother
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
759 if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
760 if (fari != fars[0] && fari != fars[1] && fari != fars[2] && fari != fars[3]) skippo = 100;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
761 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
762
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
763 if (skippo == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
764 int okay = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
765 metamax = 3;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
766 if (g_machine == PLUS4M) metamax = 2;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
767
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
768 // if the color is already in the 4x8 area?
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
769
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
770 for (metay = 0; metay <= metamax; metay++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
771 if (uses[metay] == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
772 if (fars[metay] == fari) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
773 if (metay == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
774 bit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
775 bit2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
776 g_map[looks] = byte(fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
777 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
778 if (metay == 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
779 bit1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
780 bit2 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
781 g_map[looks + 1000] = byte(fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
782 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
783 if (metay == 3) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
784 bit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
785 bit2 = 1;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
786 if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
787 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
788 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
789 g_map[1024 + xx + yy * X] = bit1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
790 g_map[1024 + xx + yy * X + 1] = bit2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
791 okay = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
792 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
793 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
794 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
795
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
796 //if the color is not in the 4x8 area
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
797
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
798 if (okay == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
799 for (metay = 1; metay <= metamax; metay++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
800 if (uses[metay] == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
801 uses[metay] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
802 if (metay == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
803 bit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
804 bit2 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
805 g_map[looks] = byte(fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
806 uses[2] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
807 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
808 if (metay == 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
809 bit1 = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
810 bit2 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
811 g_map[looks + 1000] = byte(fari);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
812 uses[3] = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
813 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
814 if (metay == 3) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
815 bit1 = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
816 bit2 = 1;
179
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
817 if (g_machine == C64M) g_map[looks + 2000] = byte(fari);
934934bb1fbb Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
818 if (g_machine == PLUS4M) g_map[looks + 2000] = byte(zeroc2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
819 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
820 g_map[1024 + xx + yy * X] = bit1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
821 g_map[1024 + xx + yy * X + 1] = bit2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
822 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
823 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
824 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
825
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
826 } //skippo0
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
827
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
828 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
829
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
830 case 2: // VGA style i.e. Amiga, CPC
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
831 fari = g_farge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
832
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
833 if (g_data[int('d')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
834 if (g_map[1024 + xx + yy * X] == byte(g_backg)) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
835 g_map[1024 + xx + yy * X] = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
836 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
837 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
838 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
839 g_map[1024 + xx + yy * X] = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
840 if (g_hzoomer == 2) g_map[1024 + xx + yy * X + 1] = byte(g_farge);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
841 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
842 break;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
843 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
844 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
845
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
846 // end ignore
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
847
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
848 // X Y mirrors & tiler
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
849
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
850 if (g_data[int('t')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
851 if (tiler == 0) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
852 int ex = int(X / g_gridx);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
853 int ey = int(Y / g_gridy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
854 for (int tilx = -(ex); tilx <= ex; tilx++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
855 for (int tily = -(ey); tily <= ey; tily++) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
856 makepoint(20000 + xx + int(X / ex) * tilx, yy + int(Y / ey) * tily);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
857 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
858 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
859 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
860 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
861 }
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
862 if (g_data[int('X')] == 1 && mirrix == 0) makepoint(10000 + (X - 1) - xx, yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
863 if (g_data[int('Y')] == 1 && mirriy == 0) makepoint(xx, 10000 + (Y - 1) - yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
864 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
865 if (mirrix == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
866 makepoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
867 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
868 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
869 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
870
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
871 void clearpoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
872 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
873 if (g_multic == 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
874 g_farge = g_backg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
875 makepoint(xx, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
876 g_farge = g_ofarge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
877 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
878 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
879 if (g_multic == 1) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
880 xx = chop2(xx);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
881 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
882 g_farge = g_backg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
883 makepoint(xx, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
884 g_farge = g_ofarge;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
885 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
886
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
887
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
888 void absolute_clearpoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
889 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
890 int mirrix = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
891 int mirriy = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
892 int ignore = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
893 if (xx >= 10000) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
894 xx = xx - 10000;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
895 mirrix = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
896 mirriy = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
897 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
898 if (yy >= 10000) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
899 yy = yy - 10000;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
900 mirriy = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
901 mirrix = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
902 }
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
903
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
904 if (xx < 0 || yy < 0 || xx >= X || yy >= Y)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
905 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
906
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
907 if (g_multic == 2 && g_hzoomer != 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
908 g_farge = g_backg;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
909 makepoint(xx, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
910 g_farge = g_ofarge;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
911 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
912 }
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
913 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
914 xx = chop2(xx);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
915 }
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
916 if (g_data[int('b')] == 1) return;
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
917
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
918 if (g_data[int('r')] == 1) { //raster
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
919 if (get_raster(xx, yy) == 0) ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
920 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
921
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
922 if (g_data[int('R')] == 1) { //user defined raster
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
923 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
924 int x0 = int(xx / ((g_bsourcex2 + 1) - g_bsourcex));
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
925 int y0 = int(yy / ((g_bsourcey2 + 1) - g_bsourcey));
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
926 int x1 = xx - x0 * ((g_bsourcex2 + 1) - g_bsourcex);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
927 int y1 = yy - y0 * ((g_bsourcey2 + 1) - g_bsourcey);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
928 int xr = g_bsourcex + x1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
929 int yr = g_bsourcey + y1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
930 if (g_brush[1024 + xr + yr * X] == 0) ignore = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
931 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
932 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
933
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
934 if (ignore == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
935 g_map[1024 + xx + yy * X] = byte(0);
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
936 if (g_pixelw == 2) g_map[1024 + xx + yy * X + 1] = byte(0);
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
937 int xc = int(xx / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
938 int yc = int(yy / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
939 g_redo[xc + yc * MX] = byte(0); //block update
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
940 g_remdo[xc + yc * MX] = byte(1); //block update
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
941 }
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
942
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
943 if (g_data[int('X')] == 1 && mirrix == 0) clearpoint(10000 + (X - 1) - xx, yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
944 if (g_data[int('Y')] == 1 && mirriy == 0) clearpoint(xx, 10000 + (Y - 1) - yy);
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
945 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
946 if (mirrix == 0) clearpoint(10000 + (X - 1) - xx, 10000 + (Y - 1) - yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
947 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
948 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
949
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
950
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
951 void simplepaint(int xx, int yy, int mode, int attr)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
952 {
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
953 int ad, swad, miny, maxy, ojyx;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
954 xx = int(xx / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
955 ojyx = chop8(yy);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
956
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
957 ad = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
958 swad = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
959 miny = yy - ojyx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
960 maxy = miny;
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
961
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
962 if (g_attrimode == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
963 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
964 miny = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
965 maxy = 7;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
966 }
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
967
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
968 for (int j = miny; j <= maxy; j++)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
969 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
970 if (mode == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
971 ad = 65536 + xx + (ojyx + j) * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
972 swad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
973 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
974 if (mode == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
975 ad = 65536 + xx + (ojyx + j) * MX + (MX * MY) * 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
976 swad = 65536 + xx + (ojyx + j) * MX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
977 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
978 if (g_britemode == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
979 if (attr == 8) attr = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
980 if (attr > 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
981 if (attr >= 8 && g_map[swad] <= 7) g_map[swad] = byte(g_map[swad] + 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
982 if (attr <= 7 && g_map[swad] >= 8) g_map[swad] = byte(g_map[swad] - 8);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
983 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
984 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
985 g_map[ad] = byte(attr);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
986 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
987 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
988
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
989
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
990 void storecoords(int qqx, int qqy)
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
991 {
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
992 int psizex = g_magpix[magmode()],
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
993 psizey = g_magpiy[magmode()];
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
994
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
995 if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
996 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
997 g_storedcoordx = int(qqx / psizex);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
998 g_storedcoordy = int(qqy / psizey);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
999 }
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1000 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1001 if (g_data[int('m')] == 1 || g_data[int('M')] == 1)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1002 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1003 g_storedcoordx = int(qqx / psizex) + g_ofx * 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1004 g_storedcoordy = int(qqy / psizey) + g_ofy * 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1005 }
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1006 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1007 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1008 g_storedcoordx = int(qqx);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1009 g_storedcoordy = int(qqy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1010 }
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1011 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1012
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1013
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1014 void do_tool(int qqx, int qqy, int mbut)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1015 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1016 storecoords(qqx, qqy);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1017
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1018 int tt = tool(),
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1019 ox = g_storedcoordx,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1020 oy = g_storedcoordy,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1021 x = g_storedcoordx,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1022 y = g_storedcoordy;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1023
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1024 if (g_btype == 9 && tt != 4 && tt != 0 && mbut != 255)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1025 {
146
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1026 x -= int((g_bsourcex2 - g_bsourcex) / 2);
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1027 y -= int((g_bsourcey2 - g_bsourcey) / 2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1028 }
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1029
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1030 if (g_data[int('c')] == 1 || g_shift)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1031 {
146
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1032 x = chopv(x, g_gridx);
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1033 y = chopv(y, g_gridy);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1034 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1035
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1036 if (g_pixelw == 2)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1037 {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1038 x = chop2(x);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1039 ox = chop2(ox);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1040 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1041
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1042 if (mbut == 254)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1043 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1044 //block picker
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1045 switcher(2);
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1046 g_data[int('n')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1047 g_data[int('x')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1048 g_data[int('y')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1049 g_data[int('q')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1050 g_data[int('z')] = 0;
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1051
146
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1052 x = chopv(ox, g_gridx);
bb1602f371d4 Add helper function chopv() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
1053 y = chopv(oy, g_gridy);
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1054
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1055 g_bsourcex = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1056 g_bsourcey = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1057 g_bsourcex2 = x + g_gridx - 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1058 g_bsourcey2 = y + g_gridy - 1;
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1059
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1060 g_btype = 9;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1061 return;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1062 }
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1063 else
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1064 if (mbut == 255) { // color picker
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1065 if (g_multic == 2) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1066 if (g_hzoomer == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1067 ox = chop2(ox);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1068 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1069 selectcolor(0, getmultic(ox, oy, 0));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1070 return;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1071 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1072 selectcolor(0, getabsa(ox, oy, 0));
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
1073 if (g_pixelw == 2) {
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1074 ox = chop2(ox);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1075 selectcolor(0, getattra(ox, oy, 0));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1076 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1077 g_ofarge = g_farge;
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1078 if (g_btype == 9) g_data[int('p')] = 1;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1079 g_realfront = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1080 return;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1081 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1082
9
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
1083 if (x >= 0 && y >= 0 && x < X && y < Y && g_mx < width - g_hedge && g_my < height - g_vedge)
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
1084 help(1000, x, y);
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
1085
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
1086 if (g_phase > 0)
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
1087 help(1000, x, y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1088
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1089 if (tt == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1090 {
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1091 craft(x, y, 0); //pixeller
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1092 }
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1093 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1094 if (tt == 2)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1095 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1096 //spraycan
6
07ddf9cfc6c2 Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
1097 //if(random(100)<50){fixed_raster_command(int('x'));}
07ddf9cfc6c2 Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
1098 //if(random(100)<50){fixed_raster_command(int('y'));}
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1099 for (int i = 0; i <= 12; i++)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1100 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1101 int rx = x - 10 + int(random((10) * 2));
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1102 int ry = y - 10 + int(random((10) * 2));
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1103 if (mbut == LEFT) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1104 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1105 } else {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1106 if (dist(x, y, rx, ry) < 10) craft(rx, ry, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1107 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1108 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1109 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1110 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1111 if (tt == 3)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1112 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1113 //cont line
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1114 if (g_phase == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1115 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1116 g_prex = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1117 g_prey = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1118 craft(x, y, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1119 }
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
1120 do_line(x, y, g_prex, g_prey, 0);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1121 g_prex = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1122 g_prey = y;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1123 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1124 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1125 if (tt == 5)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1126 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1127 //floodfill
174
aa3d05b4dfa5 Fix flood fill. During v1.8.2018 reworks, a boolean check was accidentally reversed.
Matti Hamalainen <ccr@tnsp.org>
parents: 173
diff changeset
1128 if (!g_klikkeri)
143
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
1129 {
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
1130 g_klikkeri = true;
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
1131
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1132 storeparameters();
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1133 g_data[int('X')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1134 g_data[int('Y')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1135 g_data[int('c')] = 0;
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1136 g_data[int('t')] = 0;
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1137
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1138 if (ox >= 0 && ox < X && oy >= 0 & oy < Y)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1139 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1140 store_undo(); // exceptional!
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
1141 if (g_multic)
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1142 floodfill_mc(ox, oy, mbut);
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
1143 else
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1144 floodfill_iq(ox, oy, mbut);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1145 }
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
1146 else
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
1147 changeborder(mbut);
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
1148
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1149 restoreparameters();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1150 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1151 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1152 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1153 if (tt == 6 || tt == 7 || tt == 8)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1154 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1155 //line,circle,rect
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1156 if (g_phase == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1157 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1158 g_rx = g_rx2 = x;
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1159 g_ry = g_ry2 = y;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1160 g_rubbermode = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1161 }
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1162 else
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1163 if (g_phase == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1164 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1165 g_rx2 = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1166 g_ry2 = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1167 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1168 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1169 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1170 if (tt == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1171 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1172 // magnifier graphic tool
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1173 g_data[int('m')] = 1;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1174 g_orx = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1175 g_ory = y;
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1176 g_rx = x - int(magx() / 2) * 8;
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1177 g_ry = y - int(magy() / 2) * 8;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1178 g_rx2 = x + (int(magx() / 2) + odd(magx())) * 8;
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1179 g_ry2 = y + (int(magy() / 2) + odd(magy())) * 8;
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1180 g_data[int('m')] = 0;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1181
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1182 if (g_phase == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1183 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1184 g_rubbermode = 0;
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1185 g_data[int('m')] = 1;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1186 set_tool(g_prevtool);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1187 g_phase = 0;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1188
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1189 g_ofx = int(x / 8) - int(magx() / 2);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
1190 g_ofy = int(y / 8) - int(magy() / 2);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1191 refresh();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1192 g_repanel = -2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1193 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1194 else
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1195 g_rubbermode = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1196 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1197 else
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1198 if (tt == 4)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1199 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1200 //brush grabber grab brush
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1201 if (g_phase == 0) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1202 g_rx = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1203 g_orx = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1204 g_ry = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1205 g_ory = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1206 g_rx2 = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1207 g_ry2 = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1208 }
70
8cee0b34defe Attempt to optimize makepoint() slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 44
diff changeset
1209 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1210 if (g_phase == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1211 g_rx2 = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1212 g_rx = g_orx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1213 g_ry2 = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1214 g_ry = g_ory;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1215 if (x < g_orx) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1216 g_rx2 = g_orx;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1217 g_rx = x;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1218 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1219 if (y < g_ory) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1220 g_ry2 = g_ory;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1221 g_ry = y;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1222 }
4
a1261cd4c676 Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
1223 if (g_data[int('c')] == 1 || g_shift) {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1224 g_rx2--;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1225 g_ry2--;
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
1226 if (g_pixelw == 2) g_rx2--;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1227 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1228 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1229 g_rubbermode = 1;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1230 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1231
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1232 if (tt == 0 || tt == 4)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1233 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1234 if (g_rubbermode == 1) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1235 for (int xx = g_rx; xx <= g_rx2 + 2; xx++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1236 updatepoint(xx, g_ry);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1237 updatepoint(xx, g_ry2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1238 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1239 for (int yy = g_ry; yy <= g_ry2; yy++) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1240 updatepoint(g_rx, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1241 updatepoint(g_rx2, yy);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1242 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1243 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1244 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1245 }