-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPath.pde
63 lines (50 loc) · 1.17 KB
/
Path.pde
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
public class Path {
import toxi.geom.*;
import toxi.processing.*;
static private final color PATH_COLOR = #dc982c;
static private final int PATH_WIDTH = 70;
Spline2D path;
/**
* Constructor
*/
Path() {
path = new Spline2D();
path.add(new Vec2D(0, 400));
path.add(new Vec2D(150, 350));
path.add(new Vec2D(500, 150));
path.add(new Vec2D(720, 80));
}
/**
* Draw the path.
*/
public void draw(ToxiclibsSupport gfx, boolean debug) {
// Draw the path with the full width.
stroke(PATH_COLOR);
strokeWeight(PATH_WIDTH);
noFill();
gfx.lineStrip2D(path.pointList);
if (debug) drawDebugVisuals(gfx);
}
/**
* Get the list of points that make up this Path.
*/
public List<Vec2D> getPointList() {
return path.getPointList();
}
/**
* Get the width of the path.
*/
public int getWidth() {
return PATH_WIDTH;
}
/**
* Draw extra information for debugging.
*/
private void drawDebugVisuals(ToxiclibsSupport gfx) {
// Draw a thin line in the center of the path.
stroke(50);
strokeWeight(1);
noFill();
gfx.lineStrip2D(path.pointList);
}
}