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,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);
}