This commit is contained in:
benfry
2011-01-26 19:22:19 +00:00
parent d3a18c7964
commit eb64b2d4fc
1234 changed files with 96518 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
// Example 02-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
ellipse(50, 50, 80, 80);

View File

@@ -0,0 +1,17 @@
// Example 02-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
smooth();
}
void draw() {
if (mousePressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}

View File

@@ -0,0 +1,4 @@
// Example 03-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(800, 600);

View File

@@ -0,0 +1,5 @@
// Example 03-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
point(240, 60);

View File

@@ -0,0 +1,5 @@
// Example 03-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
line(20, 50, 420, 110);

View File

@@ -0,0 +1,7 @@
// Example 03-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
quad(158, 55, 199, 14, 392, 66, 351, 107);
triangle(347, 54, 392, 9, 392, 66);
triangle(158, 55, 290, 91, 290, 112);

View File

@@ -0,0 +1,5 @@
// Example 03-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
rect(180, 60, 220, 40);

View File

@@ -0,0 +1,7 @@
// Example 03-06 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
ellipse(278, -100, 400, 400);
ellipse(120, 100, 110, 110);
ellipse(412, 60, 18, 18);

View File

@@ -0,0 +1,8 @@
// Example 03-07 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
arc(90, 60, 80, 80, 0, HALF_PI);
arc(190, 60, 80, 80, 0, PI+HALF_PI);
arc(290, 60, 80, 80, PI, TWO_PI+HALF_PI);
arc(390, 60, 80, 80, QUARTER_PI, PI+QUARTER_PI);

View File

@@ -0,0 +1,8 @@
// Example 03-08 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
arc(90, 60, 80, 80, 0, radians(90));
arc(190, 60, 80, 80, 0, radians(270));
arc(290, 60, 80, 80, radians(180), radians(450));
arc(390, 60, 80, 80, radians(45), radians(225));

View File

@@ -0,0 +1,8 @@
// Example 03-09 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
ellipse(140, 0, 190, 190);
// The rectangle draws on top of the ellipse
// because it comes after in the code
rect(160, 30, 260, 20);

View File

@@ -0,0 +1,8 @@
// Example 03-10 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
rect(160, 30, 260, 20);
// The ellipse draws on top of the rectangle
// because it comes after in the code
ellipse(140, 0, 190, 190);

View File

@@ -0,0 +1,8 @@
// Example 03-11 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth(); // Turns on smoothing
ellipse(140, 60, 90, 90);
noSmooth(); // Turns off smoothing
ellipse(240, 60, 90, 90);

View File

@@ -0,0 +1,11 @@
// Example 03-12 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
ellipse(75, 60, 90, 90);
strokeWeight(8); // Stroke weight to 8 pixels
ellipse(175, 60, 90, 90);
ellipse(279, 60, 90, 90);
strokeWeight(20); // Stroke weight to 20 pixels
ellipse(389, 60, 90, 90);

View File

@@ -0,0 +1,14 @@
// Example 03-13 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(12);
strokeJoin(ROUND); // Round the stroke corners
rect(40, 25, 70, 70);
strokeJoin(BEVEL); // Bevel the stroke corners
rect(140, 25, 70, 70);
strokeCap(SQUARE); // Square the line endings
line(270, 25, 340, 95);
strokeCap(ROUND); // Round the line endings
line(350, 25, 420, 95);

View File

@@ -0,0 +1,12 @@
// Example 03-14 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
background(0); // Black
fill(204); // Light gray
ellipse(132, 82, 200, 200); // Light gray circle
fill(153); // Medium gray
ellipse(228, -16, 200, 200); // Medium gray circle
fill(102); // Dark gray
ellipse(268, 118, 200, 200); // Dark gray circle

View File

@@ -0,0 +1,11 @@
// Example 03-15 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
fill(153); // Medium gray
ellipse(132, 82, 200, 200); // Gray circle
noFill(); // Turn off fill
ellipse(228, -16, 200, 200); // Outline circle
noStroke(); // Turn off stroke
ellipse(268, 118, 200, 200); // Doesnt draw!

View File

@@ -0,0 +1,13 @@
// Example 03-16 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
noStroke();
smooth();
background(0, 26, 51); // Dark blue color
fill(255, 0, 0); // Red color
ellipse(132, 82, 200, 200); // Red circle
fill(0, 255, 0); // Green color
ellipse(228, -16, 200, 200); // Green circle
fill(0, 0, 255); // Blue color
ellipse(268, 118, 200, 200); // Blue circle

View File

@@ -0,0 +1,13 @@
// Example 03-17 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
noStroke();
smooth();
background(204, 226, 225); // Light blue color
fill(255, 0, 0, 160); // Red color
ellipse(132, 82, 200, 200); // Red circle
fill(0, 255, 0, 160); // Green color
ellipse(228, -16, 200, 200); // Green circle
fill(0, 0, 255, 160); // Blue color
ellipse(268, 118, 200, 200); // Blue circle

View File

@@ -0,0 +1,13 @@
// Example 03-18 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
beginShape();
vertex(180, 82);
vertex(207, 36);
vertex(214, 63);
vertex(407, 11);
vertex(412, 30);
vertex(219, 82);
vertex(226, 109);
endShape();

View File

@@ -0,0 +1,13 @@
// Example 03-19 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
beginShape();
vertex(180, 82);
vertex(207, 36);
vertex(214, 63);
vertex(407, 11);
vertex(412, 30);
vertex(219, 82);
vertex(226, 109);
endShape(CLOSE);

View File

@@ -0,0 +1,38 @@
// Example 03-20 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
// Left creature
beginShape();
vertex(50, 120);
vertex(100, 90);
vertex(110, 60);
vertex(80, 20);
vertex(210, 60);
vertex(160, 80);
vertex(200, 90);
vertex(140, 100);
vertex(130, 120);
endShape();
fill(0);
ellipse(155, 60, 8, 8);
// Right creature
fill(255);
beginShape();
vertex(370, 120);
vertex(360, 90);
vertex(290, 80);
vertex(340, 70);
vertex(280, 50);
vertex(420, 10);
vertex(390, 50);
vertex(410, 90);
vertex(460, 120);
endShape();
fill(0);
ellipse(345, 50, 10, 10);

View File

@@ -0,0 +1,10 @@
// Example 04-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
int y = 60;
int d = 80;
ellipse(75, y, d, d); // Left
ellipse(175, y, d, d); // Middle
ellipse(275, y, d, d); // Right

View File

@@ -0,0 +1,10 @@
// Example 04-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
int y = 100;
int d = 130;
ellipse(75, y, d, d); // Left
ellipse(175, y, d, d); // Middle
ellipse(275, y, d, d); // Right

View File

@@ -0,0 +1,8 @@
// Example 04-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
line(0, 0, width, height); // Line from (0,0) to (480, 120)
line(width, 0, 0, height); // Line from (480, 0) to (0, 120)
ellipse(width/2, height/2, 60, 60);

View File

@@ -0,0 +1,12 @@
// Example 04-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
int x = 25;
int h = 20;
int y = 25;
rect(x, y, 300, h); // Top
x = x + 100;
rect(x, y + h, 300, h); // Middle
x = x - 250;
rect(x, y + h*2, 300, h); // Bottom

View File

@@ -0,0 +1,13 @@
// Example 04-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(8);
line(20, 40, 80, 80);
line(80, 40, 140, 80);
line(140, 40, 200, 80);
line(200, 40, 260, 80);
line(260, 40, 320, 80);
line(320, 40, 380, 80);
line(380, 40, 440, 80);

View File

@@ -0,0 +1,10 @@
// Example 04-06 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(8);
for (int i = 20; i < 400; i += 60) {
line(i, 40, i + 60, 80);
}

View File

@@ -0,0 +1,10 @@
// Example 04-07 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(2);
for (int i = 20; i < 400; i += 8) {
line(i, 40, i + 60, 80);
}

View File

@@ -0,0 +1,10 @@
// Example 04-08 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(2);
for (int i = 20; i < 400; i += 20) {
line(i, 0, i + i/2, 80);
}

View File

@@ -0,0 +1,11 @@
// Example 04-09 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
smooth();
strokeWeight(2);
for (int i = 20; i < 400; i += 20) {
line(i, 0, i + i/2, 80);
line(i + i/2, 80, i*1.2, 120);
}

View File

@@ -0,0 +1,14 @@
// Example 04-10 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
background(0);
smooth();
noStroke();
for (int y = 0; y <= height; y += 40) {
for (int x = 0; x <= width; x += 40) {
fill(255, 140);
ellipse(x, y, 40, 40);
}
}

View File

@@ -0,0 +1,16 @@
// Example 04-11 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
background(0);
smooth();
noStroke();
for (int y = 0; y < height+45; y += 40) {
fill(255, 140);
ellipse(0, y, 40, 40);
}
for (int x = 0; x < width+45; x += 40) {
fill(255, 140);
ellipse(x, 0, 40, 40);
}

View File

@@ -0,0 +1,16 @@
// Example 04-12 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
background(0);
smooth();
fill(255);
stroke(102);
for (int y = 20; y <= height-20; y += 10) {
for (int x = 20; x <= width-20; x += 10) {
ellipse(x, y, 4, 4);
// Draw a line to the center of the display
line(x, y, 240, 60);
}
}

View File

@@ -0,0 +1,12 @@
// Example 04-13 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
size(480, 120);
background(0);
smooth();
for (int y = 32; y <= height; y += 8) {
for (int x = 12; x <= width; x += 15) {
ellipse(x + y, y, 16 - y/10.0, 16 - y/10.0);
}
}

View File

@@ -0,0 +1,9 @@
// Example 05-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void draw() {
// Displays the frame count to the Console
println("Im drawing");
println(frameCount);
}

