-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsketch.js
executable file
·62 lines (49 loc) · 1.15 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
// p5.func examples - easing4_fillArray
// I<3DM rld
var ease = new p5.Ease();
var styles = ease.listAlgos();
var curstyle;
var speed = 0.02;
var t = 0.;
var tab;
var tb; // textbox
function setup()
{
createCanvas(800, 600);
curstyle = random(styles);
tb = createDiv('');
tb.style("font-family", "Courier");
tb.style("font-size", "12px");
tb.position(width*0.1, height*0.1);
tb.size(500, 500);
}
function draw()
{
background(255);
stroke(255, 0, 0);
noFill();
rect(width*0.25, height*0.2, width*0.5, height*0.5);
var npoints = floor(constrain(mouseX/4, 2, width/4))
tab = ease.fillArray(curstyle, npoints);
var hs = '';
hs+= 'p5.Ease() array filling.<br>';
hs+= curstyle + ': ' + npoints + ' points.<br>';
hs+= 'mouseX = # points; <space> = new algorithm.';
tb.html(hs);
stroke(0, 0, 255);
fill(0, 32);
beginShape();
for(var i = 0;i<tab.length;i++)
{
var x = i/(tab.length-1)*width*0.5+width*0.25;
var y = map(tab[i], 0., 1., height*0.7, height*0.2);
ellipse(x, y, 5, 5);
vertex(x, y);
}
endShape();
}
function keyTyped()
{
curstyle = random(styles);
tab = ease.fillArray(curstyle, 512);
}