-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTouch_Screen1.pde
87 lines (71 loc) · 1.93 KB
/
Touch_Screen1.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
int gridSize = 50; //set grid size.
Thread thread; // declare Thread object
Stitch stitch; // declare Stitch object
ArrayList<Stitch> stitches = new ArrayList<Stitch>(); // declare Stitch ArryList
void setup() {
fullScreen();
noFill();
thread = new Thread(); //run constructor? does thread have a constructor?
stitch = new Stitch(); // run constructors
// do I need to start with an index on the array??
// stitches.add(new Stitch());
}
void draw() {
background(255);
// redraw all stitches??
for (int i = 0; i < stitches.size(); i++) {
stitches.get(i).display();
}
// calls previous stitch??
for (int i = 0; i < stitches.size(); i++){
stitches.get(stitches.size()-1);
}
// thread moves with mouse and snapps to grid when released
if (mousePressed) {
thread.x1 = stitch.x2;
thread.y1 = stitch.y2;
thread.x2 = mouseX;
thread.y2 = mouseY;
} else {
thread.x1 = stitch.x2;
thread.y1 = stitch.y2;
thread.x2 = int(thread.x2/gridSize)*gridSize;
thread.y2 = int(thread.y2/gridSize)*gridSize;
stitches.add(new Stitch());
stitch.display();
}
// draws grid
strokeWeight(0.01);
for (int i = 0; i < width/gridSize; i++)
line(i*gridSize, 0, i*gridSize, height); // vertical
for (int i = 0; i < height/gridSize; i++)
line(0, i*gridSize, width, i*gridSize); // horizontal
// draws thread line
strokeWeight(3);
line(thread.x1, thread.y1, thread.x2, thread.y2);
}
class Thread {
float x1;
float y1;
float x2;
float y2;
}
class Stitch {
float x1;
float y1;
float x2;
float y2;
//CONSTRUCTOR?? - this create a 'no constructor' error - is it somewhere else??
/* Stitch (float x1Temp, float y1Temp, float x2Temp, float y2Temp) {
x1 = x1Temp;
y1 = y1Temp;
x2 = x2Temp;
y2 = y2Temp;
}*/
// maybe a method for updating the variables??
// draw method
void display(){
strokeWeight(3);
line (x1, y1, x2, y2);
}
}