View File

@@ -0,0 +1,11 @@
// Example 05-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
println("Im starting");
}
void draw() {
println("Im running");
}

View File

@@ -0,0 +1,18 @@
// Example 05-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int x = 280;
int y = -100;
int diameter = 380;
void setup() {
size(480, 120);
smooth();
fill(102);
}
void draw() {
background(204);
ellipse(x, y, diameter, diameter);
}

View File

@@ -0,0 +1,15 @@
// Example 05-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
fill(0, 102);
smooth();
noStroke();
}
void draw() {
ellipse(mouseX, mouseY, 9, 9);
}

View File

@@ -0,0 +1,15 @@
// Example 05-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
fill(0, 102);
smooth();
noStroke();
}
void draw() {
background(204);
ellipse(mouseX, mouseY, 9, 9);
}

View File

@@ -0,0 +1,14 @@
// Example 05-06 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
strokeWeight(4);
smooth();
stroke(0, 102);
}
void draw() {
line(mouseX, mouseY, pmouseX, pmouseY);
}

View File

@@ -0,0 +1,15 @@
// Example 05-07 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
smooth();
stroke(0, 102);
}
void draw() {
float weight = dist(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(weight);
line(mouseX, mouseY, pmouseX, pmouseY);
}

View File

@@ -0,0 +1,18 @@
// Example 05-08 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float x;
float easing = 0.01;
void setup() {
size(220, 120);
smooth();
}
void draw() {
float targetX = mouseX;
x += (targetX - x) * easing;
ellipse(x, 40, 12, 12);
println(targetX + " : " + x);
}

View File

@@ -0,0 +1,27 @@
// Example 05-09 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float x;
float y;
float px;
float py;
float easing = 0.05;
void setup() {
size(480, 120);
smooth();
stroke(0, 102);
}
void draw() {
float targetX = mouseX;
x += (targetX - x) * easing;
float targetY = mouseY;
y += (targetY - y) * easing;
float weight = dist(x, y, px, py);
strokeWeight(weight);
line(x, y, px, py);
py = y;
px = x;
}

View File

@@ -0,0 +1,18 @@
// Example 05-10 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
strokeWeight(12);
smooth();
}
void draw() {
background(204);
stroke(255);
line(120, 60, mouseX, mouseY); // White line
stroke(0);
float mx = mouseX/2 + 60;
line(120, 60, mx, mouseY); // Black line
}

