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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1 // Collect all that "writes" the virtual image in some way or other
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
2 // plus other active manipulations
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
3
156
5d73681b97eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
4 int clampv(int v, int vmin, int vmax)
154
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
5 {
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
6 return (v < vmin) ? vmin : (v > vmax ? vmax : v);
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
7 }
1b2cbf3ab441 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
8
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
9 int chop2(int v)
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
10 {
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
24
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
25 void createpoint(int x, int y, int mo)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
26 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
27 if (mo == LEFT) makepoint(x, y);
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
28 else
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
29 if (mo == RIGHT) clearpoint(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
31
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
32
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
33 void doborx(int xf, int yf, int xt, int yt)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
34 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
35 //rectangle for brush drawing
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
36 for (int ii = xf; ii <= xt; ii++)
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
37 for (int jj = yf; jj <= yt; jj++)
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
38 createpoint(ii, jj, g_button);
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
39 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
40
71
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
41
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
42 void docircx(int xf, int yf, int hh, int vv)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
43 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44 //circle for brush drawing
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
45 float prop, fh = hh, fv = vv;
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
46
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
47 if (vv > 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
50 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
51 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
56
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
57 for (int ii = -hh; ii <= hh; ii++)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
58 for (int jj = -vv; jj <= vv; jj++)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
59 {
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
60 if (dist(xf + ii, yf + jj * prop, xf, yf) <= hh - 1)
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
65
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
66 void craft(int x, int y, int c)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
75 if (g_btype == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
76 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
77 if (g_bsize < 4)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
80 switch (g_bsize)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
86 if (g_data[int('c')] == 1 || g_shift == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
94 if (g_data[int('c')] == 1 || g_shift == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
102 if (g_data[int('c')] == 1 || g_shift == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
110 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
111 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
121 if (g_btype == 9)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
130 if (g_data[int('t')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
137 if (g_data[int('c')] == 1 || g_shift == true)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
138 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
139 if (g_data[int('q')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
146 int orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')];
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
147 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
153 for (int pp = 1; pp <= passes; pp++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
154 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
155 for (int yy = tempoy; yy <= tempy; yy = yy + moloy)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
156 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
157 for (int xx = tempox; xx <= tempx; xx = xx + g_pixelw)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
162 if (s1 != g_backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
167 if (g_data[int('q')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
177 if (g_data[int('x')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
184 if (g_data[int('y')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
191 if (g_data[int('c')] == 1 || g_shift)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
197 if (orient == 110)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
202 if (orient == 111)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
209 if (mb == LEFT)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
210 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
211 if (g_multic > 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
215 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
218 if (g_data[int('q')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
223 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
224 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
228 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
229 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
232 if (zxcolor(g_farge) != zxcolor(g_backg))
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
240 if (mb == RIGHT)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
241 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
242 if (g_multic > 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
243 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
244 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
247 if (g_data[int('q')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
252 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
253 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
257 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
258 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
271 if (g_bsize < 4)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
272 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
273 switch (g_bsize)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
295 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
296 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
305
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
306 void do_line(int xfrom, int yfrom, int xto, int yto, int prevent)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
312 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
324 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
337 if (steep)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
357 if (x0 < x1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
360 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
361 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
365 if (y0 < y1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
368 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
369 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
375 while (x != x1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
376 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
377 if (steep)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
378 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
379 if (y * g_pixelw != pex || x != pey)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
385 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
386 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
387 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
388 if (x * g_pixelw != pex || y != pey)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
397 if (error < 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
406 void do_circle_new(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
422 if (vv > 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
425 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
426 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
431 for (int ii = -hh; ii <= hh; ii++)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
432 for (int jj = -vv; jj <= vv; jj++)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
433 {
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
434 if (dist(xf + ii, yf + jj * prop, xf, yf) <= hh - 1)
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
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
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
439
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
440 void do_circle(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
457 if (g_data[int('f')] == 1 && g_btype != 9)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
458 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
459 if (g_multic == 1 && g_data[int('d')] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
470 for (t = 0; t <= (gear2); t++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
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
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
481
150
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
482 void do_rectangle(int x1, int y1, int x2, int y2)
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
494
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
495 if (x2 < x1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
501 if (y2 < y1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
511 if (g_btype != 9)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
512 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
513 if (g_data[int('c')] == 1 || g_shift)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
520 if (g_data[int('f')] == 1 && g_btype != 9)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
521 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
522 if (g_multic == 1 && g_data[int('d')] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
525 for (int y = y1; y <= y2; y++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
526 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
527 for (int x = x1; x <= x2; x = x + g_pixelw)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
528 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
529 if (x >= xf && y >= yf && x <= xt && y <= yt)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
538 for (int y = y1; y <= y2; y++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
539 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
540 for (int x = x1; x <= x2; x = x + g_pixelw)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
546 if (g_data[int('f')] == 0 || g_btype == 9)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
547 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
548 if (g_data[int('c')] == 1 && g_btype == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
549 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
550 if (x2 > x1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
557 if (y2 > y1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
565 do_line(x1, y1, x2, y1, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
566 do_line(x1, y1, x1, y2, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
567 do_line(x1, y2, x2, y2, 0);
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
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
15556815ebe2 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
573
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
574 void makepoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
588 if (xx >= 20000)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
595 if (xx >= 10000)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
601 if (yy >= 10000)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
607
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
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
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
611 if (int(g_map[12]) != 5)
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
612 {
8
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
613 if (g_multic == 2)
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
614 {
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
615 skaveri(xx, yy, g_farge, 0);
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
616 }
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
617 else
f97ee354db2a Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
618 {
173
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
619 if (g_data[int('b')] == 0)
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
620 {
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
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
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
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
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
625 }
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
626 else
9bbed9b6df8d Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
634 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
639 if (g_data[int('r')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
644 if (g_data[int('R')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
645 { //user defined raster
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
646 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
655 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
666 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
667 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
677 if (ignore == 0 && g_data[int('d')] == 1 && g_attrimode <= 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
682 if (g_multic == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
688
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
689 if (g_attrimode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
698 if (g_farge == baba && g_farge == aba)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
699 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
700 for (jj = miny; jj <= maxy; jj++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
701 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
702 for (ii = 0; ii < 8; ii++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
708 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
709 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
710 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
711 if (aba == g_backg)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
714 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
715 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
726 if (ignore == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
733 switch (g_multic)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
740 if (getattra(xx, yy, 1) == 0 && fari == g_map[1])
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
743 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
744 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
745 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
746 if (getattra(xx, yy, 1) == fari)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
749 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
750 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
761 if (g_attrimode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
767 for (int j = miny; j <= maxy; j++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
768 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
769 for (int i = 0; i < 8; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
775 for (int j = miny; j <= maxy; j++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
776 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
777 for (int i = 0; i < 8; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
782 if (mac == maxos)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
783 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
784 for (int j = miny; j <= maxy; j++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
787 for (int i = 0; i < 8; i++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
794 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
795 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
812 if (fari == zeroc)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
818 if (g_machine == PLUS4M && fari == zeroc2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
824 if (cut)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
827 if (g_data[int('t')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
828 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
829 if (tiler == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
833 for (int tilx = -ex; tilx <= ex; tilx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
834 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
835 for (int tily = -ey; tily <= ey; tily++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
845 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
846 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
847 if (mirrix == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
870 for (metay = 0; metay <= 7; metay++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
871 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
872 for (metax = 0; metax <= 3; metax++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
879 if (pars == 3)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
894 if (uses[0] == 1 && uses[1] == 1 && uses[2] == 1 && uses[3] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
899 if (skippo == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
907 for (metay = 0; metay <= metamax; metay++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
908 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
909 if (uses[metay] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
910 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
911 if (fars[metay] == fari)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
912 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
913 if (metay == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
919 if (metay == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
925 if (metay == 3)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
941 if (okay == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
942 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
943 for (metay = 1; metay <= metamax; metay++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
944 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
945 if (uses[metay] == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
948 if (metay == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
955 if (metay == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
962 if (metay == 3)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
982 if (g_data[int('d')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
983 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
984 if (g_map[1024 + xx + yy * X] == byte(g_backg))
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
989 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
990 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1003 if (g_data[int('t')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1004 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1005 if (tiler == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1009 for (int tilx = -(ex); tilx <= ex; tilx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1010 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1011 for (int tily = -(ey); tily <= ey; tily++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1021 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1022 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1023 if (mirrix == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1030 void clearpoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1031 {
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1032 if (g_multic == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1039 if (g_multic == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1049 void absolute_clearpoint(int xx, int yy)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1054 if (xx >= 10000)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1060 if (yy >= 10000)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1066
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1067 if (xx < 0 || yy < 0 || xx >= X || yy >= Y)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1068 return;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1069
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1070 if (g_multic == 2 && g_hzoomer != 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1077 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1082
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1083 if (g_data[int('r')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1088 if (g_data[int('R')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1089 { //user defined raster
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1090 if (g_bsourcex2 > g_bsourcex && g_bsourcey2 > g_bsourcey)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1102 if (ignore == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1114 if (g_data[int('X')] == 1 && g_data[int('Y')] == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1120
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1121 void simplepaint(int xx, int yy, int mode, int attr)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1122 {
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1131
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1132 if (g_attrimode == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1137
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1138 for (int j = miny; j <= maxy; j++)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1139 {
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1140 if (mode == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1145 if (mode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1150 if (g_britemode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1153 if (attr > 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1163
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1164 void storecoords(int qqx, int qqy)
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1165 {
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1166 int psizex = g_magpix[magmode()],
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
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
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1169 if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1170 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1171 g_storedcoordx = int(qqx / psizex);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1172 g_storedcoordy = int(qqy / psizey);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1173 }
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1174 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1175 if (g_data[int('m')] == 1 || g_data[int('M')] == 1)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1176 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1177 g_storedcoordx = int(qqx / psizex) + g_ofx * 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1178 g_storedcoordy = int(qqy / psizey) + g_ofy * 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1179 }
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1180 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1181 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1182 g_storedcoordx = int(qqx);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
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
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1185 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
1186
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1187
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1188 void do_tool(int qqx, int qqy, int mbut)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1189 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1190 storecoords(qqx, qqy);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
1191
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1192 int tt = tool(),
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1193 ox = g_storedcoordx,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1194 oy = g_storedcoordy,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1195 x = g_storedcoordx,
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1196 y = g_storedcoordy;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1197
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1198 if (g_btype == 9 && tt != 4 && tt != 0 && mbut != 255)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1203
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1204 if (g_data[int('c')] == 1 || g_shift)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1210 if (g_pixelw == 2)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1216 if (mbut == 254)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1217 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
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
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1237 else
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1238 if (mbut == 255)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1239 { // color picker
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1240 if (g_multic == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1241 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1242 if (g_hzoomer == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1250 if (g_pixelw == 2)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1267 if (tt == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1272 if (tt == 2)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1273 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1277 for (int i = 0; i <= 12; i++)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1281 if (mbut == LEFT)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1284 }
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1285 else
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1292 if (tt == 3)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1293 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1294 //cont line
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1295 if (g_phase == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
d7c13f427178 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1306 if (tt == 5)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1307 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
1310 {
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
1311 g_klikkeri = true;
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
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
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1318
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
1319 if (ox >= 0 && ox < X && oy >= 0 & oy < Y)
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
1322 if (g_multic)
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
1323 floodfill_mc(ox, oy, mbut);
44
041cb75875af Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
1324 else
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1334 if (tt == 6 || tt == 7 || tt == 8)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1335 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1336 //line,circle,rect
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1337 if (g_phase == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1338 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1339 g_rx = g_rx2 = x;
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1343 else
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1344 if (g_phase == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1351 if (tt == 0)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1352 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1357 g_rx = x - int(magx() / 2) * 8;
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
1362
147
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1363 if (g_phase == 1)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1379 if (tt == 4)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1380 {
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1381 //brush grabber grab brush
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1382 if (g_phase == 0)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1392 if (g_phase == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1398 if (x < g_orx)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1403 if (y < g_ory)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1408 if (g_data[int('c')] == 1 || g_shift)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1418 if (tt == 0 || tt == 4)
9ad847dcd8e3 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
1419 {
225
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1420 if (g_rubbermode == 1)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1421 {
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1422 for (int xx = g_rx; xx <= g_rx2 + 2; xx++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
1427 for (int yy = g_ry; yy <= g_ry2; yy++)
1c9deae71fb1 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
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 }