-
Notifications
You must be signed in to change notification settings - Fork 7
/
SketchLaserLine.java
executable file
·51 lines (40 loc) · 1.33 KB
/
SketchLaserLine.java
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
package de.hfkbremen.algorithmiccliches.examples;
import de.hfkbremen.algorithmiccliches.laserline.LaserLine2;
import processing.core.PApplet;
import java.util.ArrayList;
public class SketchLaserLine extends PApplet {
private final ArrayList<LaserLine2> mLaserLines = new ArrayList<>();
public void settings() {
size(1024, 768, P3D);
}
public void setup() {
}
public void draw() {
background(0);
noStroke();
for (LaserLine2 l : mLaserLines) {
l.draw(g);
}
for (int i = 0; i < mLaserLines.size(); i++) {
LaserLine2 l = mLaserLines.get(i);
l.fade_width = sin(radians(frameCount * 4 + i * (360.0f / mLaserLines.size()))) * 5;
l.fade_width += 10;
}
}
public void mousePressed() {
LaserLine2 l = new LaserLine2();
l.core_color = color(255, 0, 0);
l.inner_fade_color = color(255, 0, 0, 127);
l.outer_fade_color = color(255, 0, 0, 0);
if (mLaserLines.isEmpty()) {
l.p0.set(width / 2.0f, height / 2.0f);
} else {
l.p0.set(mLaserLines.get(mLaserLines.size() - 1).p1);
}
l.p1.set(mouseX, mouseY);
mLaserLines.add(l);
}
public static void main(String[] args) {
PApplet.main(SketchLaserLine.class.getName());
}
}