View File

@@ -0,0 +1,18 @@
// Example 05-11 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
strokeWeight(12);
smooth();
}
void draw() {
background(204);
stroke(255);
line(120, 60, mouseX, mouseY); // White line
stroke(0);
float mx = map(mouseX, 0, width, 60, 180);
line(120, 60, mx, mouseY); // Black line
}

View File

@@ -0,0 +1,19 @@
// Example 05-12 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
smooth();
strokeWeight(30);
}
void draw() {
background(204);
stroke(102);
line(40, 0, 70, height);
if (mousePressed == true) {
stroke(0);
}
line(0, 70, width, 50);
}

View File

@@ -0,0 +1,21 @@
// Example 05-13 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
smooth();
strokeWeight(30);
}
void draw() {
background(204);
stroke(102);
line(40, 0, 70, height);
if (mousePressed) {
stroke(0);
} else {
stroke(255);
}
line(0, 70, width, 50);
}

View File

@@ -0,0 +1,23 @@
// Example 05-14 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
smooth();
strokeWeight(30);
}
void draw() {
background(204);
stroke(102);
line(40, 0, 70, height);
if (mousePressed) {
if (mouseButton == LEFT) {
stroke(255);
} else {
stroke(0);
}
line(0, 70, width, 50);
}
}

View File

