-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.pde
66 lines (59 loc) · 1.67 KB
/
plot.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
64
65
66
// see https://processing.org/reference/libraries/pdf/index.html
// deliverable04 template by golan
import processing.pdf.*;
boolean bRecordingPDF;
int pdfOutputCount = 0;
void setup() {
size(600, 400);
bRecordingPDF = true;
}
void keyPressed() {
// When you press a key, it will initiate a PDF export
bRecordingPDF = true;
}
class LineInfo {
int x1, x2, y1, y2;
LineInfo(int x1, int y1, int x2, int y2) {
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
}
}
void draw() {
if (bRecordingPDF) {
background(255); // this should come BEFORE beginRecord()
beginRecord(PDF, "myName_" + pdfOutputCount + ".pdf");
//--------------------------
noFill();
int mid = width/2;
strokeWeight(1.5);
LineInfo[] lines = { new LineInfo(10,200,mid+10,200),
new LineInfo(10,210,mid-10,210),
new LineInfo(10,190,mid+5,190),
new LineInfo(10,185,mid-5,185),
new LineInfo(10,172,mid,172),
new LineInfo(10,230,mid,230),
new LineInfo(10,240,mid+2,240),
new LineInfo(10,168,mid-15,168) };
for (int i = 0; i < lines.length; i++) {
beginShape();
smooth();
LineInfo l = lines[i];
line(l.x1,l.y1,l.x2,l.y2);
curveVertex(l.x2,l.y2);
curveVertex(l.x2,l.y2);
float rx = l.x2;
float ry= l.y2;
for (int j=0; j < 100; j++) {
rx = rx + random(12,14);
ry = ry + random(-30, 25);
curveVertex(rx, ry);
}
endShape();
}
endRecord();
bRecordingPDF = false;
pdfOutputCount++;
}
}