This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLineClass.pde
60 lines (40 loc) · 1.36 KB
/
GLineClass.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
/*
By Chris Eugene Mills
For live drawing. NOT IMPLEMENTED YET.
*/
class GLine {
// VARIABLES /////////////////////////////////////////////////////////////////
public PVector[] points;
public String units;
public float penFeedrate = Float.NaN;
public float feedrate = Float.NaN;
public float penUp = 100; //TODO
public float penDown = 0; //TODO
// CONSTRUCTOR ///////////////////////////////////////////////////////////////
GLine(PVector[] p) {
points = p;
units = "mm";
}
GLine(PVector[] p, String u) {
points = p;
units = u;
}
GLine(float x1, float y1, float x2, float y2) {
points = new PVector[]{ new PVector(x1,y1), new PVector(x2,y2)};
units = "mm";
}
// ///////////////////////////////////////////////////////////////////////////
public ArrayList<GCommand> exportGCommands() {
ArrayList<GCommand> array = new ArrayList<GCommand>();
array.add( new GCommand('G', 0, points[0].x, points[0].y) ); //GOTO
array.add( new GCommand('G', 1, Float.NaN, Float.NaN, penDown) ); //Down
for (int i = 1; i < points.length; i++) {
array.add( new GCommand('G', 1, points[i].x, points[i].y) ); //Draw
}
array.add( new GCommand('G', 1, Float.NaN, Float.NaN, penUp) ); //Up
for (int i = 0; i < array.size(); i++) {
println(array.get(i).getGText());
}
return array;
}
}