@@ -0,0 +1,28 @@
// Example 05-15 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float x;
int offset = 10;
void setup() {
size(240, 120);
smooth();
x = width/2;
}
void draw() {
background(204);
if (mouseX > x) {
x += 0.5;
offset = -10;
}
if (mouseX < x) {
x -= 0.5;
offset = 10;
}
line(x, 0, x, height);
line(mouseX, mouseY, mouseX + offset, mouseY - 10);
line(mouseX, mouseY, mouseX + offset, mouseY + 10);
line(mouseX, mouseY, mouseX + offset*3, mouseY);
}

View File

@@ -0,0 +1,25 @@
// Example 05-16 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int x = 120;
int y = 60;
int radius = 12;
void setup() {
size(240, 120);
smooth();
ellipseMode(RADIUS);
}
void draw() {
background(204);
float d = dist(mouseX, mouseY, x, y);
if (d < radius) {
radius++;
fill(0);
} else {
fill(255);
}
ellipse(x, y, radius, radius);
}

View File

@@ -0,0 +1,24 @@
// Example 05-17 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int x = 80;
int y = 30;
int w = 80;
int h = 60;
void setup() {
size(240, 120);
}
void draw() {
background(204);
if ((mouseX > x) && (mouseX < x+w) &&
(mouseY > y) && (mouseY < y+h)) {
fill(0);
}
else {
fill(255);
}
rect(x, y, w, h);
}

View File

@@ -0,0 +1,16 @@
// Example 05-18 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
smooth();
}
void draw() {
background(204);
line(20, 20, 220, 100);
if (keyPressed) {
line(220, 20, 20, 100);
}
}

View File

@@ -0,0 +1,14 @@
// Example 05-19 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
textSize(64);
textAlign(CENTER);
}
void draw() {
background(0);
text(key, 60, 80);
}

View File

@@ -0,0 +1,22 @@
// Example 05-20 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
smooth();
}
void draw() {
background(204);
if (keyPressed) {
if ((key == 'h') || (key == 'H')) {
line(30, 60, 90, 60);
}
if ((key == 'n') || (key == 'N')) {
line(30, 20, 90, 100);
}
}
line(30, 20, 30, 100);
line(90, 20, 90, 100);
}

View File

@@ -0,0 +1,21 @@
// Example 05-21 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int x = 215;
void setup() {
size(480, 120);
}
void draw() {
if (keyPressed && (key == CODED)) { // If it's a coded key
if (keyCode == LEFT) { // If it's the left arrow
x--;
}
else if (keyCode == RIGHT) { // If it's the right arrow
x++;
}
}
rect(x, 45, 50, 50);
}

View File

@@ -0,0 +1,14 @@
// Example 06-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PImage img;
void setup() {
size(480, 120);
img = loadImage("lunar.jpg");
}
void draw() {
image(img, 0, 0);
}

View File

@@ -0,0 +1,18 @@
// Example 06-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PImage img1;
PImage img2;
void setup() {
size(480, 120);
img1 = loadImage("lunar.jpg");
img2 = loadImage("capsule.jpg");
}
void draw() {
image(img1, -120, 0);
image(img1, 130, 0, 240, 120);
image(img2, 300, 0, 240, 120);
}

View File

@@ -0,0 +1,15 @@
// Example 06-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PImage img;
void setup() {
size(480, 120);
img = loadImage("lunar.jpg");
}
void draw() {
background(0);
image(img, 0, 0, mouseX * 2, mouseY * 2);
}

View File

