-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.js
121 lines (109 loc) · 2.54 KB
/
helpers.js
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
const layerConstructors = [
{
name: "Bar",
init: () => new Bar(),
weight: 1,
},
{
name: "Right Triangle",
init: () => new RightTriangle(),
weight: 2,
},
{
name: "Double Triangle",
init: () => new DoubleTriangle(),
weight: 3,
},
{
name: "Diamond",
init: () => new Diamond(),
weight: 3,
},
{
name: "Circle",
init: () => new Circle(),
weight: 4,
},
{
name: "Square",
init: () => new Square(),
weight: 5,
},
{
name: "Leaf",
init: () => new Leaf(),
weight: 10,
},
{
name: "Eyeball",
init: () => new Eyeball(),
weight: 10,
},
];
// Draws a right triangle
function rightTriangle(posX, posY, length) {
beginShape();
const a = createVector(posX + length / 2, posY + length / 2);
const b = createVector(posX - length / 2, posY + length / 2);
const c = createVector(posX - length / 2, posY - length / 2);
vertex(a.x, a.y);
vertex(b.x, b.y);
vertex(c.x, c.y);
vertex(a.x, a.y);
endShape();
}
function doubleTriangle(posX, posY, length) {
beginShape();
const a = createVector(posX + length / 2, posY + length / 2);
const b = createVector(posX - length / 2, posY + length / 2);
const c = createVector(posX - length / 2, posY - length / 2);
const d = createVector(posX + length / 2, posY - length / 2);
vertex(a.x, a.y);
vertex(c.x, c.y);
vertex(b.x, b.y);
vertex(d.x, d.y);
vertex(a.x, a.y);
endShape();
}
function diamond(posX, posY, length) {
beginShape();
const a = createVector(posX + length / 2, posY + length / 2);
const b = createVector(posX - length / 4, posY + length / 4);
const c = createVector(posX - length / 2, posY - length / 2);
const d = createVector(posX + length / 4, posY - length / 4);
vertex(a.x, a.y);
vertex(b.x, b.y);
vertex(c.x, c.y);
vertex(d.x, d.y);
vertex(a.x, a.y);
endShape();
}
// function leaf(posX, posY, length) {
// beginShape();
// const a = createVector();
// const b = createVector();
// const c = createVector();
// const d = createVector();
// curveVertex();
// endShape();
// }
// Randomly selects boolean value
function randomSelectTwo() {
// Number of Lines
const rand = random(1);
if (rand < 0.5) {
return true;
} else {
return false;
}
}
// Selects a color from PALETTE randomly
function getRandomFromPalette(length = PALETTE.length) {
const rand = floor(random(0, length));
return PALETTE[rand];
}
// // Applies a random rotation
// function applyRotation() {
// const angle = floor(random(4));
// rotate(angle * 90);
// }