-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDrawBackFork_Flow_Lines.pde.BASE.15020.pde
120 lines (106 loc) · 2.8 KB
/
DrawBackFork_Flow_Lines.pde.BASE.15020.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
ArrayList <Line> allLines = new ArrayList<Line>();
Line curLine;
ArrayList <Line> stack = new ArrayList<Line>(); //keep track of the drawBack stack
float probRandom; //the amount of time that the drawBack will interject randomness
float degreeRandom; //how much fluctuation is introduced in random interjections
int i; //iteration count for stack
Decision_Engine engine;
void setup()
{
size(600, 600);
background(255);
fill(0);
strokeWeight(1);
smooth();
i = 0;// initialize the count for the
frameRate(20);
probRandom = .15;
degreeRandom = 5;
colorMode(HSB, 100, 100, 100);
}
void draw()
{
//could have a stack of lines that need to be processed
checkStack();
}
//##### Event Handling
void mousePressed()
{
//line(pmouseX, pmouseY, mouseX, mouseY);
curLine = new Line(mouseX, mouseY);
allLines.add(curLine);
}
void mouseDragged()
{
line(pmouseX, pmouseY, mouseX, mouseY);
//check if the slope has not change by 90 degrees
//if so set line end to previous point and begin new line with current point add previous line to stack
curLine.curEnd(mouseX, mouseY);
}
void mouseReleased()
{
line(pmouseX, pmouseY, mouseX, mouseY);
curLine.setEnd(mouseX, mouseY);
if (key == 'f')
generateFlowLines();
engine = new Decision_Engine(curLine);
engine.decision();
//printAllLines();
}
void keyPressed(){
if(key == 'c'){
clear();}
}
void clear(){
allLines = new ArrayList<Line>();
background(100);}
void generateFlowLines()
{
//cycle through all lines to determine their flow lines
for(int i = 0; i < allLines.size(); i++)
{
Line curLine = allLines.get(i);
curLine.generateFlowLines();
}
}
void translation(){
for(int i = 0; i < allLines.size(); i++){
Line curLine = allLines.get(i);
// Line_Mod mod = new Line_Mod(curLine);
Line newLine;
// newLine = mod.translation();
//newLine.drawLine();
}
}
void changeMode (String mode)
{
//change the mode of the sketch
//this information is coming from the button
}
//######## Random DrawBack Mode
void checkStack()
{
if (stack.size() >= 1)
{
//println("i: " + i + "Size of allPoints: " + stack.get(0).allPoints.size());
if (i < stack.get(0).allPoints.size())
{
//println("Size: " + stack.size() + "i: " + i);
//start the i at 0
//look at the
float x1 = stack.get(0).allPoints.get(i).x;
float y1 = stack.get(0).allPoints.get(i).y;
float x2 = stack.get(0).allPoints.get(i + 1).x;
float y2 = stack.get(0).allPoints.get(i + 1).y;
//println("x1: " + x1 + "y1: " + y1 + "x2: " + x2 + "y2: " + y2);
line (x1, y1, x2, y2);
i++;
if (i == stack.get(0).allPoints.size() - 1)
{
println("Completed line response");
stack.remove(0);
i = 0; //reset the counter
}
}
}
}