@@ -0,0 +1,16 @@
// Example 06-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PImage img;
void setup() {
size(480, 120);
img = loadImage("clouds.gif");
}
void draw() {
background(255);
image(img, 0, 0);
image(img, 0, mouseY * -1);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -0,0 +1,16 @@
// Example 06-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PImage img;
void setup() {
size(480, 120);
img = loadImage("clouds.png");
}
void draw() {
background(204);
image(img, 0, 0);
image(img, 0, mouseY * -1);
}

View File

@@ -0,0 +1,20 @@
// Example 06-06 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PFont font;
void setup() {
size(480, 120);
smooth();
font = loadFont("AndaleMono-36.vlw");
textFont(font);
}
void draw() {
background(102);
textSize(36);
text("Thats one small step for man...", 25, 60);
textSize(18);
text("Thats one small step for man...", 27, 90);
}

View File

@@ -0,0 +1,18 @@
// Example 06-07 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PFont font;
void setup() {
size(480, 120);
font = loadFont("AndaleMono-24.vlw");
textFont(font);
}
void draw() {
background(102);
text("Thats one small step for man...", 26, 30, 240, 100);
}

View File

@@ -0,0 +1,17 @@
// Example 06-08 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PFont font;
String quote = "Thats one small step for man...";
void setup() {
size(480, 120);
font = loadFont("AndaleMono-24.vlw");
textFont(font);
}
void draw() {
background(102);
text(quote, 26, 30, 240, 100);
}

View File

@@ -0,0 +1,17 @@
// Example 06-09 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PShape network;
void setup() {
size(480, 120);
smooth();
network = loadShape("network.svg");
}
void draw() {
background(0);
shape(network, 30, 10);
shape(network, 180, 10, 280, 280);
}

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 322 KiB

View File

@@ -0,0 +1,18 @@
// Example 06-10 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
PShape network;
void setup() {
size(240, 120);
smooth();
shapeMode(CENTER);
network = loadShape("network.svg");
}
void draw() {
background(0);
float diameter = map(mouseX, 0, width, 10, 800);
shape(network, 120, 60, diameter, diameter);
}

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 322 KiB

View File

@@ -0,0 +1,7 @@
// Example 07-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void draw() {
println(frameRate);
}

View File

@@ -0,0 +1,15 @@
// Example 07-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
frameRate(30); // Thirty frames each second
//frameRate(12); // Twelve frames each second
//frameRate(2); // Two frames each second
//frameRate(0.5); // One frame every two seconds
}
void draw() {
println(frameRate);
}

View File

@@ -0,0 +1,19 @@
// Example 07-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int radius = 40;
float x = -radius;
float speed = 0.5;
void setup() {
size(240, 120);
smooth();
ellipseMode(RADIUS);
}
void draw() {
background(0);
x += speed; // Increase the value of x
arc(x, 60, radius, radius, 0.52, 5.76);
}

View File

@@ -0,0 +1,22 @@
// Example 07-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int radius = 40;
float x = -radius;
float speed = 0.5;
void setup() {
size(240, 120);
smooth();
ellipseMode(RADIUS);
}
void draw() {
background(0);
x += speed; // Increase the value of x
if (x > width+radius) { // If the shape is off screen
x = -radius; // move to the left edge
}
arc(x, 60, radius, radius, 0.52, 5.76);
}

View File

@@ -0,0 +1,27 @@
// Example 07-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int radius = 40;
float x = 110;
float speed = 0.5;
int direction = 1;
void setup() {
size(240, 120);
smooth();
ellipseMode(RADIUS);
}
void draw() {
background(0);
x += speed * direction;
if ((x > width-radius) || (x < radius)) {
direction = -direction; // Flip direction
}
if (direction == 1) {
arc(x, 60, radius, radius, 0.52, 5.76); // Face right
} else {
arc(x, 60, radius, radius, 3.67, 8.9); // Face left
}
}

View File

@@ -0,0 +1,27 @@
// Example 07-06 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int startX = 20; // Initial x-coordinate
int stopX = 160; // Final x-coordinate
int startY = 30; // Initial y-coordinate
int stopY = 80; // Final y-coordinate
float x = startX; // Current x-coordinate
float y = startY; // Current y-coordinate
float step = 0.005; // Size of each step (0.0 to 1.0)
float pct = 0.0; // Percentage traveled (0.0 to 1.0)
void setup() {
size(240, 120);
smooth();
}
void draw() {
background(0);
if (pct < 1.0) {
x = startX + ((stopX-startX) * pct);
y = startY + ((stopY-startY) * pct);
pct += step;
}
ellipse(x, y, 20, 20);
}

View File

@@ -0,0 +1,8 @@
// Example 07-07 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void draw() {
float r = random(0, mouseX);
println(r);
}

View File

