-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSHUAIBAOLE.pde
61 lines (48 loc) · 1.4 KB
/
SHUAIBAOLE.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
/* Template
Bronze exercise
Lab 07 - COMP 1010
Draw a spiral in the canvas that rotates
*/
float aa = 0;
float bb = 0;
float cc = 0;
final int NUM_LINES = 500; //How many lines are drawn to make the spiral
float maxRadius; //Distance to the corners of the window (needs width/height)
final int NUM_TURNS = 10; //How many times around to get to that size
float startAngle = 0; //The angle to use to start the spiral
final float START_ANGLE_CHANGE = 0.000004; //Change in startAngle each frame
void setup() {
size(500, 500);
maxRadius = sqrt(sq(width/2)+sq(height/2)); //Distance to the corners from the centre
}
void draw() {
linecolor ();
background(255);
float Xbef = width/2;
float Ybef = height/2;
float Xnex;
float Ynex;
float r = 0;
float angle = 0;
for(int i = 0; i <=NUM_LINES; i++){
Xnex = width/2+r*cos(angle);
Ynex = height/2+r*sin(angle);
//stroke(aa,bb,cc);
//stroke(random(255),random(255),random(255));
line(Xbef,Ybef,Xnex,Ynex);
Xbef = Xnex;
Ybef = Ynex;
angle = i*(NUM_TURNS*TWO_PI/(NUM_LINES-1)+startAngle);
startAngle = startAngle + START_ANGLE_CHANGE;
r = r+1;
}
//linecolor();
}
void linecolor () {
aa = (aa + 1)%255;
if(aa >= 120 && aa <= 200){
bb = ((bb+1)*3)%255;
}
cc = random(255);
println("aa: "+aa + ", bb: " + bb + ", cc :" + cc );
}