-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmReleased.pde
More file actions
322 lines (313 loc) · 10.5 KB
/
mReleased.pde
File metadata and controls
322 lines (313 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//*********************************
void mouseReleased()
//*********************************
{
//int mx, my;
//mx = mouseX;
//my = mouseY;
// terminate confetti tool render drawing
if (tool == "Confetti")
{
while(confettiThings.size() > 0)
{
livelli[activeLyr].pg.beginDraw(); // open active layer PGraphics
livelli[activeLyr].pg.noStroke();
livelli[activeLyr].pg.fill(brushCol);
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
for (int i=0, sz=confettiThings.size(); i<sz; i++)
{
ConfettiBase c = (ConfettiBase)confettiThings.get(i);
c.move();
if (c.alive()) { c.paint(); }
else
{
confettiThings.remove(c);
i--;
sz--;
}
}
livelli[activeLyr].pg.endDraw();
}
}
if(startAction) // started an action who has modified the active layer --> reset REDO
{
startAction = false;
// reset redo
for( int i=0; i< numRedo; i++)
{ redoLyr[i] = -1; }
}
// unlock slider (size,alfa,gap,threshold,...)
slSIZE.locked = false;
slALFA.locked = false;
slSTAMP.locked = false;
slSTAMP2.locked = false;
slFILLER.locked = false;
slMIXERA.locked = false;
slMIXERD.locked = false;
slWEBA.locked = false;
slWEBD.locked = false;
slCONFVEL.locked = false;
slCONFDVEL.locked = false;
// unlock dyna slider
dslHOOKE.locked = false;
dslDAMPING.locked = false;
dslDUCTUS.locked = false;
dslMASS.locked = false;
dslMINB.locked = false;
dslMAXB.locked = false;
// unlock Shape slider
slSHitems.locked = false;
slSHsizeD.locked = false;
slSHalfaD.locked = false;
slSHposD.locked = false;
// unlock new tools slider
slALPHAT.locked = false;
slRGBr.locked = false;
slRGBg.locked = false;
slRGBb.locked = false;
slHSBh.locked = false;
slHSBs.locked = false;
slHSBb.locked = false;
slRNDa.locked = false;
slRNDr.locked = false;
slRNDg.locked = false;
slRNDb.locked = false;
// check if drawing with Liner
if ((lineDown) && (tool=="Liner"))
{
lineDown = false;
if (grab) { grabLayer(); } // before start drawing: grab the canvas image for undo
livelli[activeLyr].pg.beginDraw(); // open PGraphics
//livelli[activeLyr].pg.strokeCap(SQUARE);
livelli[activeLyr].pg.noFill();
livelli[activeLyr].pg.stroke(brushCol);
livelli[activeLyr].pg.strokeWeight(brushSize);
if (noGlitch) { prepareGlitch(); } // Start antialias...
if (snap2Grid)
{
x1L = gridX * (int)round((float)x1L / gridX);
y1L = gridY * (int)round((float)y1L / gridY);
x2L = gridX * (int)round((float)x2L / gridX);
y2L = gridY * (int)round((float)y2L / gridY);
}
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
livelli[activeLyr].pg.line(x1L, y1L, x2L, y2L); // draw on active layer
if (symX) // draw symmetry from X axis
{
calcSymX(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.line(s1x, s1y, s2x, s2y);
}
if (symY) // draw symmetry from Y axis
{
calcSymY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.line(s1x, s1y, s2x, s2y);
}
if(symX && symY) // draw symmetry from center point (opposite)
{
calcSymXY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.line(s1x, s1y, s2x, s2y);
}
livelli[activeLyr].pg.strokeWeight(1);
livelli[activeLyr].pg.endDraw(); // close PGraphics
}
// check if drawing with Quad
else if ((quadDown) && (tool=="Quad"))
{
quadDown = false;
if (grab) { grabLayer(); } // before start drawing: grab the canvas image for undo
livelli[activeLyr].pg.beginDraw(); // open PGraphics
//livelli[activeLyr].pg.strokeJoin(ROUND);
livelli[activeLyr].pg.noFill();
livelli[activeLyr].pg.stroke(brushCol);
livelli[activeLyr].pg.strokeWeight(brushSize);
if (noGlitch) { prepareGlitch(); } // Start antialias...
if (quadLock) // draw square
{
if (snap2Grid)
{
x1L = gridX * (int)round((float)x1L / gridX);
y1L = gridY * (int)round((float)y1L / gridY);
x2L = gridX * (int)round((float)x2L / gridX);
y2L = gridY * (int)round((float)y2L / gridY);
}
int dd = max(abs(x2L-x1L), abs(y2L-y1L));
int qx1 ,qy1, qx2, qy2;
qx1 = 0; qy1 = 0; qx2 = 0; qy2 = 0;
if (x2L > x1L)
{
if (y2L > y1L) { qx1 = x1L; qy1 = y1L; qx2 = x1L + dd; qy2 = y1L + dd; } // lower left
else { qx1 = x1L; qy1 = y1L - dd; qx2 = x1L + dd; qy2 = y1L; } // upper left
}
else // (x1L > x2L)
{
if (y2L > y1L) { qx1 = x1L - dd; qy1 = y1L; qx2 = x1L; qy2 = y1L + dd; } // lower right
else { qx1 = x1L - dd; qy1 = y1L - dd; qx2 = x1L ; qy2 = y1L; } // upper right
}
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
livelli[activeLyr].pg.rect(qx1,qy1, qx2 - qx1, qy2 - qy1); // draw on active layer
if (symX) // draw symmetry from X axis
{
calcSymX(qx1,qy1,qx2,qy2);
livelli[activeLyr].pg.rect(s1x, s1y, s2x - s1x, s2y - s1y);
}
if (symY) // draw symmetry from Y axis
{
calcSymY(qx1,qy1,qx2,qy2);
livelli[activeLyr].pg.rect(s1x, s1y, s2x - s1x, s2y - s1y);
}
if(symX && symY) // draw symmetry from center point (opposite)
{
calcSymXY(qx1,qy1,qx2,qy2);
livelli[activeLyr].pg.rect(s1x, s1y, s2x - s1x, s2y - s1y);
}
}
else // draw rect
{
if (snap2Grid)
{
x1L = gridX * (int)round((float)x1L / gridX);
y1L = gridY * (int)round((float)y1L / gridY);
x2L = gridX * (int)round((float)x2L / gridX);
y2L = gridY * (int)round((float)y2L / gridY);
}
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
livelli[activeLyr].pg.rect(x1L,y1L,x2L-x1L,y2L-y1L);
if (symX) // draw symmetry from X axis
{
calcSymX(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.rect(s1x, s1y, s2x-s1x, s2y-s1y);
}
if (symY) // draw symmetry from Y axis
{
calcSymY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.rect(s1x, s1y, s2x-s1x, s2y-s1y);
}
if(symX && symY) // draw symmetry from center point (opposite)
{
calcSymXY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.rect(s1x, s1y, s2x-s1x, s2y-s1y);
}
}
livelli[activeLyr].pg.strokeWeight(1);
livelli[activeLyr].pg.endDraw(); // close PGraphics
}
// check if drawing with Circle
else if ((circleDown) && (tool=="Circle"))
{
circleDown = false;
if (grab) { grabLayer(); } // before start drawing: grab the canvas image for undo
livelli[activeLyr].pg.beginDraw();
livelli[activeLyr].pg.noFill();
livelli[activeLyr].pg.stroke(brushCol);
livelli[activeLyr].pg.strokeWeight(brushSize);
if (noGlitch) { prepareGlitch(); } // Start antialias...
if (circleLock) // draw circle
{
if (snap2Grid)
{
x1L = gridX * (int)round((float)x1L / gridX);
y1L = gridY * (int)round((float)y1L / gridY);
x2L = gridX * (int)round((float)x2L / gridX);
y2L = gridY * (int)round((float)y2L / gridY);
}
float dd = dist(x1L,y1L,x2L,y2L)*2;
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
livelli[activeLyr].pg.ellipse(x1L, y1L, dd, dd);
if (symX) // draw symmetry from X axis
{
calcSymX(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse(s1x, s1y, dd, dd);
}
if (symY) // draw symmetry from Y axis
{
calcSymY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse(s1x, s1y, dd, dd);
}
if(symX && symY) // draw symmetry from center point (opposite)
{
calcSymXY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse(s1x, s1y, dd, dd);
}
}
else // draw ellipse
{
if (aSelection) { livelli[activeLyr].pg.clip(x1sel+1, y1sel+1, x2sel-x1sel-1, y2sel-y1sel-1); } // check selection
livelli[activeLyr].pg.ellipse((x1L+x2L)/2, (y1L+y2L)/2, (x1L-x2L), (y1L-y2L));
if (symX) // draw symmetry from X axis
{
calcSymX(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse((s1x+s2x)/2, (s1y+s2y)/2, (s1x-s2x), (s1y-s2y));
}
if (symY) // draw symmetry from Y axis
{
calcSymY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse((s1x+s2x)/2, (s1y+s2y)/2, (s1x-s2x), (s1y-s2y));
}
if(symX && symY) // draw symmetry from center point (opposite)
{
calcSymXY(x1L,y1L,x2L,y2L);
livelli[activeLyr].pg.ellipse((s1x+s2x)/2, (s1y+s2y)/2, (s1x-s2x), (s1y-s2y));
}
}
livelli[activeLyr].pg.strokeWeight(1);
livelli[activeLyr].pg.endDraw(); // close PGraphics
}
// check if drawing with Select
else if ((selectDown) && (tool=="Select"))
{
selectDown = false;
if (snap2Grid)
{
x1L = gridX * (int)round((float)x1L / gridX);
y1L = gridY * (int)round((float)y1L / gridY);
x2L = gridX * (int)round((float)x2L / gridX);
y2L = gridY * (int)round((float)y2L / gridY);
}
// reorder rect coords
if (x1L < x2L) { x1sel = x1L; x2sel = x2L; }
else { x1sel = x2L; x2sel = x1L; }
if (y1L < y2L) { y1sel = y1L; y2sel = y2L; }
else { y1sel = y2L; y2sel = y1L; }
// check oustide coords
x1sel = constrain(x1sel,0,width-1);
x2sel = constrain(x2sel,0,width-1);
y1sel = constrain(y1sel,0,height-1);
y2sel = constrain(y2sel,0,height-1);
// check null selection
if ((x1sel == x2sel) || (y1sel == y2sel))
{ aSelection = false; }
else { aSelection = true; }
// update SELECT checkbox
cbSELECT.s = aSelection;
}
// clone tool
if (tool=="Clone")
{
// check null distance
if (gapX!=0 && gapY!=0)
{
cloneGap = !cbCLONE.s;
}
}
// UNDO ACTION - check if there is an UNDO image to memorize
if (!grab) // push grabbed image on undoPG array
{
for(int i = numUndo-1; i > 0; i--)
{
copyPG2PG(undoPG[i-1], undoPG[i]);
undoLyr[i] = undoLyr[i-1];
}
copyPG2PG(grabPG,undoPG[0]);
undoLyr[0] = grabLyr;
grab = true;
}
// ...terminate antialias glitch
if (noGlitch && startGlitch) { finalizeGlitch(); }
// update swatch of current layer
livelli[activeLyr].updateLayerSwatch();
// update undo/redo button
if (undoLyr[0] == -1) { btnUNDO.s = false; }
else { btnUNDO.s = true; }
if (redoLyr[0] == -1) { btnREDO.s = false; }
else { btnREDO.s = true; }
}