-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogic.js
More file actions
109 lines (95 loc) · 1.9 KB
/
logic.js
File metadata and controls
109 lines (95 loc) · 1.9 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
function setupAnimation() {
loop();
theta = 0
innerPoints = [];
outerPoints = [];
}
function setupValLoop() {
let Loop = loopVals.checked();
if (Loop) {
Ninput.attribute('disabled', '');
Dinput.attribute('disabled', '');
n = 0;
d = 0;
} else {
Ninput.removeAttribute('disabled');
Dinput.removeAttribute('disabled');
n = Ninput.value();
d = Dinput.value();
}
}
function staticRose(inside = true, outside = false) {
if (!loopVals.checked())
noLoop();
noFill();
background(0);
if (inside) {
strokeWeight(1);
stroke(innerColor.color());
beginShape();
for (let i = 0; i <= 360; i++) {
let k = i * d;
let r = sin(n * k) * R;
let x = r * cos(k);
let y = r * sin(k);
vertex(x, y);
}
endShape();
}
if (outside) {
strokeWeight(5);
stroke(outerColor.color());
beginShape();
for (let i = 0; i <= 360; i++) {
let k = i;
let r = sin(n * k) * R;
let x = r * cos(k);
let y = r * sin(k);
vertex(x, y);
}
endShape();
}
}
function animatedRose(inside = true, outside = false, Loop = false) {
// loop();
if (theta >= 361) {
if (Loop)
setupAnimation();
else {
staticRose(inside, outside);
}
return;
}
noFill();
let k = d * theta;
let r = R * sin(n * k);
let x = r * cos(k)
let y = r * sin(k)
innerPoints.push(createVector(x, y));
if (inside) {
stroke(innerColor.color());
strokeWeight(1);
beginShape();
for (let p of innerPoints) {
// print(p.x);
vertex(p.x, p.y);
}
endShape();
}
k = theta;
r = R * sin(n * k);
x = r * cos(k)
y = r * sin(k)
outerPoints.push(createVector(x, y));
if (outside) {
strokeWeight(5);
stroke(outerColor.color());
beginShape();
for (let p of outerPoints) {
// print(p.x);
vertex(p.x, p.y);
}
endShape();
}
theta++;
}