-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginal.js
50 lines (44 loc) · 1003 Bytes
/
original.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
function setup() {
background(255);
createCanvas(windowWidth,windowHeight);
}
var PY, PX;
var x = [20];
var y = [20];
var segLength = 5;
for(var i=0; i<60; i++) {
x[i]=1;
y[i]=1;
}
function segment( x, y, a) {
strokeWeight(1);
stroke(0, 0, 0,50);
push();
translate(x, y);
rotate(a);
line(0, 0, segLength, 0);
pop();
}
function dragSegment( i, xin, yin) {
var dx = xin - x[i];
var dy = yin - y[i];
var angle = atan2(dy, dx);
x[i] = xin - cos(angle) * segLength;
y[i] = yin - sin(angle) * segLength;
segment(x[i], y[i], angle);
}
function draw() {
PX=mouseX;
PY=mouseY;
dragSegment(0, PX, PY);
for(var i=0; i<x.length-1; i++) {
dragSegment(i+1, x[i], y[i]);
}
}
/*
"Smoke Brush" by Laura Valentini
http://www.openprocessing.org/sketch/583697
Licensed under Creative Commons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
https://creativecommons.org/licenses/GPL/2.0/
*/