-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
111 lines (95 loc) · 3.02 KB
/
sketch.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
var circulation = [];
var bgColor = 255;
function setup() {
// title
title = createA('https://github.com/livacengiz/cavity', 'cavity', '_blank');
title.position(20, 20);
// Hole
holeSpan = createSpan('zero point experience');
holeSpan.position(20, 60)
holeSpan.style('font-family', 'monospace')
holeSlider = createSlider(0, 250, random(125))
holeSlider.position(20,80);
// Complex
complexSpan = createSpan('complex experience');
complexSpan.position(20, 110)
complexSpan.style('font-family', 'monospace')
complexSlider = createSlider(-250, 250, -180)
complexSlider.position(20,130);
// Inside
curveSpan = createSpan('curve experience');
curveSpan.position(20, 160)
curveSpan.style('font-family', 'monospace')
curveSlider = createSlider(-250, 255, random(80))
curveSlider.position(20,180);
// Opaticy
opacitySpan = createSpan('opaticy experience');
opacitySpan.position(20, 210)
opacitySpan.style('font-family', 'monospace')
opacitySlider = createSlider(10, 100, 40)
opacitySlider.position(20,230);
// Radians
radiansSpan = createSpan('radians experience');
radiansSpan.position(20, 260)
radiansSpan.style('font-family', 'monospace')
radiansSlider = createSlider(10, 90, 60, 10)
radiansSlider.position(20, 280);
//Background color
backgroundColor = createCheckbox('background color: black', false);
backgroundColor.changed(changeBG);
backgroundColor.position(20, 310)
backgroundColor.id("bgLabel")
backgroundColor.style('font-family', 'monospace')
drawStyle = createRadio();
drawStyle.option('bezier');
drawStyle.option('line');
drawStyle.position(20, 340)
drawStyle.style('width', '60px');
drawStyle.id('drawStyle');
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 255, 255, 255, 1)
for (var i = 0; i < 180; i++) {
circulation.push(circulation[i] = floor(randomGaussian(0,70)))
}
}
function draw() {
background(bgColor);
hole = holeSlider.value();
complex = complexSlider.value();
curve = curveSlider.value();
alpha = map(opacitySlider.value(), 0,100, 0,1)
rad = radiansSlider.value();
translate(width/2, height/2);
for (var i = 0; i < circulation.length; i++) {
stroke(curve,100, hole+80, alpha);
noFill()
var circ = abs(circulation[i]);
var style = drawStyle.value();
if (style == 'line'){
rotate(TWO_PI/circulation.length)
line(hole, curve, circ, complex);
}else {
rotate(radians(rad))
bezier(hole, 10, circ, curve, curve, circ, 105, complex);
}
}
}
function changeBG() {
var spans = document.getElementsByTagName("SPAN")
var bg = document.getElementById("bgLabel")
var drawStyle = document.getElementById("drawStyle")
if (this.checked()) {
bgColor = 0;
bg.style.color = "white";
drawStyle.style.color = "white";
for (var i = 0; i < spans.length; i++) {
spans[i].style.color = "white";
}
} else {
bgColor = 255;
for (var i = 0; i < spans.length; i++) {
spans[i].style.color = "black";
}
bg.style.color = "black";
drawStyle.style.color = "black";
}}