Merge branch 'master' of github.com:processing/processing

This commit is contained in:
Daniel Shiffman
2013-04-06 22:06:57 -04:00
8 changed files with 63 additions and 56 deletions
@@ -1,7 +1,7 @@
/**
* Tile Images
*
* Draws an image larger than the screen by tiling it into small sections.
*
* Draws an image larger than the screen, and saves the image as six tiles.
* The scaleValue variable sets amount of scaling: 1 is 100%, 2 is 200%, etc.
*/
@@ -9,31 +9,29 @@ int scaleValue = 3; // Multiplication factor
int xoffset = 0; // x-axis offset
int yoffset = 0; // y-axis offset
void setup()
{
void setup() {
size(600, 600);
stroke(0, 100);
}
void draw()
{
void draw() {
background(204);
scale(scaleValue);
translate(xoffset *(-width / scaleValue), yoffset *(-height / scaleValue));
translate(xoffset * (-width / scaleValue), yoffset * (-height / scaleValue));
line(10, 150, 500, 50);
line(0, 600, 600, 0);
save("lines-" + yoffset + "-" + xoffset + ".png");
setOffset();
}
void setOffset()
{
save("lines-" + xoffset + "-" + yoffset + ".jpg");
void setOffset() {
xoffset++;
if (xoffset == scaleValue) {
xoffset = 0;
yoffset++;
if (yoffset == scaleValue) {
println("Tiles saved.");
exit();
}
}
background(204);
}
}
@@ -5,6 +5,6 @@ PImage img = loadImage("sprite.png");
// The coordinates (0, 0) refer to the top-left corder of the screen
image(img, 0, 0);
// The following coordinate calculations will center the image in the screen
image(img, (width img.width) / 2, (height img.height) / 2);
image(img, (width - img.width) / 2, (height - img.height) / 2);
// Finally, the next line will position the image in the bottom-right corner
image(img, width img.width, height img.height);
image(img, width - img.width, height - img.height);
@@ -9,10 +9,10 @@ void setup() {
//size(200, 200);
smooth();
noStroke();
ellipseMode(CENTER_RADIUS);
ellipseMode(RADIUS);
randomSeed(0);
for(int i=0; i<sps.length; i++) {
sps[i] = new Spot();
sps[i] = new Spot();
}
}
@@ -21,12 +21,12 @@ void draw() {
rect(0, 0, width, height);
fill(0);
for(int i=0; i<sps.length; i++) {
sps[i].updateDisplay();
sps[i].updateDisplay();
}
}
void mousePressed() {
save("page_278.tif");
save("page_278.tif");
}
@@ -46,18 +46,18 @@ class Spot {
if (r < .25) {
directionX = 1;
directionY = 1;
}
}
else if (r < .5) {
directionX = -1;
directionY = 1;
}
directionY = 1;
}
else if (r < .75) {
directionX = 1;
directionY = -1;
}
directionY = -1;
}
else {
directionX = -1;
directionY = -1;
directionY = -1;
}
}
@@ -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() {
@@ -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;
}
}
@@ -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();
}
@@ -1,3 +1,8 @@
/* CubicGridRetained
*
* You may need to increase the maximum available memory in the
* Processing preferences menu.
*/
float boxSize = 20;
float margin = boxSize*2;
float depth = 400;
@@ -14,16 +19,16 @@ void setup() {
frameRate(60);
noSmooth();
noStroke();
grid = createShape(GROUP);
// Build grid using multiple translations
// Build grid using multiple translations
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
for (float j =- height+margin; j <= height-margin; j += boxSize){
for (float k =- width+margin; k <= width-margin; k += boxSize){
// Base fill color on counter values, abs function
// Base fill color on counter values, abs function
// ensures values stay within legal range
boxFill = color(abs(i), abs(j), abs(k), 50);
boxFill = color(abs(i), abs(j), abs(k), 50);
PShape cube = createShape(BOX, boxSize, boxSize, boxSize);
cube.setFill(boxFill);
cube.translate(k, j, i);
@@ -35,9 +40,9 @@ void setup() {
void draw() {
background(255);
hint(DISABLE_DEPTH_TEST);
// Center and spin grid
pushMatrix();
translate(width/2, height/2, -depth);
@@ -46,17 +51,17 @@ void draw() {
shape(grid);
popMatrix();
hint(ENABLE_DEPTH_TEST);
fcount += 1;
int m = millis();
if (m - lastm > 1000 * fint) {
frate = float(fcount) / fint;
fcount = 0;
lastm = m;
println("fps: " + frate);
}
println("fps: " + frate);
}
fill(0);
text("fps: " + frate, 10, 20);
}
@@ -1,7 +1,7 @@
/**
* Tile Images
*
* Draws an image larger than the screen by tiling it into small sections.
*
* Draws an image larger than the screen, and saves the image as six tiles.
* The scaleValue variable sets amount of scaling: 1 is 100%, 2 is 200%, etc.
*/
@@ -15,22 +15,23 @@ void setup() {
}
void draw() {
background(204);
scale(scaleValue);
translate(xoffset *(-width / scaleValue), yoffset *(-height / scaleValue));
translate(xoffset * (-width / scaleValue), yoffset * (-height / scaleValue));
line(10, 150, 500, 50);
line(0, 600, 600, 0);
save("lines-" + yoffset + "-" + xoffset + ".png");
setOffset();
}
void setOffset() {
save("lines-" + xoffset + "-" + yoffset + ".png");
xoffset++;
if (xoffset == scaleValue) {
xoffset = 0;
yoffset++;
if (yoffset == scaleValue) {
println("Tiles saved.");
exit();
}
}
background(204);
}
}