-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.js
86 lines (79 loc) · 2.6 KB
/
helper.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
function randomBinaryChoice(){
const rando = random(1);
if (rando > 0.5){
return true;
}
else{
return false;
}
}
function getPalette(){
const rando2 = floor(random(0, PALETTE.length));
return PALETTE[rando2];
}
function hexagon(xpos, ypos, radius){
const rotAngle = 360/6;
beginShape();
for (let i = 0; i < 6; i++){
const thisVertex = pointCircle(xpos, ypos, radius, i * rotAngle)
vertex(thisVertex.x, thisVertex.y);
}
endShape(CLOSE);
}
function pointCircle(xpos,ypos, radius, angle){
const x = xpos + radius * cos(angle);
const y = ypos + radius * sin(angle);
return createVector(x,y);
}
function myTriangle (center, radius, direction) {
if (direction) {
beginShape();
vertex(center + radius * cos(0), radius * sin(0));
vertex(center + radius * cos(120), radius * sin(120));
vertex(center + radius * cos(240), radius * sin(240));
endShape(CLOSE);
} else {
beginShape();
vertex(center + radius * cos(180), radius * sin(180));
vertex(center + radius * cos(300), radius * sin(300));
vertex(center + radius * cos(60), radius * sin(60));
endShape(CLOSE);
}
}
let layerConstruct = [
{
name: 'centeredShape',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new CenteredShape(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.3,
},
{
name: 'circle',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new Circles(SIZE, CRYSTAL_SIZE),
weight: 0.3,
},
{
name: 'outlineShape',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new OutlineShape(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.3,
},
{
name: 'lines',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new Lines(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.3,
},
{
name: 'dottedLines',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new DottedLines(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.1,
},
{
name: 'steppedHexagons',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new SteppedHexagons(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.3,
},
{
name: 'ringOfShapes',
init: (SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke) => new RingOfShapes(SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke),
weight: 0.1,
},
];