@@ -0,0 +1,18 @@
// Example 07-08 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(240, 120);
smooth();
}
void draw() {
background(204);
for (int x = 20; x < width; x += 20) {
float mx = mouseX / 10;
float offsetA = random(-mx, mx);
float offsetB = random(-mx, mx);
line(x + offsetA, 20, x - offsetB, 100);
}
}

View File

@@ -0,0 +1,21 @@
// Example 07-09 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float speed = 2.5;
int diameter = 20;
float x;
float y;
void setup() {
size(240, 120);
smooth();
x = width/2;
y = height/2;
}
void draw() {
x += random(-speed, speed);
y += random(-speed, speed);
ellipse(x, y, diameter, diameter);
}

View File

@@ -0,0 +1,8 @@
// Example 07-10 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void draw() {
int timer = millis();
println(timer);
}

View File

@@ -0,0 +1,23 @@
// Example 07-11 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
int time1 = 2000;
int time2 = 4000;
float x = 0;
void setup() {
size(480, 120);
smooth();
}
void draw() {
int currentTime = millis();
background(204);
if (currentTime > time2) {
x -= 0.5;
} else if (currentTime > time1) {
x += 2;
}
ellipse(x, 60, 90, 90);
}

View File

@@ -0,0 +1,13 @@
// Example 07-12 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
void draw() {
float sinval = sin(angle);
println(sinval);
float gray = map(sinval, -1, 1, 0, 255);
background(gray);
angle += 0.1;
}

View File

@@ -0,0 +1,24 @@
// Example 07-13 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
float offset = 60;
float scalar = 40;
float speed = 0.05;
void setup() {
size(240, 120);
smooth();
}
void draw() {
background(0);
float y1 = offset + sin(angle) * scalar;
float y2 = offset + sin(angle + 0.4) * scalar;
float y3 = offset + sin(angle + 0.8) * scalar;
ellipse( 80, y1, 40, 40);
ellipse(120, y2, 40, 40);
ellipse(160, y3, 40, 40);
angle += speed;
}

View File

@@ -0,0 +1,20 @@
// Example 07-14 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
float offset = 60;
float scalar = 30;
float speed = 0.05;
void setup() {
size(120, 120);
smooth();
}
void draw() {
float x = offset + cos(angle) * scalar;
float y = offset + sin(angle) * scalar;
ellipse( x, y, 40, 40);
angle += speed;
}

View File

@@ -0,0 +1,22 @@
// Example 07-15 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
float offset = 60;
float scalar = 2;
float speed = 0.05;
void setup() {
size(120, 120);
fill(0);
smooth();
}
void draw() {
float x = offset + cos(angle) * scalar;
float y = offset + sin(angle) * scalar;
ellipse( x, y, 2, 2);
angle += speed;
scalar += speed;
}

View File

@@ -0,0 +1,12 @@
// Example 07-16 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
}
void draw() {
translate(mouseX, mouseY);
rect(0, 0, 30, 30);
}

View File

@@ -0,0 +1,14 @@
// Example 07-17 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
}
void draw() {
translate(mouseX, mouseY);
rect(0, 0, 30, 30);
translate(35, 10);
rect(0, 0, 15, 15);
}

View File

@@ -0,0 +1,16 @@
// Example 07-18 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(120, 120);
}
void draw() {
pushMatrix();
translate(mouseX, mouseY);
rect(0, 0, 30, 30);
popMatrix();
translate(35, 10);
rect(0, 0, 15, 15);
}

View File

@@ -0,0 +1,17 @@
// Example 07-19 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
void setup() {
size(120, 120);
smooth();
}
void draw() {
translate(mouseX, mouseY);
rotate(angle);
rect(-15, -15, 30, 30);
angle += 0.1;
}

View File

@@ -0,0 +1,17 @@
// Example 07-20 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
void setup() {
size(120, 120);
smooth();
}
void draw() {
rotate(angle);
translate(mouseX, mouseY);
rect(-15, -15, 30, 30);
angle += 0.1;
}

View File

@@ -0,0 +1,17 @@
// Example 07-21 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
void setup() {
size(120, 120);
smooth();
}
void draw() {
translate(mouseX, mouseY);
scale(sin(angle) + 2);
rect(-15, -15, 30, 30);
angle += 0.1;
}

View File

@@ -0,0 +1,19 @@
// Example 07-22 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
void setup() {
size(120, 120);
smooth();
}
void draw() {
translate(mouseX, mouseY);
float scalar = sin(angle) + 2;
scale(scalar);
strokeWeight(1.0 / scalar);
rect(-15, -15, 30, 30);
angle += 0.1;
}

