diff --git a/android/examples/Topics/File IO/TileImages/TileImages.pde b/android/examples/Topics/File IO/TileImages/TileImages.pde index 7b266570c..d577e275e 100644 --- a/android/examples/Topics/File IO/TileImages/TileImages.pde +++ b/android/examples/Topics/File IO/TileImages/TileImages.pde @@ -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); -} +} \ No newline at end of file diff --git a/java/examples/Books/Processing Handbook/Extensions/Mobile/Ex_01/Ex_01.pde b/java/examples/Books/Processing Handbook/Extensions/Mobile/Ex_01/Ex_01.pde index 2e1c732d9..160fa2647 100755 --- a/java/examples/Books/Processing Handbook/Extensions/Mobile/Ex_01/Ex_01.pde +++ b/java/examples/Books/Processing Handbook/Extensions/Mobile/Ex_01/Ex_01.pde @@ -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); \ No newline at end of file +image(img, width - img.width, height - img.height); \ No newline at end of file diff --git a/java/examples/Books/Processing Handbook/Illustrations/page_278/page_278.pde b/java/examples/Books/Processing Handbook/Illustrations/page_278/page_278.pde index 46869d576..fbe77b1b6 100755 --- a/java/examples/Books/Processing Handbook/Illustrations/page_278/page_278.pde +++ b/java/examples/Books/Processing Handbook/Illustrations/page_278/page_278.pde @@ -9,10 +9,10 @@ void setup() { //size(200, 200); smooth(); noStroke(); - ellipseMode(CENTER_RADIUS); + ellipseMode(RADIUS); randomSeed(0); for(int i=0; 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; } } diff --git a/java/examples/Books/Processing Handbook/Illustrations/page_420/page_420.pde b/java/examples/Books/Processing Handbook/Illustrations/page_420/page_420.pde index 3010bc637..ecdc57fd3 100755 --- a/java/examples/Books/Processing Handbook/Illustrations/page_420/page_420.pde +++ b/java/examples/Books/Processing Handbook/Illustrations/page_420/page_420.pde @@ -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(); } diff --git a/java/examples/Demos/Performance/CubicGridRetained/CubicGridRetained.pde b/java/examples/Demos/Performance/CubicGridRetained/CubicGridRetained.pde index 1e833810b..70906fbde 100644 --- a/java/examples/Demos/Performance/CubicGridRetained/CubicGridRetained.pde +++ b/java/examples/Demos/Performance/CubicGridRetained/CubicGridRetained.pde @@ -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); } diff --git a/java/examples/Topics/File IO/TileImages/TileImages.pde b/java/examples/Topics/File IO/TileImages/TileImages.pde index 00af7c634..d577e275e 100644 --- a/java/examples/Topics/File IO/TileImages/TileImages.pde +++ b/java/examples/Topics/File IO/TileImages/TileImages.pde @@ -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); -} +} \ No newline at end of file