Merge pull request #1721 from ybakos/p5_web_45_examples_Handbook_pdfExamples

Examples patch (5 of 9)
This commit is contained in:
Casey Reas
2013-04-05 14:34:06 -07:00
3 changed files with 18 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
// Based on code 32-07 (p. 297)
import processing.pdf.*;
float inc = 0.0;
@@ -12,11 +13,11 @@ void setup() {
}
void draw() {
if(record) {
beginRecord(PDF, "page_290.pdf");
}
stroke(0, 143);
randomSeed(0);
background(255);
@@ -33,12 +34,12 @@ void draw() {
tail(i, 300, int(random(5, 12)), angle*random(1.0, 1.3));
tail(i, 400, int(random(5, 12)), -angle*random(1.0, 1.3));
}
if(record) {
endRecord();
record = false;
record = false;
}
}
void mousePressed() {

View File

@@ -1,6 +1,7 @@
// Based on code 33-14 (p. 307)
import processing.pdf.*;
float inc = 0.0;
@@ -17,7 +18,7 @@ void setup() {
size(180, 666);
smooth();
noFill();
strokeWeight(0.25);
strokeWeight(0.25);
y = new float[height];
x = new float[height];
@@ -32,9 +33,9 @@ void draw() {
background(255);
// Shift the values to the right
for (int i = y.length-1; i > 0; i--) {
for (int i = y.length-1; i > 0; i--) {
y[i] = y[i-1];
}
}
// Add new values to the beginning
my += (mouseX-my) * 0.1;
y[0] = my;
@@ -46,9 +47,9 @@ void draw() {
endShape();
// Shift the values to the right
for (int i = x.length-1; i > 0; i--) {
for (int i = x.length-1; i > 0; i--) {
x[i] = x[i-1];
}
}
// Add new values to the beginning
mx += (mouseY-mx) * 0.1;
x[0] = mx;
@@ -62,7 +63,7 @@ void draw() {
if(record) {
endRecord();
record = false;
record = false;
}
}

View File

@@ -1,9 +1,10 @@
// Based on code 45-04 (p. 424)
import processing.pdf.*;
void setup() {
size(513, 666);
size(513, 666);
}
void draw() {
@@ -11,17 +12,17 @@ void draw() {
point(mouseX, mouseY);
println("hi");
}
}
}
void mousePressed() {
beginRecord(PDF, "page_420.pdf");
beginRecord(PDF, "page_420.pdf");
background(255);
stroke(0);
strokeCap(ROUND);
}
void mouseReleased() {
endRecord();
endRecord();
}