View File

@@ -0,0 +1,33 @@
// Example 07-23 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
float angle = 0.0;
float angleDirection = 1;
float speed = 0.005;
void setup() {
size(120, 120);
smooth();
}
void draw() {
background(204);
translate(20, 25); // Move to start position
rotate(angle);
strokeWeight(12);
line(0, 0, 40, 0);
translate(40, 0); // Move to next joint
rotate(angle * 2.0);
strokeWeight(6);
line(0, 0, 30, 0);
translate(30, 0); // Move the next joint
rotate(angle * 2.5);
strokeWeight(3);
line(0, 0, 20, 0);
angle += speed * angleDirection;
if ((angle > QUARTER_PI) || (angle < 0)) {
angleDirection *= -1;
}
}

View File

@@ -0,0 +1,16 @@
// Example 08-01 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
println("Ready to roll!");
rollDice(20);
rollDice(20);
rollDice(6);
println("Finished.");
}
void rollDice(int numSides) {
int d = 1 + int(random(numSides));
println("Rolling... " + d);
}

View File

@@ -0,0 +1,14 @@
// Example 08-02 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
println("Ready to roll!");
int d1 = 1 + int(random(20));
println("Rolling... " + d1);
int d2 = 1 + int(random(20));
println("Rolling... " + d2);
int d3 = 1 + int(random(6));
println("Rolling... " + d3);
println("Finished.");
}

View File

@@ -0,0 +1,25 @@
// Example 08-03 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
smooth();
}
void draw() {
background(204);
translate(110, 110);
stroke(0);
strokeWeight(70);
line(0, -35, 0, -65); // Body
noStroke();
fill(255);
ellipse(-17.5, -65, 35, 35); // Left eye dome
ellipse(17.5, -65, 35, 35); // Right eye dome
arc(0, -65, 70, 70, 0, PI); // Chin
fill(0);
ellipse(-14, -65, 8, 8); // Left eye
ellipse(14, -65, 8, 8); // Right eye
quad(0, -58, 4, -51, 0, -44, -4, -51); // Beak
}

View File

@@ -0,0 +1,42 @@
// Example 08-04 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
smooth();
}
void draw() {
background(204);
// Left owl
translate(110, 110);
stroke(0);
strokeWeight(70);
line(0, -35, 0, -65); // Body
noStroke();
fill(255);
ellipse(-17.5, -65, 35, 35); // Left eye dome
ellipse(17.5, -65, 35, 35); // Right eye dome
arc(0, -65, 70, 70, 0, PI); // Chin
fill(0);
ellipse(-14, -65, 8, 8); // Left eye
ellipse(14, -65, 8, 8); // Right eye
quad(0, -58, 4, -51, 0, -44, -4, -51); // Beak
// Right owl
translate(70, 0);
stroke(0);
strokeWeight(70);
line(0, -35, 0, -65); // Body
noStroke();
fill(255);
ellipse(-17.5, -65, 35, 35); // Left eye dome
ellipse(17.5, -65, 35, 35); // Right eye dome
arc(0, -65, 70, 70, 0, PI); // Chin
fill(0);
ellipse(-14, -65, 8, 8); // Left eye
ellipse(14, -65, 8, 8); // Right eye
quad(0, -58, 4, -51, 0, -44, -4, -51); // Beak
}

View File

@@ -0,0 +1,32 @@
// Example 08-05 from "Getting Started with Processing"
// by Reas & Fry. O'Reilly / Make 2010
void setup() {
size(480, 120);
smooth();
}
void draw() {
background(204);
owl(110, 110);
owl(180, 110);
}
void owl(int x, int y) {
pushMatrix();
translate(x, y);
stroke(0);
strokeWeight(70);
line(0, -35, 0, -65); // Body
noStroke();
fill(255);
ellipse(-17.5, -65, 35, 35); // Left eye dome
ellipse(17.5, -65, 35, 35); // Right eye dome
arc(0, -65, 70, 70, 0, PI); // Chin
fill(0);
ellipse(-14, -65, 8, 8); // Left eye
ellipse(14, -65, 8, 8); // Right eye
quad(0, -58, 4, -51, 0, -44, -4, -51); // Beak
popMatrix();
}

Some files were not shown because too many files have changed in this diff Show More