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