-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTools.pde
189 lines (161 loc) · 5.97 KB
/
Tools.pde
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
abstract class Tool { //Main Class for tools
PImage icon;
abstract void useTool(); //Function which gets called whenever a mouse is pressed/moved/released and a tool is selected
public Tool(PImage icon) {
this.icon = icon;
}
}
class Brush extends Tool {
void useTool() {
if (isOnCanvas()) {
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
float distX = ((mouseX - centerX)/scaleAmount) - transAmountX;
float distY = ((mouseY - centerY)/scaleAmount) - transAmountY;
currentProject.layers.get(selectedLayer).layer.add(new CircleElement(int(distX), int(distY), currentBrushThickness, currentBrushThickness, currentProject.canvas, currentFill, currentFill));
}
}
public Brush(PImage tool) {
super(tool);
}
}
class Eraser extends Tool {
void useTool() {
if (isOnCanvas()) {
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
float distX = ((mouseX - centerX)/scaleAmount) - transAmountX;
float distY = ((mouseY - centerY)/scaleAmount) - transAmountY;
currentProject.layers.get(selectedLayer).layer.add(new CircleElement(int(distX), int(distY), currentBrushThickness, currentBrushThickness, currentProject.canvas, color(#ffffff), color(#ffffff)));
}
}
public Eraser(PImage tool) {
super(tool);
}
}
class Line extends Tool {
int x1;
int x2;
int y1;
int y2;
boolean lineInProgress = false;
public Line(PImage tool) {
super(tool);
}
void useTool() {
if (mousePressed && !lineInProgress) {
lineInProgress = true;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
x1 = int(((mouseX - centerX)/scaleAmount) - transAmountX);
y1 = int(((mouseY - centerY)/scaleAmount) - transAmountY);
} else if (!mousePressed && lineInProgress) {
lineInProgress = false;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
x2 = int(((mouseX - centerX)/scaleAmount) - transAmountX);
y2 = int(((mouseY - centerY)/scaleAmount) - transAmountY);
currentProject.layers.get(selectedLayer).layer.add(new LineElement(x1, y1, x2, y2, currentProject.canvas, currentStroke, currentBrushThickness));
}
}
}
class Circle extends Tool {
int x;
int y;
int xSize;
int ySize;
boolean circleInProgress = false;
public Circle(PImage tool) {
super(tool);
}
void useTool() {
if (mousePressed && !circleInProgress) {
circleInProgress = true;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
x = int(((mouseX - centerX)/scaleAmount) - transAmountX);
y = int(((mouseY - centerY)/scaleAmount) - transAmountY);
} else if (!mousePressed && circleInProgress) {
circleInProgress = false;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
int x2 = int(((mouseX - centerX)/scaleAmount) - transAmountX);
int y2 = int(((mouseY - centerY)/scaleAmount) - transAmountY);
if (keyPressed && keyCode == 18) {
xSize = int(dist(x, y, x2, y2));
xSize = ySize;
} else {
xSize = x2 - x;
ySize = y2 - y;
}
currentProject.layers.get(selectedLayer).layer.add(new CircleElement(x, y, xSize, ySize, currentProject.canvas, currentFill, currentStroke));
}
}
}
class Rect extends Tool {
int x;
int y;
int xSize;
int ySize;
boolean rectInProgress = false;
public Rect(PImage tool) {
super(tool);
}
void useTool() {
if (mousePressed && !rectInProgress) {
rectInProgress = true;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
x = int(((mouseX - centerX)/scaleAmount) - transAmountX);
y = int(((mouseY - centerY)/scaleAmount) - transAmountY);
} else if (!mousePressed && rectInProgress) {
rectInProgress = false;
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
int x2 = int(((mouseX - centerX)/scaleAmount) - transAmountX);
int y2 = int(((mouseY - centerY)/scaleAmount) - transAmountY);
if (keyPressed && keyCode == 18) {
xSize = int(dist(x, y, x2, y2));
xSize = ySize;
} else {
xSize = x2 - x;
ySize = y2 - y;
}
currentProject.layers.get(selectedLayer).layer.add(new RectElement(x, y, xSize, ySize, currentProject.canvas, currentFill, currentStroke));
}
}
}
class Text extends Tool {
Text(PImage tool) {
super(tool);
}
void useTool() {
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
int x = int(((mouseX - centerX)/scaleAmount) - transAmountX);
int y = int(((mouseY - centerY)/scaleAmount) - transAmountY);
String text = booster.showTextInputDialog("What text would you like in this text box?");
if (text == null) {
return;
}
currentProject.layers.get(selectedLayer).layer.add(new TextElement(currentProject.canvas, x, y, test[int(d2.getValue())], currentFill, text, createFont(PFont.list()[int(d1.getValue())], int(d3.getValue())*5+1), int(d3.getValue())));
}
}
class TCketManage extends Tool {
TCketManage(PImage tool) {
super(tool);
}
void useTool() {
float centerX = ((width/2 - 100));
float centerY = ((height/2 + 25));
int x = int(((mouseX - centerX)/scaleAmount) - transAmountX);
int y = int(((mouseY - centerY)/scaleAmount) - transAmountY);
if (currentProject.layers.get(0).LayerName.equals("tCketLayer")) {
currentProject.layers.get(0).layer.set(0, new TCketField(currentProject.canvas, x, y, currentFill, createFont(PFont.list()[int(d1.getValue())], int(d3.getValue())*5+1), int(d3.getValue()), test[int(d2.getValue())]));
} else {
currentProject.layers.add(0, new Layer("tCketLayer", currentProject.canvas));
currentProject.layers.get(0).layer.add(0, new TCketField(currentProject.canvas, x, y, currentFill, createFont(PFont.list()[int(d1.getValue())], int(d3.getValue())*5+1), int(d3.getValue()), test[int(d2.getValue())]));
selectedLayer = 1;
}
}
}