diff --git a/android/examples/Basics/Arrays/Array/applet/Array.java b/android/examples/Basics/Arrays/Array/applet/Array.java deleted file mode 100644 index 3beda6698..000000000 --- a/android/examples/Basics/Arrays/Array/applet/Array.java +++ /dev/null @@ -1,56 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Array extends PApplet { - public void setup() {/** - * Array. - * - * An array is a list of data. Each piece of data in an array - * is identified by an index number representing its position in - * the array. Arrays are zero based, which means that the first - * element in the array is [0], the second element is [1], and so on. - * In this example, an array named "coswav" is created and - * filled with the cosine values. This data is displayed three - * separate ways on the screen. - */ - -size(200, 200); - -float[] coswave = new float[width]; - -for (int i = 0; i < width; i++) { - float amount = map(i, 0, width, 0, PI); - coswave[i] = abs(cos(amount)); -} - -for (int i = 0; i < width; i++) { - stroke(coswave[i]*255); - line(i, 0, i, height/3); -} - -for (int i = 0; i < width; i++) { - stroke(coswave[i]*255 / 4); - line(i, height/3, i, height/3*2); -} - -for (int i = 0; i < width; i++) { - stroke(255 - coswave[i]*255); - line(i, height/3*2, i, height); -} - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Array" }); - } -} diff --git a/android/examples/Basics/Arrays/Array/applet/Array.pde b/android/examples/Basics/Arrays/Array/applet/Array.pde deleted file mode 100644 index a981fa470..000000000 --- a/android/examples/Basics/Arrays/Array/applet/Array.pde +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Array. - * - * An array is a list of data. Each piece of data in an array - * is identified by an index number representing its position in - * the array. Arrays are zero based, which means that the first - * element in the array is [0], the second element is [1], and so on. - * In this example, an array named "coswav" is created and - * filled with the cosine values. This data is displayed three - * separate ways on the screen. - */ - -size(200, 200); - -float[] coswave = new float[width]; - -for (int i = 0; i < width; i++) { - float amount = map(i, 0, width, 0, PI); - coswave[i] = abs(cos(amount)); -} - -for (int i = 0; i < width; i++) { - stroke(coswave[i]*255); - line(i, 0, i, height/3); -} - -for (int i = 0; i < width; i++) { - stroke(coswave[i]*255 / 4); - line(i, height/3, i, height/3*2); -} - -for (int i = 0; i < width; i++) { - stroke(255 - coswave[i]*255); - line(i, height/3*2, i, height); -} diff --git a/android/examples/Basics/Arrays/Array/applet/loading.gif b/android/examples/Basics/Arrays/Array/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Arrays/Array/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Arrays/Array2D/applet/Array2D.java b/android/examples/Basics/Arrays/Array2D/applet/Array2D.java deleted file mode 100644 index ee25d0c53..000000000 --- a/android/examples/Basics/Arrays/Array2D/applet/Array2D.java +++ /dev/null @@ -1,53 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Array2D extends PApplet { - public void setup() {/** - * Array 2D. - * - * Demonstrates the syntax for creating a two-dimensional (2D) array. - * Values in a 2D array are accessed through two index values. - * 2D arrays are useful for storing images. In this example, each dot - * is colored in relation to its distance from the center of the image. - */ - -float[][] distances; -float maxDistance; - -size(200, 200); -background(0); -maxDistance = dist(width/2, height/2, width, height); -distances = new float[width][height]; -for(int i=0; i= size || x <= 0) { - xdir *= -1; - x = x + (1 * xdir); - y = y + (1 * ydir); - } - if (y >= size || y <= 0) { - ydir *= -1; - y = y + (1 * ydir); - } - } - - // Custom method for drawing the object - public void draw() { - stroke(second()*4); - point(mx+x-1, my+y-1); - } -} - - - - static public void main(String args[]) { - PApplet.main(new String[] { "ArrayObjects" }); - } -} diff --git a/android/examples/Basics/Arrays/ArrayObjects/applet/ArrayObjects.pde b/android/examples/Basics/Arrays/ArrayObjects/applet/ArrayObjects.pde deleted file mode 100644 index c2ea3b4a2..000000000 --- a/android/examples/Basics/Arrays/ArrayObjects/applet/ArrayObjects.pde +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Array Objects. - * - * Demonstrates the syntax for creating an array of custom objects. - */ - -int unit = 40; -int num; -Module[] mods; - -void setup() -{ - size(200, 200); - background(176); - noStroke(); - - num = width/unit * width/unit; - mods = new Module[num]; - - for (int i=0; i= size || x <= 0) { - xdir *= -1; - x = x + (1 * xdir); - y = y + (1 * ydir); - } - if (y >= size || y <= 0) { - ydir *= -1; - y = y + (1 * ydir); - } - } - - // Custom method for drawing the object - void draw() { - stroke(second()*4); - point(mx+x-1, my+y-1); - } -} - - diff --git a/android/examples/Basics/Arrays/ArrayObjects/applet/loading.gif b/android/examples/Basics/Arrays/ArrayObjects/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Arrays/ArrayObjects/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/Brightness/applet/Brightness.java b/android/examples/Basics/Color/Brightness/applet/Brightness.java deleted file mode 100644 index 03e7c208c..000000000 --- a/android/examples/Basics/Color/Brightness/applet/Brightness.java +++ /dev/null @@ -1,51 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Brightness extends PApplet { - -/** - * Brightness - * by Rusty Robison. - * - * Brightness is the relative lightness or darkness of a color. - * Move the cursor vertically over each bar to alter its brightness. - */ - -int barWidth = 5; -int[] brightness; - -public void setup() -{ - size(200, 200); - colorMode(HSB, 360, height, height); - brightness = new int[width/barWidth]; -} - -public void draw() -{ - int j = 0; - for (int i = 0; i <= (width-barWidth); i += barWidth) { - noStroke(); - if ((mouseX > i) && (mouseX < i+barWidth)) { - brightness[j] = mouseY; - } - fill(i, height, brightness[j]); - rect(i, 0, barWidth, height); - j++; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Brightness" }); - } -} diff --git a/android/examples/Basics/Color/Brightness/applet/Brightness.pde b/android/examples/Basics/Color/Brightness/applet/Brightness.pde deleted file mode 100644 index c9dba6d28..000000000 --- a/android/examples/Basics/Color/Brightness/applet/Brightness.pde +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Brightness - * by Rusty Robison. - * - * Brightness is the relative lightness or darkness of a color. - * Move the cursor vertically over each bar to alter its brightness. - */ - -int barWidth = 5; -int[] brightness; - -void setup() -{ - size(200, 200); - colorMode(HSB, 360, height, height); - brightness = new int[width/barWidth]; -} - -void draw() -{ - int j = 0; - for (int i = 0; i <= (width-barWidth); i += barWidth) { - noStroke(); - if ((mouseX > i) && (mouseX < i+barWidth)) { - brightness[j] = mouseY; - } - fill(i, height, brightness[j]); - rect(i, 0, barWidth, height); - j++; - } -} diff --git a/android/examples/Basics/Color/Brightness/applet/loading.gif b/android/examples/Basics/Color/Brightness/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/Brightness/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/ColorWheel/applet/ColorWheel.java b/android/examples/Basics/Color/ColorWheel/applet/ColorWheel.java deleted file mode 100644 index c9ecabb74..000000000 --- a/android/examples/Basics/Color/ColorWheel/applet/ColorWheel.java +++ /dev/null @@ -1,99 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class ColorWheel extends PApplet { - -/** - * Subtractive Color Wheel - * by Ira Greenberg. - * - * The primaries are red, yellow, and blue. The - * secondaries are green, purple, and orange. The - * tertiaries are yellow-orange, red-orange, red-purple, - * blue-purple, blue-green, and yellow-green. - * - * Create a shade or tint of the - * subtractive color wheel using - * SHADE or TINT parameters. - */ - -int segs = 12; -int steps = 6; -float rotAdjust = radians(360.0f/segs/2.0f); -float radius = 95.0f; -float segWidth = radius/steps; -float interval = TWO_PI/segs; -int SHADE = 0; -int TINT = 1; - -public void setup(){ - size(200, 200); - background(127); - smooth(); - ellipseMode(CENTER_RADIUS); - noStroke(); - // you can substitue TINT for SHADE argument - createWheel(width/2, height/2, SHADE); -} - -public void createWheel(int x, int y, int valueShift){ - if (valueShift == SHADE){ - for (int j=0; j i) && (mouseX < i+barWidth)) { - hue[j] = mouseY; - } - fill(hue[j], height/1.2f, height/1.2f); - rect(i, 0, barWidth, height); - j++; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Hue" }); - } -} diff --git a/android/examples/Basics/Color/Hue/applet/Hue.pde b/android/examples/Basics/Color/Hue/applet/Hue.pde deleted file mode 100644 index b22ffb535..000000000 --- a/android/examples/Basics/Color/Hue/applet/Hue.pde +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Hue. - * - * Hue is the color reflected from or transmitted through an object - * and is typically referred to as the name of the color (red, blue, yellow, etc.) - * Move the cursor vertically over each bar to alter its hue. - */ - -int barWidth = 5; -int[] hue; - -void setup() -{ - size(200, 200); - colorMode(HSB, 360, height, height); - hue = new int[width/barWidth]; - noStroke(); -} - -void draw() -{ - int j = 0; - for (int i=0; i<=(width-barWidth); i+=barWidth) { - if ((mouseX > i) && (mouseX < i+barWidth)) { - hue[j] = mouseY; - } - fill(hue[j], height/1.2, height/1.2); - rect(i, 0, barWidth, height); - j++; - } -} diff --git a/android/examples/Basics/Color/Hue/applet/loading.gif b/android/examples/Basics/Color/Hue/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/Hue/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.java b/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.java deleted file mode 100644 index 6fbbc5c2e..000000000 --- a/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.java +++ /dev/null @@ -1,93 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class LinearGradient extends PApplet { - -/** - * Simple Linear Gradient - * by Ira Greenberg. - * - * Using the convenient red(), green() - * and blue() component functions, - * generate some linear gradients. - */ - -// constants -int Y_AXIS = 1; -int X_AXIS = 2; - -public void setup(){ - size(200, 200); - - // create some gradients - // background - int b1 = color(190, 190, 190); - int b2 = color(20, 20, 20); - setGradient(0, 0, width, height, b1, b2, Y_AXIS); - //center squares - int c1 = color(255, 120, 0); - int c2 = color(10, 45, 255); - int c3 = color(10, 255, 15); - int c4 = color(125, 2, 140); - int c5 = color(255, 255, 0); - int c6 = color(25, 255, 200); - setGradient(25, 25, 75, 75, c1, c2, Y_AXIS); - setGradient(100, 25, 75, 75, c3, c4, X_AXIS); - setGradient(25, 100, 75, 75, c2, c5, X_AXIS); - setGradient(100, 100, 75, 75, c4, c6, Y_AXIS); -} - -public void setGradient(int x, int y, float w, float h, int c1, int c2, int axis ){ - // calculate differences between color components - float deltaR = red(c2)-red(c1); - float deltaG = green(c2)-green(c1); - float deltaB = blue(c2)-blue(c1); - - // choose axis - if(axis == Y_AXIS){ - /*nested for loops set pixels - in a basic table structure */ - // column - for (int i=x; i<=(x+w); i++){ - // row - for (int j = y; j<=(y+h); j++){ - int c = color( - (red(c1)+(j-y)*(deltaR/h)), - (green(c1)+(j-y)*(deltaG/h)), - (blue(c1)+(j-y)*(deltaB/h)) - ); - set(i, j, c); - } - } - } - else if(axis == X_AXIS){ - // column - for (int i=y; i<=(y+h); i++){ - // row - for (int j = x; j<=(x+w); j++){ - int c = color( - (red(c1)+(j-x)*(deltaR/h)), - (green(c1)+(j-x)*(deltaG/h)), - (blue(c1)+(j-x)*(deltaB/h)) - ); - set(j, i, c); - } - } - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "LinearGradient" }); - } -} diff --git a/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.pde b/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.pde deleted file mode 100644 index f41fc2b66..000000000 --- a/android/examples/Basics/Color/LinearGradient/applet/LinearGradient.pde +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Simple Linear Gradient - * by Ira Greenberg. - * - * Using the convenient red(), green() - * and blue() component functions, - * generate some linear gradients. - */ - -// constants -int Y_AXIS = 1; -int X_AXIS = 2; - -void setup(){ - size(200, 200); - - // create some gradients - // background - color b1 = color(190, 190, 190); - color b2 = color(20, 20, 20); - setGradient(0, 0, width, height, b1, b2, Y_AXIS); - //center squares - color c1 = color(255, 120, 0); - color c2 = color(10, 45, 255); - color c3 = color(10, 255, 15); - color c4 = color(125, 2, 140); - color c5 = color(255, 255, 0); - color c6 = color(25, 255, 200); - setGradient(25, 25, 75, 75, c1, c2, Y_AXIS); - setGradient(100, 25, 75, 75, c3, c4, X_AXIS); - setGradient(25, 100, 75, 75, c2, c5, X_AXIS); - setGradient(100, 100, 75, 75, c4, c6, Y_AXIS); -} - -void setGradient(int x, int y, float w, float h, color c1, color c2, int axis ){ - // calculate differences between color components - float deltaR = red(c2)-red(c1); - float deltaG = green(c2)-green(c1); - float deltaB = blue(c2)-blue(c1); - - // choose axis - if(axis == Y_AXIS){ - /*nested for loops set pixels - in a basic table structure */ - // column - for (int i=x; i<=(x+w); i++){ - // row - for (int j = y; j<=(y+h); j++){ - color c = color( - (red(c1)+(j-y)*(deltaR/h)), - (green(c1)+(j-y)*(deltaG/h)), - (blue(c1)+(j-y)*(deltaB/h)) - ); - set(i, j, c); - } - } - } - else if(axis == X_AXIS){ - // column - for (int i=y; i<=(y+h); i++){ - // row - for (int j = x; j<=(x+w); j++){ - color c = color( - (red(c1)+(j-x)*(deltaR/h)), - (green(c1)+(j-x)*(deltaG/h)), - (blue(c1)+(j-x)*(deltaB/h)) - ); - set(j, i, c); - } - } - } -} - diff --git a/android/examples/Basics/Color/LinearGradient/applet/loading.gif b/android/examples/Basics/Color/LinearGradient/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/LinearGradient/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.java b/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.java deleted file mode 100644 index 1ba6eaa19..000000000 --- a/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.java +++ /dev/null @@ -1,78 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class RadialGradient extends PApplet { - -/** - * Simple Radial Gradient - * by Ira Greenberg. - * - * Using the convenient red(), green() - * and blue() component functions, - * generate an array of radial gradients. - */ - -public void setup(){ - size(200, 200); - background(0); - smooth(); - - // create a simple table of gradients - int columns = 4; - int radius = (width/columns)/2; - // create some gradients - for (int i=radius; i< width; i+=radius*2){ - for (int j =radius; j< height; j+=radius*2){ - createGradient(i, j, radius, - color(PApplet.parseInt(random(255)), PApplet.parseInt(random(255)), PApplet.parseInt(random(255))), - color(PApplet.parseInt(random(255)), PApplet.parseInt(random(255)), PApplet.parseInt(random(255)))); - } - } -} - -public void createGradient (float x, float y, float radius, int c1, int c2){ - float px = 0, py = 0, angle = 0; - - // calculate differences between color components - float deltaR = red(c2)-red(c1); - float deltaG = green(c2)-green(c1); - float deltaB = blue(c2)-blue(c1); - // hack to ensure there are no holes in gradient - // needs to be increased, as radius increases - float gapFiller = 8.0f; - - for (int i=0; i< radius; i++){ - for (float j=0; j<360; j+=1.0f/gapFiller){ - px = x+cos(radians(angle))*i; - py = y+sin(radians(angle))*i; - angle+=1.0f/gapFiller; - int c = color( - (red(c1)+(i)*(deltaR/radius)), - (green(c1)+(i)*(deltaG/radius)), - (blue(c1)+(i)*(deltaB/radius)) - ); - set(PApplet.parseInt(px), PApplet.parseInt(py), c); - } - } - // adds smooth edge - // hack anti-aliasing - noFill(); - strokeWeight(3); - ellipse(x, y, radius*2, radius*2); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "RadialGradient" }); - } -} diff --git a/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.pde b/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.pde deleted file mode 100644 index f5ba2b3fe..000000000 --- a/android/examples/Basics/Color/RadialGradient/applet/RadialGradient.pde +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Simple Radial Gradient - * by Ira Greenberg. - * - * Using the convenient red(), green() - * and blue() component functions, - * generate an array of radial gradients. - */ - -void setup(){ - size(200, 200); - background(0); - smooth(); - - // create a simple table of gradients - int columns = 4; - int radius = (width/columns)/2; - // create some gradients - for (int i=radius; i< width; i+=radius*2){ - for (int j =radius; j< height; j+=radius*2){ - createGradient(i, j, radius, - color(int(random(255)), int(random(255)), int(random(255))), - color(int(random(255)), int(random(255)), int(random(255)))); - } - } -} - -void createGradient (float x, float y, float radius, color c1, color c2){ - float px = 0, py = 0, angle = 0; - - // calculate differences between color components - float deltaR = red(c2)-red(c1); - float deltaG = green(c2)-green(c1); - float deltaB = blue(c2)-blue(c1); - // hack to ensure there are no holes in gradient - // needs to be increased, as radius increases - float gapFiller = 8.0; - - for (int i=0; i< radius; i++){ - for (float j=0; j<360; j+=1.0/gapFiller){ - px = x+cos(radians(angle))*i; - py = y+sin(radians(angle))*i; - angle+=1.0/gapFiller; - color c = color( - (red(c1)+(i)*(deltaR/radius)), - (green(c1)+(i)*(deltaG/radius)), - (blue(c1)+(i)*(deltaB/radius)) - ); - set(int(px), int(py), c); - } - } - // adds smooth edge - // hack anti-aliasing - noFill(); - strokeWeight(3); - ellipse(x, y, radius*2, radius*2); -} - diff --git a/android/examples/Basics/Color/RadialGradient/applet/loading.gif b/android/examples/Basics/Color/RadialGradient/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/RadialGradient/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/Reading/applet/Reading.java b/android/examples/Basics/Color/Reading/applet/Reading.java deleted file mode 100644 index 5ce02d462..000000000 --- a/android/examples/Basics/Color/Reading/applet/Reading.java +++ /dev/null @@ -1,63 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Reading extends PApplet { - public void setup() {/** - * Reading. - * - * An image is recreated from its individual component colors. - * The many colors of the image are created through modulating the - * red, green, and blue values. This is an exageration of an LCD display. - */ - -size(200, 200); -noStroke(); -background(0); - -// Load an image from the data directory -PImage c; -c = loadImage("cait.jpg"); - -int xoff = 0; -int yoff = 0; -int p = 2; -int pix = p*3; - - -for(int i = 0; i < c.width*c.height; i += 1) -{ - int here = c.pixels[i]; - - fill(red(here), 0, 0); - rect(xoff, yoff, p, pix); - - fill(0, green(here), 0); - rect(xoff+p, yoff, p, pix); - - fill(0, 0, blue(here)); - rect(xoff+p*2, yoff, p, pix); - - xoff+=pix; - if(xoff >= width-pix) { - xoff = 0; - yoff += pix; - } -} - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Reading" }); - } -} diff --git a/android/examples/Basics/Color/Reading/applet/Reading.pde b/android/examples/Basics/Color/Reading/applet/Reading.pde deleted file mode 100644 index 6f1ec2042..000000000 --- a/android/examples/Basics/Color/Reading/applet/Reading.pde +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Reading. - * - * An image is recreated from its individual component colors. - * The many colors of the image are created through modulating the - * red, green, and blue values. This is an exageration of an LCD display. - */ - -size(200, 200); -noStroke(); -background(0); - -// Load an image from the data directory -PImage c; -c = loadImage("cait.jpg"); - -int xoff = 0; -int yoff = 0; -int p = 2; -int pix = p*3; - - -for(int i = 0; i < c.width*c.height; i += 1) -{ - int here = c.pixels[i]; - - fill(red(here), 0, 0); - rect(xoff, yoff, p, pix); - - fill(0, green(here), 0); - rect(xoff+p, yoff, p, pix); - - fill(0, 0, blue(here)); - rect(xoff+p*2, yoff, p, pix); - - xoff+=pix; - if(xoff >= width-pix) { - xoff = 0; - yoff += pix; - } -} - diff --git a/android/examples/Basics/Color/Reading/applet/loading.gif b/android/examples/Basics/Color/Reading/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/Reading/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/Relativity/applet/Relativity.java b/android/examples/Basics/Color/Relativity/applet/Relativity.java deleted file mode 100644 index 3612db49e..000000000 --- a/android/examples/Basics/Color/Relativity/applet/Relativity.java +++ /dev/null @@ -1,62 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Relativity extends PApplet { - -/** - * Relativity. - * - * Each color is perceived in relation to other colors. - * The top and bottom bars each contain the same component colors, - * but a different display order causes individual colors to appear differently. - */ - -int a, b, c, d, e; - -public void setup() { - size(200, 200); - noStroke(); - a = color(165, 167, 20); - b = color(77, 86, 59); - c = color(42, 106, 105); - d = color(165, 89, 20); - e = color(146, 150, 127); - noLoop(); -} - -public void draw() { - drawBand(a, b, c, d, e, 0, 4); - drawBand(c, a, d, b, e, height/2, 4); -} - -public void drawBand(int v, int w, int x, int y, int z, int ypos, int barWidth) { - int num = 5; - int[] colorOrder = { v, w, x, y, z }; - for(int i = 0; i < width; i += barWidth*num) { - for(int j = 0; j < num; j++) { - fill(colorOrder[j]); - rect(i+j*barWidth, ypos, barWidth, height/2); - } - } -} - - - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Relativity" }); - } -} diff --git a/android/examples/Basics/Color/Relativity/applet/Relativity.pde b/android/examples/Basics/Color/Relativity/applet/Relativity.pde deleted file mode 100644 index 59a3365a6..000000000 --- a/android/examples/Basics/Color/Relativity/applet/Relativity.pde +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Relativity. - * - * Each color is perceived in relation to other colors. - * The top and bottom bars each contain the same component colors, - * but a different display order causes individual colors to appear differently. - */ - -color a, b, c, d, e; - -void setup() { - size(200, 200); - noStroke(); - a = color(165, 167, 20); - b = color(77, 86, 59); - c = color(42, 106, 105); - d = color(165, 89, 20); - e = color(146, 150, 127); - noLoop(); -} - -void draw() { - drawBand(a, b, c, d, e, 0, 4); - drawBand(c, a, d, b, e, height/2, 4); -} - -void drawBand(color v, color w, color x, color y, color z, int ypos, int barWidth) { - int num = 5; - color[] colorOrder = { v, w, x, y, z }; - for(int i = 0; i < width; i += barWidth*num) { - for(int j = 0; j < num; j++) { - fill(colorOrder[j]); - rect(i+j*barWidth, ypos, barWidth, height/2); - } - } -} - - - - - - diff --git a/android/examples/Basics/Color/Relativity/applet/loading.gif b/android/examples/Basics/Color/Relativity/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/Relativity/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/Saturation/applet/Saturation.java b/android/examples/Basics/Color/Saturation/applet/Saturation.java deleted file mode 100644 index 62ac4f2f0..000000000 --- a/android/examples/Basics/Color/Saturation/applet/Saturation.java +++ /dev/null @@ -1,52 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Saturation extends PApplet { - -/** - * Saturation. - * - * Saturation is the strength or purity of the color and represents the - * amount of gray in proportion to the hue. A "saturated" color is pure - * and an "unsaturated" color has a large percentage of gray. - * Move the cursor vertically over each bar to alter its saturation. - */ - -int barWidth = 5; -int[] saturation; - -public void setup() -{ - size(200, 200); - colorMode(HSB, 360, height, height); - saturation = new int[width/barWidth]; -} - -public void draw() -{ - int j = 0; - for (int i=0; i<=(width-barWidth); i+=barWidth) { - noStroke(); - if ((mouseX > i) && (mouseX < i+barWidth)) { - saturation[j] = mouseY; - } - fill(i, saturation[j], height/1.5f); - rect(i, 0, barWidth, height); - j++; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Saturation" }); - } -} diff --git a/android/examples/Basics/Color/Saturation/applet/Saturation.pde b/android/examples/Basics/Color/Saturation/applet/Saturation.pde deleted file mode 100644 index 0902ead92..000000000 --- a/android/examples/Basics/Color/Saturation/applet/Saturation.pde +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Saturation. - * - * Saturation is the strength or purity of the color and represents the - * amount of gray in proportion to the hue. A "saturated" color is pure - * and an "unsaturated" color has a large percentage of gray. - * Move the cursor vertically over each bar to alter its saturation. - */ - -int barWidth = 5; -int[] saturation; - -void setup() -{ - size(200, 200); - colorMode(HSB, 360, height, height); - saturation = new int[width/barWidth]; -} - -void draw() -{ - int j = 0; - for (int i=0; i<=(width-barWidth); i+=barWidth) { - noStroke(); - if ((mouseX > i) && (mouseX < i+barWidth)) { - saturation[j] = mouseY; - } - fill(i, saturation[j], height/1.5); - rect(i, 0, barWidth, height); - j++; - } -} diff --git a/android/examples/Basics/Color/Saturation/applet/loading.gif b/android/examples/Basics/Color/Saturation/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Color/Saturation/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Color/WaveGradient/applet/WaveGradient.java b/android/examples/Basics/Color/WaveGradient/applet/WaveGradient.java deleted file mode 100644 index c5cdd68ff..000000000 --- a/android/examples/Basics/Color/WaveGradient/applet/WaveGradient.java +++ /dev/null @@ -1,59 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class WaveGradient extends PApplet { - -/** - * Wave Gradient - * by Ira Greenberg. - * - * Generate a gradient along a sin() wave. - */ - -float angle = 0; -float px = 0, py = 0; -float amplitude = 30; -float frequency = 0; -float fillGap = 2.5f; -int c; - -public void setup() { - size(200, 200); - background(200,200,200); - noLoop(); -} - -public void draw() { - for (int i =- 75; i < height+75; i++){ - // Reset angle to 0, so waves stack properly - angle = 0; - // Increasing frequency causes more gaps - frequency+=.006f; - for (float j=0; j 0){ - for(int j = margin; j < width-margin; j+= box_space){ - fill(255-box_size*10); - rect(j, i, box_size, box_size); - } - box_size = box_size - 0.6f; - } -} - - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "EmbeddedIteration" }); - } -} diff --git a/android/examples/Basics/Control/EmbeddedIteration/applet/EmbeddedIteration.pde b/android/examples/Basics/Control/EmbeddedIteration/applet/EmbeddedIteration.pde deleted file mode 100644 index 3473aca2e..000000000 --- a/android/examples/Basics/Control/EmbeddedIteration/applet/EmbeddedIteration.pde +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Embedding Iteration. - * - * Embedding "for" structures allows repetition in two dimensions. - */ - -float box_size = 11; -float box_space = 12; -int margin = 7; - -size(200, 200); -background(0); -noStroke(); - -// Draw gray boxes - -for (int i = margin; i < height-margin; i += box_space){ - if(box_size > 0){ - for(int j = margin; j < width-margin; j+= box_space){ - fill(255-box_size*10); - rect(j, i, box_size, box_size); - } - box_size = box_size - 0.6; - } -} - - diff --git a/android/examples/Basics/Control/EmbeddedIteration/applet/loading.gif b/android/examples/Basics/Control/EmbeddedIteration/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Control/EmbeddedIteration/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Control/Iteration/applet/Iteration.java b/android/examples/Basics/Control/Iteration/applet/Iteration.java deleted file mode 100644 index 56274253b..000000000 --- a/android/examples/Basics/Control/Iteration/applet/Iteration.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Iteration extends PApplet { - public void setup() {/** - * Iteration. - * - * Iteration with a "for" structure constructs repetitive forms. - */ - -int k; -int xpos1 = 100; -int xpos2 = 118; -int count = 0; -int timey = 0; -int num = 12; - -size(200, 200); -background(102); -noStroke(); - -// Draw gray bars -fill(255); -k=60; -for(int i=0; i < num/3; i++) { - rect(25, k, 155, 5); - k+=10; -} - -// Black bars -fill(51); -k = 40; -for(int i=0; i < num; i++) { - rect(105, k, 30, 5); - k += 10; -} -k = 15; -for(int i = 0; i < num; i++) { - rect(125, k, 30, 5); - k +=10; -} - -// Thin lines -k = 42; -fill(0); -for(int i=0; i < num-1; i++) { - rect(36, k, 20, 1); - k+=10; -} - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Iteration" }); - } -} diff --git a/android/examples/Basics/Control/Iteration/applet/Iteration.pde b/android/examples/Basics/Control/Iteration/applet/Iteration.pde deleted file mode 100644 index 722806122..000000000 --- a/android/examples/Basics/Control/Iteration/applet/Iteration.pde +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Iteration. - * - * Iteration with a "for" structure constructs repetitive forms. - */ - -int k; -int xpos1 = 100; -int xpos2 = 118; -int count = 0; -int timey = 0; -int num = 12; - -size(200, 200); -background(102); -noStroke(); - -// Draw gray bars -fill(255); -k=60; -for(int i=0; i < num/3; i++) { - rect(25, k, 155, 5); - k+=10; -} - -// Black bars -fill(51); -k = 40; -for(int i=0; i < num; i++) { - rect(105, k, 30, 5); - k += 10; -} -k = 15; -for(int i = 0; i < num; i++) { - rect(125, k, 30, 5); - k +=10; -} - -// Thin lines -k = 42; -fill(0); -for(int i=0; i < num-1; i++) { - rect(36, k, 20, 1); - k+=10; -} diff --git a/android/examples/Basics/Control/Iteration/applet/loading.gif b/android/examples/Basics/Control/Iteration/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Control/Iteration/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.java b/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.java deleted file mode 100644 index bf9354786..000000000 --- a/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class LogicalOperators extends PApplet { - public void setup() {/** - * Logical Operators. - * - * The logical operators for AND (&&) and OR (||) are used to - * combine simple relational statements into more complex expressions. - * The NOT (!) operator is used to negate a boolean statement. - */ - -size(200, 200); -background(126); - -boolean op = false; - -for(int i=5; i<=195; i+=5) { - // Logical AND - stroke(0); - if((i > 35) && (i < 100)) { - line(5, i, 95, i); - op = false; - } - - // Logical OR - stroke(76); - if((i <= 35) || (i >= 100)) { - line(105, i, 195, i); - op = true; - } - - // Testing if a boolean value is "true" - // The expression "if(op)" is equivalent to "if(op == true)" - if(op) { - stroke(0); - point(width/2, i); - } - - // Testing if a boolean value is "false" - // The expression "if(!op)" is equivalent to "if(op == false)" - if(!op) { - stroke(255); - point(width/4, i); - } -} - - - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "LogicalOperators" }); - } -} diff --git a/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.pde b/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.pde deleted file mode 100644 index d9329c004..000000000 --- a/android/examples/Basics/Control/LogicalOperators/applet/LogicalOperators.pde +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Logical Operators. - * - * The logical operators for AND (&&) and OR (||) are used to - * combine simple relational statements into more complex expressions. - * The NOT (!) operator is used to negate a boolean statement. - */ - -size(200, 200); -background(126); - -boolean op = false; - -for(int i=5; i<=195; i+=5) { - // Logical AND - stroke(0); - if((i > 35) && (i < 100)) { - line(5, i, 95, i); - op = false; - } - - // Logical OR - stroke(76); - if((i <= 35) || (i >= 100)) { - line(105, i, 195, i); - op = true; - } - - // Testing if a boolean value is "true" - // The expression "if(op)" is equivalent to "if(op == true)" - if(op) { - stroke(0); - point(width/2, i); - } - - // Testing if a boolean value is "false" - // The expression "if(!op)" is equivalent to "if(op == false)" - if(!op) { - stroke(255); - point(width/4, i); - } -} - - - diff --git a/android/examples/Basics/Control/LogicalOperators/applet/loading.gif b/android/examples/Basics/Control/LogicalOperators/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Control/LogicalOperators/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.java b/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.java deleted file mode 100644 index 6d3433d02..000000000 --- a/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.java +++ /dev/null @@ -1,101 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class CharactersStrings extends PApplet { - -/** - * Characters Strings. - * - * Click on the image to give it focus and then type letters to - * shift the location of the image. - * Characters are typographic symbols such as A, d, and %. - * The character datatype, abbreviated as char, stores letters and - * symbols in the Unicode format, a coding system developed to support - * a variety of world languages. Characters are distinguished from other - * symbols by putting them between single quotes ('P'). - * A string is a sequence of characters. A string is noted by surrounding - * a group of letters with double quotes ("Processing"). - * Chars and strings are most often used with the keyboard methods, - * to display text to the screen, and to load images or files. - */ - -PImage frog; -PFont fontA; -int lettersize = 90; -int xoffset; -char letter; - -public void setup() -{ - size(200, 200); - fontA = loadFont("Eureka90.vlw"); - textFont(fontA); - textSize(lettersize); - - // The String datatype must be capitalized because it is a complex datatype. - // A String is actually a class with its own methods, some of which are - // featured below. - String name= "rathausFrog"; - String extension = ".jpg"; - int nameLength = name.length(); - println("The length of " + name + " is " + nameLength + "."); - name = name.concat(extension); - nameLength = name.length(); - println("The length of " + name + " is " + nameLength + "."); - - // The parameter for the loadImage() method must be a string - // This line could also be written "frog = loadImage("rathausFrog.jpg"); - frog = loadImage(name); -} - -public void draw() -{ - background(51); // Set background to dark gray - - image(frog, xoffset, 0); - - // Draw an X - line(0, 0, width, height); - line(0, height, width, 0); - - // Get the width of the letter - int letterWidth = PApplet.parseInt(fontA.width(letter) * lettersize); - - // Draw the letter to the center of the screen - text(letter, width/2-letterWidth/2, height/2); -} - -public void keyPressed() -{ - // The variable "key" always contains the value of the most recent key pressed. - // If the key is an upper or lowercase letter between 'A' and 'z' - // the image is shifted to the corresponding value of that key - if(key >= 'A' && key <= 'z') { - letter = PApplet.parseChar(key); - // Scale the values to numbers between 0 and 100 - float scale = 100.0f/57.0f; - int temp = PApplet.parseInt((key - 'A') * scale); - // Set the offset for the image - xoffset = temp; - println(key); - } -} - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "CharactersStrings" }); - } -} diff --git a/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.pde b/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.pde deleted file mode 100644 index 868037671..000000000 --- a/android/examples/Basics/Data/CharactersStrings/applet/CharactersStrings.pde +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Characters Strings. - * - * Click on the image to give it focus and then type letters to - * shift the location of the image. - * Characters are typographic symbols such as A, d, and %. - * The character datatype, abbreviated as char, stores letters and - * symbols in the Unicode format, a coding system developed to support - * a variety of world languages. Characters are distinguished from other - * symbols by putting them between single quotes ('P'). - * A string is a sequence of characters. A string is noted by surrounding - * a group of letters with double quotes ("Processing"). - * Chars and strings are most often used with the keyboard methods, - * to display text to the screen, and to load images or files. - */ - -PImage frog; -PFont fontA; -int lettersize = 90; -int xoffset; -char letter; - -void setup() -{ - size(200, 200); - fontA = loadFont("Eureka90.vlw"); - textFont(fontA); - textSize(lettersize); - - // The String datatype must be capitalized because it is a complex datatype. - // A String is actually a class with its own methods, some of which are - // featured below. - String name= "rathausFrog"; - String extension = ".jpg"; - int nameLength = name.length(); - println("The length of " + name + " is " + nameLength + "."); - name = name.concat(extension); - nameLength = name.length(); - println("The length of " + name + " is " + nameLength + "."); - - // The parameter for the loadImage() method must be a string - // This line could also be written "frog = loadImage("rathausFrog.jpg"); - frog = loadImage(name); -} - -void draw() -{ - background(51); // Set background to dark gray - - image(frog, xoffset, 0); - - // Draw an X - line(0, 0, width, height); - line(0, height, width, 0); - - // Get the width of the letter - int letterWidth = int(fontA.width(letter) * lettersize); - - // Draw the letter to the center of the screen - text(letter, width/2-letterWidth/2, height/2); -} - -void keyPressed() -{ - // The variable "key" always contains the value of the most recent key pressed. - // If the key is an upper or lowercase letter between 'A' and 'z' - // the image is shifted to the corresponding value of that key - if(key >= 'A' && key <= 'z') { - letter = char(key); - // Scale the values to numbers between 0 and 100 - float scale = 100.0/57.0; - int temp = int((key - 'A') * scale); - // Set the offset for the image - xoffset = temp; - println(key); - } -} - - - - diff --git a/android/examples/Basics/Data/CharactersStrings/applet/loading.gif b/android/examples/Basics/Data/CharactersStrings/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/CharactersStrings/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.java b/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.java deleted file mode 100644 index d9b5077a0..000000000 --- a/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.java +++ /dev/null @@ -1,49 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class DatatypeConversion extends PApplet { - public void setup() {/** - * Datatype Conversion. - * - * It is sometimes beneficial to convert a value from one type of - * data to another. Each of the conversion functions converts its parameter - * to an equivalent representation within its datatype. - * The conversion functions include int(), float(), char(), byte(), and others. - */ - -size(200, 200); -background(51); -noStroke(); - -char c; // Chars are used for storing typographic symbols -float f; // Floats are decimal numbers -int i; // Ints are values between 2,147,483,647 and -2147483648 -byte b; // Bytes are values between -128 and 128 - -c = 'A'; -f = PApplet.parseFloat(c); // Sets f = 65.0 -i = PApplet.parseInt(f * 1.4f); // Sets i to 91 -b = PApplet.parseByte(c / 2); // Sets b to 32 - -rect(f, 0, 40, 66); -fill(204); -rect(i, 67, 40, 66); -fill(255); -rect(b, 134, 40, 66); - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "DatatypeConversion" }); - } -} diff --git a/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.pde b/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.pde deleted file mode 100644 index 381afd181..000000000 --- a/android/examples/Basics/Data/DatatypeConversion/applet/DatatypeConversion.pde +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Datatype Conversion. - * - * It is sometimes beneficial to convert a value from one type of - * data to another. Each of the conversion functions converts its parameter - * to an equivalent representation within its datatype. - * The conversion functions include int(), float(), char(), byte(), and others. - */ - -size(200, 200); -background(51); -noStroke(); - -char c; // Chars are used for storing typographic symbols -float f; // Floats are decimal numbers -int i; // Ints are values between 2,147,483,647 and -2147483648 -byte b; // Bytes are values between -128 and 128 - -c = 'A'; -f = float(c); // Sets f = 65.0 -i = int(f * 1.4); // Sets i to 91 -b = byte(c / 2); // Sets b to 32 - -rect(f, 0, 40, 66); -fill(204); -rect(i, 67, 40, 66); -fill(255); -rect(b, 134, 40, 66); diff --git a/android/examples/Basics/Data/DatatypeConversion/applet/loading.gif b/android/examples/Basics/Data/DatatypeConversion/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/DatatypeConversion/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.java b/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.java deleted file mode 100644 index e705fde4c..000000000 --- a/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.java +++ /dev/null @@ -1,56 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class IntegersFloats extends PApplet { - -/** - * Integers Floats. - * - * Integers and floats are two different kinds of numerical data. - * An integer (more commonly called an int) is a number without - * a decimal point. A float is a floating-point number, which means - * it is a number that has a decimal place. Floats are used when - * more precision is needed. - */ - -int a = 0; // Create a variable "a" of the datatype "int" -float b = 0.0f; // Create a variable "b" of the datatype "float" - -public void setup() -{ - size(200, 200); - stroke(255); - frameRate(30); -} - -public void draw() -{ - background(51); - - a = a + 1; - b = b + 0.2f; - line(a, 0, a, height/2); - line(b, height/2, b, height); - - if(a > width) { - a = 0; - } - if(b > width) { - b = 0; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "IntegersFloats" }); - } -} diff --git a/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.pde b/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.pde deleted file mode 100644 index 87bf67f19..000000000 --- a/android/examples/Basics/Data/IntegersFloats/applet/IntegersFloats.pde +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Integers Floats. - * - * Integers and floats are two different kinds of numerical data. - * An integer (more commonly called an int) is a number without - * a decimal point. A float is a floating-point number, which means - * it is a number that has a decimal place. Floats are used when - * more precision is needed. - */ - -int a = 0; // Create a variable "a" of the datatype "int" -float b = 0.0; // Create a variable "b" of the datatype "float" - -void setup() -{ - size(200, 200); - stroke(255); - frameRate(30); -} - -void draw() -{ - background(51); - - a = a + 1; - b = b + 0.2; - line(a, 0, a, height/2); - line(b, height/2, b, height); - - if(a > width) { - a = 0; - } - if(b > width) { - b = 0; - } -} diff --git a/android/examples/Basics/Data/IntegersFloats/applet/loading.gif b/android/examples/Basics/Data/IntegersFloats/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/IntegersFloats/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.java b/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.java deleted file mode 100644 index 0d30054b6..000000000 --- a/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.java +++ /dev/null @@ -1,55 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class TrueFalse extends PApplet { - public void setup() {/** - * True/False. - * - * Boolean data is one bit of information. True or false. - * It is common to use Booleans with control statements to - * determine the flow of a program. In this example, when the - * boolean value "x" is true, vertical black lines are drawn and when - * the boolean value "x" is false, horizontal gray lines are drawn. - */ - -boolean x = false; - -size(200, 200); -background(0); -stroke(0); - -for (int i = 1; i < width; i += 2) -{ - if (i < width/2) { - x = true; - } else { - x = false; - } - - if (x) { - stroke(255); - line(i, 1, i, height-1); - } - - if (!x) { - stroke(126); - line(width/2 , i, width-2, i); - } -} - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "TrueFalse" }); - } -} diff --git a/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.pde b/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.pde deleted file mode 100644 index c4bb0531f..000000000 --- a/android/examples/Basics/Data/TrueFalse/applet/TrueFalse.pde +++ /dev/null @@ -1,34 +0,0 @@ -/** - * True/False. - * - * Boolean data is one bit of information. True or false. - * It is common to use Booleans with control statements to - * determine the flow of a program. In this example, when the - * boolean value "x" is true, vertical black lines are drawn and when - * the boolean value "x" is false, horizontal gray lines are drawn. - */ - -boolean x = false; - -size(200, 200); -background(0); -stroke(0); - -for (int i = 1; i < width; i += 2) -{ - if (i < width/2) { - x = true; - } else { - x = false; - } - - if (x) { - stroke(255); - line(i, 1, i, height-1); - } - - if (!x) { - stroke(126); - line(width/2 , i, width-2, i); - } -} diff --git a/android/examples/Basics/Data/TrueFalse/applet/loading.gif b/android/examples/Basics/Data/TrueFalse/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/TrueFalse/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/VariableScope/applet/VariableScope.java b/android/examples/Basics/Data/VariableScope/applet/VariableScope.java deleted file mode 100644 index 426ba59a1..000000000 --- a/android/examples/Basics/Data/VariableScope/applet/VariableScope.java +++ /dev/null @@ -1,81 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class VariableScope extends PApplet { - -/** - * Variable Scope. - * - * Variables may either have a global or local "scope". - * For example, variables declared within either the - * setup() or loop() functions may be only used in these - * functions. Global variables, variables declared outside - * of setup() and loop(), may be used anywhere within the program. - * If a local variable is declared with the same name as a - * global variable, the program will use the local variable to make - * its calculations within the current scope. Variables may be localized - * within classes, functions, and iterative statements. - */ - -int a = 20; // Create a global variable "a" - -public void setup() -{ - size(200, 200); - background(51); - stroke(255); - noLoop(); -} - -public void draw() -{ - // Draw a line using the global variable "a" - line(a, 0, a, height); - - // Create a new variable "a" local to the for() statement - for(int a=50; a<80; a += 2) { - line(a, 0, a, height); - } - - // Create a new variable "a" local to the loop() method - int a = 100; - // Draw a line using the new local variable "a" - line(a, 0, a, height); - - // Make a call to the custom function drawAnotherLine() - drawAnotherLine(); - - // Make a call to the custom function setYetAnotherLine() - drawYetAnotherLine(); -} - -public void drawAnotherLine() -{ - // Create a new variable "a" local to this method - int a = 185; - // Draw a line using the local variable "a" - line(a, 0, a, height); -} - -public void drawYetAnotherLine() -{ - // Because no new local variable "a" is set, - // this lines draws using the original global - // variable "a" which is set to the value 20. - line(a+2, 0, a+2, height); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "VariableScope" }); - } -} diff --git a/android/examples/Basics/Data/VariableScope/applet/VariableScope.pde b/android/examples/Basics/Data/VariableScope/applet/VariableScope.pde deleted file mode 100644 index 8c2ae3559..000000000 --- a/android/examples/Basics/Data/VariableScope/applet/VariableScope.pde +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Variable Scope. - * - * Variables may either have a global or local "scope". - * For example, variables declared within either the - * setup() or loop() functions may be only used in these - * functions. Global variables, variables declared outside - * of setup() and loop(), may be used anywhere within the program. - * If a local variable is declared with the same name as a - * global variable, the program will use the local variable to make - * its calculations within the current scope. Variables may be localized - * within classes, functions, and iterative statements. - */ - -int a = 20; // Create a global variable "a" - -void setup() -{ - size(200, 200); - background(51); - stroke(255); - noLoop(); -} - -void draw() -{ - // Draw a line using the global variable "a" - line(a, 0, a, height); - - // Create a new variable "a" local to the for() statement - for(int a=50; a<80; a += 2) { - line(a, 0, a, height); - } - - // Create a new variable "a" local to the loop() method - int a = 100; - // Draw a line using the new local variable "a" - line(a, 0, a, height); - - // Make a call to the custom function drawAnotherLine() - drawAnotherLine(); - - // Make a call to the custom function setYetAnotherLine() - drawYetAnotherLine(); -} - -void drawAnotherLine() -{ - // Create a new variable "a" local to this method - int a = 185; - // Draw a line using the local variable "a" - line(a, 0, a, height); -} - -void drawYetAnotherLine() -{ - // Because no new local variable "a" is set, - // this lines draws using the original global - // variable "a" which is set to the value 20. - line(a+2, 0, a+2, height); -} diff --git a/android/examples/Basics/Data/VariableScope/applet/loading.gif b/android/examples/Basics/Data/VariableScope/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/VariableScope/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Data/Variables/applet/Variables.java b/android/examples/Basics/Data/Variables/applet/Variables.java deleted file mode 100644 index 60471a43b..000000000 --- a/android/examples/Basics/Data/Variables/applet/Variables.java +++ /dev/null @@ -1,44 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Variables extends PApplet { - public void setup() {/** - * Variables. - * - * Variables are used for storing values. In this example, changing - * the values of variables 'a' and 'b' significantly change the composition. - */ - -size(200, 200); -background(0); -stroke(153); - -int a = 20; -int b = 50; -int c = a*8; -int d = a*9; -int e = b-a; -int f = b*2; -int g = f+e; - -line(a, f, b, g); -line(b, e, b, g); -line(b, e, d, c); -line(a, e, d-e, c); - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Variables" }); - } -} diff --git a/android/examples/Basics/Data/Variables/applet/Variables.pde b/android/examples/Basics/Data/Variables/applet/Variables.pde deleted file mode 100644 index 9566ae472..000000000 --- a/android/examples/Basics/Data/Variables/applet/Variables.pde +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Variables. - * - * Variables are used for storing values. In this example, changing - * the values of variables 'a' and 'b' significantly change the composition. - */ - -size(200, 200); -background(0); -stroke(153); - -int a = 20; -int b = 50; -int c = a*8; -int d = a*9; -int e = b-a; -int f = b*2; -int g = f+e; - -line(a, f, b, g); -line(b, e, b, g); -line(b, e, d, c); -line(a, e, d-e, c); diff --git a/android/examples/Basics/Data/Variables/applet/loading.gif b/android/examples/Basics/Data/Variables/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Data/Variables/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Form/Bezier/applet/Bezier.java b/android/examples/Basics/Form/Bezier/applet/Bezier.java deleted file mode 100644 index 1b0a14a3b..000000000 --- a/android/examples/Basics/Form/Bezier/applet/Bezier.java +++ /dev/null @@ -1,39 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Bezier extends PApplet { - public void setup() {/** - * Bezier. - * - * The first two parameters for the bezier() function specify the - * first point in the curve and the last two parameters specify - * the last point. The middle parameters set the control points - * that define the shape of the curve. - */ - -size(200, 200); -background(0); -stroke(255); -noFill(); -smooth(); - -for(int i = 0; i < 100; i += 20) { - bezier(90-(i/2.0f), 20+i, 210, 10, 220, 150, 120-(i/8.0f), 150+(i/4.0f)); -} - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Bezier" }); - } -} diff --git a/android/examples/Basics/Form/Bezier/applet/Bezier.pde b/android/examples/Basics/Form/Bezier/applet/Bezier.pde deleted file mode 100644 index e0b53db21..000000000 --- a/android/examples/Basics/Form/Bezier/applet/Bezier.pde +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Bezier. - * - * The first two parameters for the bezier() function specify the - * first point in the curve and the last two parameters specify - * the last point. The middle parameters set the control points - * that define the shape of the curve. - */ - -size(200, 200); -background(0); -stroke(255); -noFill(); -smooth(); - -for(int i = 0; i < 100; i += 20) { - bezier(90-(i/2.0), 20+i, 210, 10, 220, 150, 120-(i/8.0), 150+(i/4.0)); -} diff --git a/android/examples/Basics/Form/Bezier/applet/loading.gif b/android/examples/Basics/Form/Bezier/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Form/Bezier/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Form/BezierEllipse/applet/BezierEllipse.java b/android/examples/Basics/Form/BezierEllipse/applet/BezierEllipse.java deleted file mode 100644 index 7db24e9b7..000000000 --- a/android/examples/Basics/Form/BezierEllipse/applet/BezierEllipse.java +++ /dev/null @@ -1,123 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class BezierEllipse extends PApplet { - -/** - * Bezier Ellipse - * By Ira Greenberg - * - * Generates an ellipse using bezier() and - * trig functions. Approximately every 1/2 - * second a new ellipse is plotted using - * random values for control/anchor points. - */ - -// arrays to hold ellipse coordinate data -float[] px, py, cx, cy, cx2, cy2; - -// global variable-points in ellipse -int pts = 4; - -int controlPtCol = 0xff222222; -int anchorPtCol = 0xffBBBBBB; - -public void setup(){ - size(200, 200); - smooth(); - setEllipse(pts, 65, 65); - frameRate(1); -} - -public void draw(){ - background(145); - drawEllipse(); - setEllipse(PApplet.parseInt(random(3, 12)), random(-100, 150), random(-100, 150)); -} - -// draw ellipse with anchor/control points -public void drawEllipse(){ - strokeWeight(1.125f); - stroke(255); - noFill(); - // create ellipse - for (int i=0; i0){ - line(px[i], py[i], cx2[i-1], cy2[i-1]); - } - line(px[i], py[i], cx[i], cy[i]); - } - - for ( int i=0; i< pts; i++){ - fill(controlPtCol); - noStroke(); - //control handles - ellipse(cx[i], cy[i], 4, 4); - ellipse(cx2[i], cy2[i], 4, 4); - - fill(anchorPtCol); - stroke(0); - //anchor points - rect(px[i], py[i], 5, 5); - } -} - -// fill up arrays with ellipse coordinate data -public void setEllipse(int points, float radius, float controlRadius){ - pts = points; - px = new float[points]; - py = new float[points]; - cx = new float[points]; - cy = new float[points]; - cx2 = new float[points]; - cy2 = new float[points]; - float angle = 360.0f/points; - float controlAngle1 = angle/3.0f; - float controlAngle2 = controlAngle1*2.0f; - for ( int i=0; i0){ - line(px[i], py[i], cx2[i-1], cy2[i-1]); - } - line(px[i], py[i], cx[i], cy[i]); - } - - for ( int i=0; i< pts; i++){ - fill(controlPtCol); - noStroke(); - //control handles - ellipse(cx[i], cy[i], 4, 4); - ellipse(cx2[i], cy2[i], 4, 4); - - fill(anchorPtCol); - stroke(0); - //anchor points - rect(px[i], py[i], 5, 5); - } -} - -// fill up arrays with ellipse coordinate data -void setEllipse(int points, float radius, float controlRadius){ - pts = points; - px = new float[points]; - py = new float[points]; - cx = new float[points]; - cy = new float[points]; - cx2 = new float[points]; - cy2 = new float[points]; - float angle = 360.0/points; - float controlAngle1 = angle/3.0; - float controlAngle2 = controlAngle1*2.0; - for ( int i=0; i 1) { sa = 1; } - return 1-sa; -} - -public float squared(float sa) { - sa = sa*sa; - return sa; -} - - static public void main(String args[]) { - PApplet.main(new String[] { "SimpleCurves" }); - } -} diff --git a/android/examples/Basics/Form/SimpleCurves/applet/SimpleCurves.pde b/android/examples/Basics/Form/SimpleCurves/applet/SimpleCurves.pde deleted file mode 100644 index 8507d6dc1..000000000 --- a/android/examples/Basics/Form/SimpleCurves/applet/SimpleCurves.pde +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Simple Curves. - * - * Simple curves are drawn with simple equations. - * By using numbers with values between 0 and 1 in - * the equations, a series of elegant curves - * are created. The numbers are then scaled to fill the screen. - */ - -void setup() { - size(200, 200); - colorMode(RGB, 100); - background(0); - noFill(); - noLoop(); -} - -void draw() { - stroke(40); - beginShape(); - for(int i=0; i 1) { sa = 1; } - return 1-sa; -} - -float squared(float sa) { - sa = sa*sa; - return sa; -} diff --git a/android/examples/Basics/Form/SimpleCurves/applet/loading.gif b/android/examples/Basics/Form/SimpleCurves/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Form/SimpleCurves/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.java b/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.java deleted file mode 100644 index ece5f8d81..000000000 --- a/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.java +++ /dev/null @@ -1,57 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class TriangleStrip extends PApplet { - public void setup() {/** - * TRIANGLE_STRIP Mode - * By Ira Greenberg - * - * Generate a closed ring using vertex() - * function and beginShape(TRIANGLE_STRIP) - * mode. outerRad and innerRad variables - * control ring's outer/inner radii respectively. - * Trig functions generate ring. - */ - -size(200, 200); -background(204); -smooth(); - -int x = width/2; -int y = height/2; -int outerRad = 80; -int innerRad = 50; -float px = 0, py = 0, angle = 0; -float pts = 36; -float rot = 360.0f/pts; - -beginShape(TRIANGLE_STRIP); -for (int i = 0; i < pts; i++) { - px = x + cos(radians(angle))*outerRad; - py = y + sin(radians(angle))*outerRad; - angle += rot; - vertex(px, py); - px = x + cos(radians(angle))*innerRad; - py = y + sin(radians(angle))*innerRad; - vertex(px, py); - angle += rot; -} -endShape(); - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "TriangleStrip" }); - } -} diff --git a/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.pde b/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.pde deleted file mode 100644 index fdb99d032..000000000 --- a/android/examples/Basics/Form/TriangleStrip/applet/TriangleStrip.pde +++ /dev/null @@ -1,36 +0,0 @@ -/** - * TRIANGLE_STRIP Mode - * By Ira Greenberg - * - * Generate a closed ring using vertex() - * function and beginShape(TRIANGLE_STRIP) - * mode. outerRad and innerRad variables - * control ring's outer/inner radii respectively. - * Trig functions generate ring. - */ - -size(200, 200); -background(204); -smooth(); - -int x = width/2; -int y = height/2; -int outerRad = 80; -int innerRad = 50; -float px = 0, py = 0, angle = 0; -float pts = 36; -float rot = 360.0/pts; - -beginShape(TRIANGLE_STRIP); -for (int i = 0; i < pts; i++) { - px = x + cos(radians(angle))*outerRad; - py = y + sin(radians(angle))*outerRad; - angle += rot; - vertex(px, py); - px = x + cos(radians(angle))*innerRad; - py = y + sin(radians(angle))*innerRad; - vertex(px, py); - angle += rot; -} -endShape(); - diff --git a/android/examples/Basics/Form/TriangleStrip/applet/loading.gif b/android/examples/Basics/Form/TriangleStrip/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Form/TriangleStrip/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Form/Vertices/applet/Vertices.java b/android/examples/Basics/Form/Vertices/applet/Vertices.java deleted file mode 100644 index 062bc838f..000000000 --- a/android/examples/Basics/Form/Vertices/applet/Vertices.java +++ /dev/null @@ -1,68 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Vertices extends PApplet { - public void setup() {/** - * Vertices. - * - * The beginShape() function begins recording vertices - * for a shape and endShape() stops recording. - * A vertex is a location in space specified by X, Y, - * and sometimes Z coordinates. After calling the beginShape() function, - * a series of vertex() functions must follow. - * To stop drawing the shape, call the endShape() functions. - */ - -size(200, 200); -background(0); -noFill(); - -stroke(102); -beginShape(); -curveVertex(168, 182); -curveVertex(168, 182); -curveVertex(136, 38); -curveVertex(42, 34); -curveVertex(64, 200); -curveVertex(64, 200); -endShape(); - -stroke(51); -beginShape(LINES); -vertex(60, 40); -vertex(160, 10); -vertex(170, 150); -vertex(60, 150); -endShape(); - -stroke(126); -beginShape(); -vertex(60, 40); -bezierVertex(160, 10, 170, 150, 60, 150); -endShape(); - -stroke(255); -beginShape(POINTS); -vertex(60, 40); -vertex(160, 10); -vertex(170, 150); -vertex(60, 150); -endShape(); - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Vertices" }); - } -} diff --git a/android/examples/Basics/Form/Vertices/applet/Vertices.pde b/android/examples/Basics/Form/Vertices/applet/Vertices.pde deleted file mode 100644 index f8c705650..000000000 --- a/android/examples/Basics/Form/Vertices/applet/Vertices.pde +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Vertices. - * - * The beginShape() function begins recording vertices - * for a shape and endShape() stops recording. - * A vertex is a location in space specified by X, Y, - * and sometimes Z coordinates. After calling the beginShape() function, - * a series of vertex() functions must follow. - * To stop drawing the shape, call the endShape() functions. - */ - -size(200, 200); -background(0); -noFill(); - -stroke(102); -beginShape(); -curveVertex(168, 182); -curveVertex(168, 182); -curveVertex(136, 38); -curveVertex(42, 34); -curveVertex(64, 200); -curveVertex(64, 200); -endShape(); - -stroke(51); -beginShape(LINES); -vertex(60, 40); -vertex(160, 10); -vertex(170, 150); -vertex(60, 150); -endShape(); - -stroke(126); -beginShape(); -vertex(60, 40); -bezierVertex(160, 10, 170, 150, 60, 150); -endShape(); - -stroke(255); -beginShape(POINTS); -vertex(60, 40); -vertex(160, 10); -vertex(170, 150); -vertex(60, 150); -endShape(); - diff --git a/android/examples/Basics/Form/Vertices/applet/loading.gif b/android/examples/Basics/Form/Vertices/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Form/Vertices/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/Alphamask/applet/Alphamask.java b/android/examples/Basics/Image/Alphamask/applet/Alphamask.java deleted file mode 100644 index 2d0e3317d..000000000 --- a/android/examples/Basics/Image/Alphamask/applet/Alphamask.java +++ /dev/null @@ -1,45 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Alphamask extends PApplet { - -/** - * Alpha Mask. - * - * Loads a "mask" for an image to specify the transparency - * in different parts of the image. The two images are blended - * together using the mask() method of PImage. - */ - -PImage img; -PImage maskImg; - -public void setup() -{ - size(200,200); - img = loadImage("test.jpg"); - maskImg = loadImage("mask.jpg"); - img.mask(maskImg); -} - -public void draw() -{ - background((mouseX+mouseY)/1.5f); - image(img, 50, 50); - image(img, mouseX-50, mouseY-50); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Alphamask" }); - } -} diff --git a/android/examples/Basics/Image/Alphamask/applet/Alphamask.pde b/android/examples/Basics/Image/Alphamask/applet/Alphamask.pde deleted file mode 100644 index 6eb55ef9f..000000000 --- a/android/examples/Basics/Image/Alphamask/applet/Alphamask.pde +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Alpha Mask. - * - * Loads a "mask" for an image to specify the transparency - * in different parts of the image. The two images are blended - * together using the mask() method of PImage. - */ - -PImage img; -PImage maskImg; - -void setup() -{ - size(200,200); - img = loadImage("test.jpg"); - maskImg = loadImage("mask.jpg"); - img.mask(maskImg); -} - -void draw() -{ - background((mouseX+mouseY)/1.5); - image(img, 50, 50); - image(img, mouseX-50, mouseY-50); -} diff --git a/android/examples/Basics/Image/Alphamask/applet/loading.gif b/android/examples/Basics/Image/Alphamask/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/Alphamask/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.java b/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.java deleted file mode 100644 index b56dafb5b..000000000 --- a/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.java +++ /dev/null @@ -1,50 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class BackgroundImage extends PApplet { - -/** - * Background Image. - * - * This example presents the fastest way to load a background image - * into Processing. To load an image as the background, it must be - * the same width and height as the program. - */ - -PImage bg; -int a; - -public void setup() -{ - size(200,200); - frameRate(30); - // The background image must be the same size as the parameters - // into the size() method. In this program, the size of "milan_rubbish.jpg" - // is 200 x 200 pixels. - bg = loadImage("milan_rubbish.jpg"); -} - -public void draw() -{ - background(bg); - - a = (a + 1)%(width+32); - stroke(226, 204, 0); - line(0, a, width, a-26); - line(0, a-6, width, a-32); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "BackgroundImage" }); - } -} diff --git a/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.pde b/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.pde deleted file mode 100644 index 2c5f1aac8..000000000 --- a/android/examples/Basics/Image/BackgroundImage/applet/BackgroundImage.pde +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Background Image. - * - * This example presents the fastest way to load a background image - * into Processing. To load an image as the background, it must be - * the same width and height as the program. - */ - -PImage bg; -int a; - -void setup() -{ - size(200,200); - frameRate(30); - // The background image must be the same size as the parameters - // into the size() method. In this program, the size of "milan_rubbish.jpg" - // is 200 x 200 pixels. - bg = loadImage("milan_rubbish.jpg"); -} - -void draw() -{ - background(bg); - - a = (a + 1)%(width+32); - stroke(226, 204, 0); - line(0, a, width, a-26); - line(0, a-6, width, a-32); -} diff --git a/android/examples/Basics/Image/BackgroundImage/applet/loading.gif b/android/examples/Basics/Image/BackgroundImage/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/BackgroundImage/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/CreateImage/applet/CreateImage.java b/android/examples/Basics/Image/CreateImage/applet/CreateImage.java deleted file mode 100644 index 0ae2e5bd5..000000000 --- a/android/examples/Basics/Image/CreateImage/applet/CreateImage.java +++ /dev/null @@ -1,44 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class CreateImage extends PApplet { - -/** - * Create Image. - * - * The createImage() function provides a fresh buffer of pixels to play with. - * This example creates an image gradient. - */ - -PImage img; - -public void setup() -{ - size(200, 200); - img = createImage(120, 120, ARGB); - for(int i=0; i < img.pixels.length; i++) { - img.pixels[i] = color(0, 90, 102, i%img.width * 2); - } -} - -public void draw() -{ - background(204); - image(img, 33, 33); - image(img, mouseX-60, mouseY-60); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "CreateImage" }); - } -} diff --git a/android/examples/Basics/Image/CreateImage/applet/CreateImage.pde b/android/examples/Basics/Image/CreateImage/applet/CreateImage.pde deleted file mode 100644 index df095a75e..000000000 --- a/android/examples/Basics/Image/CreateImage/applet/CreateImage.pde +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Create Image. - * - * The createImage() function provides a fresh buffer of pixels to play with. - * This example creates an image gradient. - */ - -PImage img; - -void setup() -{ - size(200, 200); - img = createImage(120, 120, ARGB); - for(int i=0; i < img.pixels.length; i++) { - img.pixels[i] = color(0, 90, 102, i%img.width * 2); - } -} - -void draw() -{ - background(204); - image(img, 33, 33); - image(img, mouseX-60, mouseY-60); -} diff --git a/android/examples/Basics/Image/CreateImage/applet/loading.gif b/android/examples/Basics/Image/CreateImage/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/CreateImage/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.java b/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.java deleted file mode 100644 index 8807d2d60..000000000 --- a/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.java +++ /dev/null @@ -1,44 +0,0 @@ -import processing.core.*; -import processing.xml.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class LoadDisplayImage extends PApplet { - -/** - * Load and Display - * - * Images can be loaded and displayed to the screen at their actual size - * or any other size. - */ - -PImage a; // Declare variable "a" of type PImage - -public void setup() { - size(200, 200); - // The file "jelly.jpg" must be in the data folder - // of the current sketch to load successfully - a = loadImage("jelly.jpg"); // Load the image into the program - noLoop(); // Makes draw() only run once -} - -public void draw() { - // Displays the image at its actual size at point (0,0) - image(a, 0, 0); - // Displays the image at point (100, 0) at half of its size - image(a, 100, 0, a.width/2, a.height/2); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "LoadDisplayImage" }); - } -} diff --git a/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.pde b/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.pde deleted file mode 100644 index 8252c5cbc..000000000 --- a/android/examples/Basics/Image/LoadDisplayImage/applet/LoadDisplayImage.pde +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Load and Display - * - * Images can be loaded and displayed to the screen at their actual size - * or any other size. - */ - -PImage a; // Declare variable "a" of type PImage - -void setup() { - size(200, 200); - // The file "jelly.jpg" must be in the data folder - // of the current sketch to load successfully - a = loadImage("jelly.jpg"); // Load the image into the program - noLoop(); // Makes draw() only run once -} - -void draw() { - // Displays the image at its actual size at point (0,0) - image(a, 0, 0); - // Displays the image at point (100, 0) at half of its size - image(a, 100, 0, a.width/2, a.height/2); -} diff --git a/android/examples/Basics/Image/LoadDisplayImage/applet/loading.gif b/android/examples/Basics/Image/LoadDisplayImage/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/LoadDisplayImage/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/Pointillism/applet/Pointillism.java b/android/examples/Basics/Image/Pointillism/applet/Pointillism.java deleted file mode 100644 index a80eac561..000000000 --- a/android/examples/Basics/Image/Pointillism/applet/Pointillism.java +++ /dev/null @@ -1,49 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Pointillism extends PApplet { - -/** - * Pointillism - * by Daniel Shiffman. - * - * Mouse horizontal location controls size of dots. - * Creates a simple pointillist effect using ellipses colored - * according to pixels in an image. - */ - -PImage a; - -public void setup() -{ - a = loadImage("eames.jpg"); - size(200,200); - noStroke(); - background(255); - smooth(); -} - -public void draw() -{ - float pointillize = map(mouseX, 0, width, 2, 18); - int x = PApplet.parseInt(random(a.width)); - int y = PApplet.parseInt(random(a.height)); - int pix = a.get(x, y); - fill(pix, 126); - ellipse(x, y, pointillize, pointillize); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Pointillism" }); - } -} diff --git a/android/examples/Basics/Image/Pointillism/applet/Pointillism.pde b/android/examples/Basics/Image/Pointillism/applet/Pointillism.pde deleted file mode 100644 index 53f5c3a48..000000000 --- a/android/examples/Basics/Image/Pointillism/applet/Pointillism.pde +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Pointillism - * by Daniel Shiffman. - * - * Mouse horizontal location controls size of dots. - * Creates a simple pointillist effect using ellipses colored - * according to pixels in an image. - */ - -PImage a; - -void setup() -{ - a = loadImage("eames.jpg"); - size(200,200); - noStroke(); - background(255); - smooth(); -} - -void draw() -{ - float pointillize = map(mouseX, 0, width, 2, 18); - int x = int(random(a.width)); - int y = int(random(a.height)); - color pix = a.get(x, y); - fill(pix, 126); - ellipse(x, y, pointillize, pointillize); -} diff --git a/android/examples/Basics/Image/Pointillism/applet/loading.gif b/android/examples/Basics/Image/Pointillism/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/Pointillism/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/Sprite/applet/Sprite.java b/android/examples/Basics/Image/Sprite/applet/Sprite.java deleted file mode 100644 index c777d010f..000000000 --- a/android/examples/Basics/Image/Sprite/applet/Sprite.java +++ /dev/null @@ -1,61 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Sprite extends PApplet { - -/** - * Sprite (Teddy) - * by James Patterson. - * - * Demonstrates loading and displaying a transparent GIF image. - */ - -PImage teddy; - -float xpos; -float ypos; -float drag = 30.0f; - -public void setup() -{ - size(200,200); - teddy = loadImage("teddy.gif"); - xpos = width/2; - ypos = height/2; - frameRate(60); -} - -public void draw() -{ - background(102); - - float difx = mouseX - xpos-teddy.width/2; - if(abs(difx) > 1.0f) { - xpos = xpos + difx/drag; - xpos = constrain(xpos, 0, width-teddy.width); - } - - float dify = mouseY - ypos-teddy.height/2; - if(abs(dify) > 1.0f) { - ypos = ypos + dify/drag; - ypos = constrain(ypos, 0, height-teddy.height); - } - - // Display the sprite at the position xpos, ypos - image(teddy, xpos, ypos); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Sprite" }); - } -} diff --git a/android/examples/Basics/Image/Sprite/applet/Sprite.pde b/android/examples/Basics/Image/Sprite/applet/Sprite.pde deleted file mode 100644 index b46edfc2f..000000000 --- a/android/examples/Basics/Image/Sprite/applet/Sprite.pde +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Sprite (Teddy) - * by James Patterson. - * - * Demonstrates loading and displaying a transparent GIF image. - */ - -PImage teddy; - -float xpos; -float ypos; -float drag = 30.0; - -void setup() -{ - size(200,200); - teddy = loadImage("teddy.gif"); - xpos = width/2; - ypos = height/2; - frameRate(60); -} - -void draw() -{ - background(102); - - float difx = mouseX - xpos-teddy.width/2; - if(abs(difx) > 1.0) { - xpos = xpos + difx/drag; - xpos = constrain(xpos, 0, width-teddy.width); - } - - float dify = mouseY - ypos-teddy.height/2; - if(abs(dify) > 1.0) { - ypos = ypos + dify/drag; - ypos = constrain(ypos, 0, height-teddy.height); - } - - // Display the sprite at the position xpos, ypos - image(teddy, xpos, ypos); -} diff --git a/android/examples/Basics/Image/Sprite/applet/loading.gif b/android/examples/Basics/Image/Sprite/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/Sprite/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Image/Transparency/applet/Transparency.java b/android/examples/Basics/Image/Transparency/applet/Transparency.java deleted file mode 100644 index 1aff169ee..000000000 --- a/android/examples/Basics/Image/Transparency/applet/Transparency.java +++ /dev/null @@ -1,50 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Transparency extends PApplet { - -/** - * Transparency. - * - * Move the pointer left and right across the image to change - * its position. This program overlays one image over another - * by modifying the alpha value of the image with the tint() function. - */ - -PImage a, b; -float offset; - -public void setup() { - size(200, 200); - a = loadImage("construct.jpg"); // Load an image into the program - b = loadImage("wash.jpg"); // Load an image into the program - frameRate(60); -} - -public void draw() { - image(a, 0, 0); - float offsetTarget = map(mouseX, 0, width, -b.width/2 - width/2, 0); - offset += (offsetTarget-offset)*0.05f; - tint(255, 153); - image(b, offset, 20); -} - - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Transparency" }); - } -} diff --git a/android/examples/Basics/Image/Transparency/applet/Transparency.pde b/android/examples/Basics/Image/Transparency/applet/Transparency.pde deleted file mode 100644 index ec4f66658..000000000 --- a/android/examples/Basics/Image/Transparency/applet/Transparency.pde +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Transparency. - * - * Move the pointer left and right across the image to change - * its position. This program overlays one image over another - * by modifying the alpha value of the image with the tint() function. - */ - -PImage a, b; -float offset; - -void setup() { - size(200, 200); - a = loadImage("construct.jpg"); // Load an image into the program - b = loadImage("wash.jpg"); // Load an image into the program - frameRate(60); -} - -void draw() { - image(a, 0, 0); - float offsetTarget = map(mouseX, 0, width, -b.width/2 - width/2, 0); - offset += (offsetTarget-offset)*0.05; - tint(255, 153); - image(b, offset, 20); -} - - - - - diff --git a/android/examples/Basics/Image/Transparency/applet/loading.gif b/android/examples/Basics/Image/Transparency/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Image/Transparency/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Clock/applet/Clock.java b/android/examples/Basics/Input/Clock/applet/Clock.java deleted file mode 100644 index 7e3412158..000000000 --- a/android/examples/Basics/Input/Clock/applet/Clock.java +++ /dev/null @@ -1,59 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Clock extends PApplet { - -/** - * Clock. - * - * The current time can be read with the second(), minute(), - * and hour() functions. In this example, sin() and cos() values - * are used to set the position of the hands. - */ - -public void setup() { - size(200, 200); - stroke(255); - smooth(); -} -public void draw() { - background(0); - fill(80); - noStroke(); - // Angles for sin() and cos() start at 3 o'clock; - // subtract HALF_PI to make them start at the top - ellipse(100, 100, 160, 160); - float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; - float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; - float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI; - stroke(255); - strokeWeight(1); - line(100, 100, cos(s) * 72 + 100, sin(s) * 72 + 100); - strokeWeight(2); - line(100, 100, cos(m) * 60 + 100, sin(m) * 60 + 100); - strokeWeight(4); - line(100, 100, cos(h) * 50 + 100, sin(h) * 50 + 100); - - // Draw the minute ticks - strokeWeight(2); - for (int a = 0; a < 360; a+=6) { - float x = 100 + ( cos(radians(a)) * 72 ); - float y = 100 + ( sin(radians(a)) * 72 ); - point(x, y); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Clock" }); - } -} diff --git a/android/examples/Basics/Input/Clock/applet/Clock.pde b/android/examples/Basics/Input/Clock/applet/Clock.pde deleted file mode 100644 index 397af66f0..000000000 --- a/android/examples/Basics/Input/Clock/applet/Clock.pde +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Clock. - * - * The current time can be read with the second(), minute(), - * and hour() functions. In this example, sin() and cos() values - * are used to set the position of the hands. - */ - -void setup() { - size(200, 200); - stroke(255); - smooth(); -} -void draw() { - background(0); - fill(80); - noStroke(); - // Angles for sin() and cos() start at 3 o'clock; - // subtract HALF_PI to make them start at the top - ellipse(100, 100, 160, 160); - float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; - float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; - float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI; - stroke(255); - strokeWeight(1); - line(100, 100, cos(s) * 72 + 100, sin(s) * 72 + 100); - strokeWeight(2); - line(100, 100, cos(m) * 60 + 100, sin(m) * 60 + 100); - strokeWeight(4); - line(100, 100, cos(h) * 50 + 100, sin(h) * 50 + 100); - - // Draw the minute ticks - strokeWeight(2); - for (int a = 0; a < 360; a+=6) { - float x = 100 + ( cos(radians(a)) * 72 ); - float y = 100 + ( sin(radians(a)) * 72 ); - point(x, y); - } -} diff --git a/android/examples/Basics/Input/Clock/applet/loading.gif b/android/examples/Basics/Input/Clock/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Clock/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Constrain/applet/Constrain.java b/android/examples/Basics/Input/Constrain/applet/Constrain.java deleted file mode 100644 index 1a11e1e02..000000000 --- a/android/examples/Basics/Input/Constrain/applet/Constrain.java +++ /dev/null @@ -1,60 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Constrain extends PApplet { - -/** - * Constrain. - * - * Move the mouse across the screen to move the circle. - * The program constrains the circle to its box. - */ - -float mx; -float my; -float easing = 0.05f; -float esize = 25.0f; -int box = 30; - -public void setup() -{ - size(200, 200); - noStroke(); - smooth(); - ellipseMode(CENTER_RADIUS); -} - -public void draw() -{ - background(51); - - if(abs(mouseX - mx) > 0.1f) { - mx = mx + (mouseX - mx) * easing; - } - if(abs(mouseY - my) > 0.1f) { - my = my + (mouseY- my) * easing; - } - - float distance = esize * 2; - mx = constrain(mx, box+distance, width-box-distance); - my = constrain(my, box+distance, height-box-distance); - fill(76); - rect(box+esize, box+esize, box*3, box*3); - fill(255); - ellipse(mx, my, esize, esize); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Constrain" }); - } -} diff --git a/android/examples/Basics/Input/Constrain/applet/Constrain.pde b/android/examples/Basics/Input/Constrain/applet/Constrain.pde deleted file mode 100644 index 6d57b97d6..000000000 --- a/android/examples/Basics/Input/Constrain/applet/Constrain.pde +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Constrain. - * - * Move the mouse across the screen to move the circle. - * The program constrains the circle to its box. - */ - -float mx; -float my; -float easing = 0.05; -float esize = 25.0; -int box = 30; - -void setup() -{ - size(200, 200); - noStroke(); - smooth(); - ellipseMode(CENTER_RADIUS); -} - -void draw() -{ - background(51); - - if(abs(mouseX - mx) > 0.1) { - mx = mx + (mouseX - mx) * easing; - } - if(abs(mouseY - my) > 0.1) { - my = my + (mouseY- my) * easing; - } - - float distance = esize * 2; - mx = constrain(mx, box+distance, width-box-distance); - my = constrain(my, box+distance, height-box-distance); - fill(76); - rect(box+esize, box+esize, box*3, box*3); - fill(255); - ellipse(mx, my, esize, esize); -} diff --git a/android/examples/Basics/Input/Constrain/applet/loading.gif b/android/examples/Basics/Input/Constrain/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Constrain/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Easing/applet/Easing.java b/android/examples/Basics/Input/Easing/applet/Easing.java deleted file mode 100644 index 7e6f2749f..000000000 --- a/android/examples/Basics/Input/Easing/applet/Easing.java +++ /dev/null @@ -1,61 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Easing extends PApplet { - -/** - * Easing. - * - * Move the mouse across the screen and the symbol will follow. - * Between drawing each frame of the animation, the program - * calculates the difference between the position of the - * symbol and the cursor. If the distance is larger than - * 1 pixel, the symbol moves part of the distance (0.05) from its - * current position toward the cursor. - */ - -float x; -float y; -float targetX, targetY; -float easing = 0.05f; - -public void setup() -{ - size(200, 200); - smooth(); - noStroke(); -} - -public void draw() -{ - background( 51 ); - - targetX = mouseX; - float dx = mouseX - x; - if(abs(dx) > 1) { - x += dx * easing; - } - - targetY = mouseY; - float dy = mouseY - y; - if(abs(dy) > 1) { - y += dy * easing; - } - - ellipse(x, y, 33, 33); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Easing" }); - } -} diff --git a/android/examples/Basics/Input/Easing/applet/Easing.pde b/android/examples/Basics/Input/Easing/applet/Easing.pde deleted file mode 100644 index 9ef837afc..000000000 --- a/android/examples/Basics/Input/Easing/applet/Easing.pde +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Easing. - * - * Move the mouse across the screen and the symbol will follow. - * Between drawing each frame of the animation, the program - * calculates the difference between the position of the - * symbol and the cursor. If the distance is larger than - * 1 pixel, the symbol moves part of the distance (0.05) from its - * current position toward the cursor. - */ - -float x; -float y; -float targetX, targetY; -float easing = 0.05; - -void setup() -{ - size(200, 200); - smooth(); - noStroke(); -} - -void draw() -{ - background( 51 ); - - targetX = mouseX; - float dx = mouseX - x; - if(abs(dx) > 1) { - x += dx * easing; - } - - targetY = mouseY; - float dy = mouseY - y; - if(abs(dy) > 1) { - y += dy * easing; - } - - ellipse(x, y, 33, 33); -} diff --git a/android/examples/Basics/Input/Easing/applet/loading.gif b/android/examples/Basics/Input/Easing/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Easing/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Keyboard/applet/Keyboard.java b/android/examples/Basics/Input/Keyboard/applet/Keyboard.java deleted file mode 100644 index 73d9c7202..000000000 --- a/android/examples/Basics/Input/Keyboard/applet/Keyboard.java +++ /dev/null @@ -1,60 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Keyboard extends PApplet { - -/** - * Keyboard. - * - * Click on the image to give it focus and press the letter keys - * to create forms in time and space. Each key has a unique identifying - * number called it's ASCII value. These numbers can be used to position - * shapes in space. - */ - -int numChars = 26; -int[] colors = new int[numChars]; -int keyIndex; -float keyScale; -int rectWidth; - - -public void setup() -{ - size(200, 200); - noStroke(); - background(0); - keyScale = 200/numChars-1.0f; - rectWidth = width/4; -} - -public void draw() -{ - if(keyPressed) { - if(key >= 'A' && key <= 'z') { - if(key <= 'Z') { - keyIndex = key-'A'; - } else { - keyIndex = key-'a'; - } - fill(millis()%255); - float beginRect = rectWidth/2 + keyIndex*keyScale-rectWidth/2; - rect(beginRect, 0.0f, rectWidth, height); - } - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Keyboard" }); - } -} diff --git a/android/examples/Basics/Input/Keyboard/applet/Keyboard.pde b/android/examples/Basics/Input/Keyboard/applet/Keyboard.pde deleted file mode 100644 index ee1a3c156..000000000 --- a/android/examples/Basics/Input/Keyboard/applet/Keyboard.pde +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Keyboard. - * - * Click on the image to give it focus and press the letter keys - * to create forms in time and space. Each key has a unique identifying - * number called it's ASCII value. These numbers can be used to position - * shapes in space. - */ - -int numChars = 26; -color[] colors = new color[numChars]; -int keyIndex; -float keyScale; -int rectWidth; - - -void setup() -{ - size(200, 200); - noStroke(); - background(0); - keyScale = 200/numChars-1.0; - rectWidth = width/4; -} - -void draw() -{ - if(keyPressed) { - if(key >= 'A' && key <= 'z') { - if(key <= 'Z') { - keyIndex = key-'A'; - } else { - keyIndex = key-'a'; - } - fill(millis()%255); - float beginRect = rectWidth/2 + keyIndex*keyScale-rectWidth/2; - rect(beginRect, 0.0, rectWidth, height); - } - } -} diff --git a/android/examples/Basics/Input/Keyboard/applet/loading.gif b/android/examples/Basics/Input/Keyboard/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Keyboard/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.java b/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.java deleted file mode 100644 index 7d7d4b2f4..000000000 --- a/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.java +++ /dev/null @@ -1,109 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class KeyboardFunctions extends PApplet { - -/** - * Keyboard Functions. - * Modified from code by Martin. - * Original 'Color Typewriter' concept by John Maeda. - * - * Click on the window to give it focus and press the letter keys to type colors. - * The keyboard function keyPressed() is called whenever - * a key is pressed. keyReleased() is another keyboard - * function that is called when a key is released. - */ - -int max_height = 20; -int min_height = 10; -int letter_height = max_height; // Height of the letters -int letter_width = 10; // Width of the letter - -int x = -letter_width; // X position of the letters -int y = 0; // Y position of the letters - -boolean newletter; - -int numChars = 26; // There are 26 characters in the alphabet -int[] colors = new int[numChars]; - -public void setup() -{ - size(200, 200); - noStroke(); - colorMode(RGB, numChars); - background(numChars/2); - // Set a gray value for each key - for(int i=0; i= 'A' && key <= 'z') { - int keyIndex; - if(key <= 'Z') { - keyIndex = key-'A'; - letter_height = max_height; - fill(colors[key-'A']); - } else { - keyIndex = key-'a'; - letter_height = min_height; - fill(colors[key-'a']); - } - } else { - fill(0); - letter_height = 10; - } - - newletter = true; - - // Update the "letter" position - x = ( x + letter_width ); - - // Wrap horizontally - if (x > width - letter_width) { - x = 0; - y+= max_height; - } - - // Wrap vertically - if( y > height - letter_height) { - y = 0; // reset y to 0 - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "KeyboardFunctions" }); - } -} diff --git a/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.pde b/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.pde deleted file mode 100644 index 882e92d63..000000000 --- a/android/examples/Basics/Input/KeyboardFunctions/applet/KeyboardFunctions.pde +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Keyboard Functions. - * Modified from code by Martin. - * Original 'Color Typewriter' concept by John Maeda. - * - * Click on the window to give it focus and press the letter keys to type colors. - * The keyboard function keyPressed() is called whenever - * a key is pressed. keyReleased() is another keyboard - * function that is called when a key is released. - */ - -int max_height = 20; -int min_height = 10; -int letter_height = max_height; // Height of the letters -int letter_width = 10; // Width of the letter - -int x = -letter_width; // X position of the letters -int y = 0; // Y position of the letters - -boolean newletter; - -int numChars = 26; // There are 26 characters in the alphabet -color[] colors = new color[numChars]; - -void setup() -{ - size(200, 200); - noStroke(); - colorMode(RGB, numChars); - background(numChars/2); - // Set a gray value for each key - for(int i=0; i= 'A' && key <= 'z') { - int keyIndex; - if(key <= 'Z') { - keyIndex = key-'A'; - letter_height = max_height; - fill(colors[key-'A']); - } else { - keyIndex = key-'a'; - letter_height = min_height; - fill(colors[key-'a']); - } - } else { - fill(0); - letter_height = 10; - } - - newletter = true; - - // Update the "letter" position - x = ( x + letter_width ); - - // Wrap horizontally - if (x > width - letter_width) { - x = 0; - y+= max_height; - } - - // Wrap vertically - if( y > height - letter_height) { - y = 0; // reset y to 0 - } -} diff --git a/android/examples/Basics/Input/KeyboardFunctions/applet/loading.gif b/android/examples/Basics/Input/KeyboardFunctions/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/KeyboardFunctions/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Milliseconds/applet/Milliseconds.java b/android/examples/Basics/Input/Milliseconds/applet/Milliseconds.java deleted file mode 100644 index aa72e8e14..000000000 --- a/android/examples/Basics/Input/Milliseconds/applet/Milliseconds.java +++ /dev/null @@ -1,46 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Milliseconds extends PApplet { - -/** - * Milliseconds. - * - * A millisecond is 1/1000 of a second. - * Processing keeps track of the number of milliseconds a program has run. - * By modifying this number with the modulo(%) operator, - * different patterns in time are created. - */ - -float scale; - -public void setup() -{ - size(200, 200); - noStroke(); - scale = width/10; -} - -public void draw() -{ - for(int i=0; i 90) { - gx = 90; - } - - if (gy > 90) { - gy = 90; - } else if (gy < 10) { - gy = 10; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Mouse1D" }); - } -} diff --git a/android/examples/Basics/Input/Mouse1D/applet/Mouse1D.pde b/android/examples/Basics/Input/Mouse1D/applet/Mouse1D.pde deleted file mode 100644 index 2d1da507f..000000000 --- a/android/examples/Basics/Input/Mouse1D/applet/Mouse1D.pde +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Mouse 1D. - * - * Move the mouse left and right to shift the balance. - * The "mouseX" variable is used to control both the - * size and color of the rectangles. - */ - -int gx = 15; -int gy = 35; -float leftColor = 0.0; -float rightColor = 0.0; - -void setup() -{ - size(200, 200); - colorMode(RGB, 1.0); - noStroke(); -} - -void draw() -{ - background(0.0); - update(mouseX); - fill(0.0, leftColor + 0.4, leftColor + 0.6); - rect(width/4-gx, width/2-gx, gx*2, gx*2); - fill(0.0, rightColor + 0.2, rightColor + 0.4); - rect(width/1.33-gy, width/2-gy, gy*2, gy*2); -} - -void update(int x) -{ - leftColor = -0.002 * x/2 + 0.06; - rightColor = 0.002 * x/2 + 0.06; - - gx = x/2; - gy = 100-x/2; - - if (gx < 10) { - gx = 10; - } else if (gx > 90) { - gx = 90; - } - - if (gy > 90) { - gy = 90; - } else if (gy < 10) { - gy = 10; - } -} diff --git a/android/examples/Basics/Input/Mouse1D/applet/loading.gif b/android/examples/Basics/Input/Mouse1D/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Mouse1D/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.java b/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.java deleted file mode 100644 index aee6375f4..000000000 --- a/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.java +++ /dev/null @@ -1,45 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Mouse2D extends PApplet { - -/** - * Mouse 2D. - * - * Moving the mouse changes the position and size of each box. - */ - -public void setup() -{ - size(200, 200); - noStroke(); - colorMode(RGB, 255, 255, 255, 100); - rectMode(CENTER); -} - -public void draw() -{ - background(51); - fill(255, 80); - rect(mouseX, height/2, mouseY/2+10, mouseY/2+10); - fill(255, 80); - int inverseX = width-mouseX; - int inverseY = height-mouseY; - rect(inverseX, height/2, (inverseY/2)+10, (inverseY/2)+10); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Mouse2D" }); - } -} diff --git a/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.pde b/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.pde deleted file mode 100644 index d1c36a258..000000000 --- a/android/examples/Basics/Input/Mouse2D/applet/Mouse2D.pde +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Mouse 2D. - * - * Moving the mouse changes the position and size of each box. - */ - -void setup() -{ - size(200, 200); - noStroke(); - colorMode(RGB, 255, 255, 255, 100); - rectMode(CENTER); -} - -void draw() -{ - background(51); - fill(255, 80); - rect(mouseX, height/2, mouseY/2+10, mouseY/2+10); - fill(255, 80); - int inverseX = width-mouseX; - int inverseY = height-mouseY; - rect(inverseX, height/2, (inverseY/2)+10, (inverseY/2)+10); -} - diff --git a/android/examples/Basics/Input/Mouse2D/applet/loading.gif b/android/examples/Basics/Input/Mouse2D/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/Mouse2D/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.java b/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.java deleted file mode 100644 index 5b89aeff0..000000000 --- a/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.java +++ /dev/null @@ -1,88 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class MouseFunctions extends PApplet { - -/** - * Mouse Functions. - * - * Click on the box and drag it across the screen. - */ - -float bx; -float by; -int bs = 20; -boolean bover = false; -boolean locked = false; -float bdifx = 0.0f; -float bdify = 0.0f; - - -public void setup() -{ - size(200, 200); - bx = width/2.0f; - by = height/2.0f; - rectMode(CENTER_RADIUS); -} - -public void draw() -{ - background(0); - - // Test if the cursor is over the box - if (mouseX > bx-bs && mouseX < bx+bs && - mouseY > by-bs && mouseY < by+bs) { - bover = true; - if(!locked) { - stroke(255); - fill(153); - } - } else { - stroke(153); - fill(153); - bover = false; - } - - // Draw the box - rect(bx, by, bs, bs); -} - -public void mousePressed() { - if(bover) { - locked = true; - fill(255, 255, 255); - } else { - locked = false; - } - bdifx = mouseX-bx; - bdify = mouseY-by; - -} - -public void mouseDragged() { - if(locked) { - bx = mouseX-bdifx; - by = mouseY-bdify; - } -} - -public void mouseReleased() { - locked = false; -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "MouseFunctions" }); - } -} diff --git a/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.pde b/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.pde deleted file mode 100644 index 22717d718..000000000 --- a/android/examples/Basics/Input/MouseFunctions/applet/MouseFunctions.pde +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Mouse Functions. - * - * Click on the box and drag it across the screen. - */ - -float bx; -float by; -int bs = 20; -boolean bover = false; -boolean locked = false; -float bdifx = 0.0; -float bdify = 0.0; - - -void setup() -{ - size(200, 200); - bx = width/2.0; - by = height/2.0; - rectMode(CENTER_RADIUS); -} - -void draw() -{ - background(0); - - // Test if the cursor is over the box - if (mouseX > bx-bs && mouseX < bx+bs && - mouseY > by-bs && mouseY < by+bs) { - bover = true; - if(!locked) { - stroke(255); - fill(153); - } - } else { - stroke(153); - fill(153); - bover = false; - } - - // Draw the box - rect(bx, by, bs, bs); -} - -void mousePressed() { - if(bover) { - locked = true; - fill(255, 255, 255); - } else { - locked = false; - } - bdifx = mouseX-bx; - bdify = mouseY-by; - -} - -void mouseDragged() { - if(locked) { - bx = mouseX-bdifx; - by = mouseY-bdify; - } -} - -void mouseReleased() { - locked = false; -} - diff --git a/android/examples/Basics/Input/MouseFunctions/applet/loading.gif b/android/examples/Basics/Input/MouseFunctions/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/MouseFunctions/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/MousePress/applet/MousePress.java b/android/examples/Basics/Input/MousePress/applet/MousePress.java deleted file mode 100644 index 82bc9f6ca..000000000 --- a/android/examples/Basics/Input/MousePress/applet/MousePress.java +++ /dev/null @@ -1,43 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class MousePress extends PApplet { - -/** - * Click. - * - * Move the mouse to position the shape. - * Press the mouse button to invert the color. - */ - - -public void setup() { - size(200, 200); - fill(126); - background(102); -} - -public void draw() { - if(mousePressed) { - stroke(255); - } else { - stroke(0); - } - line(mouseX-66, mouseY, mouseX+66, mouseY); - line(mouseX, mouseY-66, mouseX, mouseY+66); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "MousePress" }); - } -} diff --git a/android/examples/Basics/Input/MousePress/applet/MousePress.pde b/android/examples/Basics/Input/MousePress/applet/MousePress.pde deleted file mode 100644 index 526eced76..000000000 --- a/android/examples/Basics/Input/MousePress/applet/MousePress.pde +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Click. - * - * Move the mouse to position the shape. - * Press the mouse button to invert the color. - */ - - -void setup() { - size(200, 200); - fill(126); - background(102); -} - -void draw() { - if(mousePressed) { - stroke(255); - } else { - stroke(0); - } - line(mouseX-66, mouseY, mouseX+66, mouseY); - line(mouseX, mouseY-66, mouseX, mouseY+66); -} diff --git a/android/examples/Basics/Input/MousePress/applet/loading.gif b/android/examples/Basics/Input/MousePress/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Input/MousePress/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Input/MouseSignals/applet/MouseSignals.java b/android/examples/Basics/Input/MouseSignals/applet/MouseSignals.java deleted file mode 100644 index b6cdf7896..000000000 --- a/android/examples/Basics/Input/MouseSignals/applet/MouseSignals.java +++ /dev/null @@ -1,74 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class MouseSignals extends PApplet { - -/** - * Mouse Signals. - * - * Move and click the mouse to generate signals. - * The top row is the signal from "mouseX", - * the middle row is the signal from "mouseY", - * and the bottom row is the signal from "mousePressed". - */ - -int[] xvals; -int[] yvals; -int[] bvals; - -public void setup() -{ - size(200, 200); - xvals = new int[width]; - yvals = new int[width]; - bvals = new int[width]; -} - -int arrayindex = 0; - -public void draw() -{ - background(102); - - for(int i=1; i width) { xpos1 = -thin; } - if(xpos2 < -thick) { xpos2 = width; } - if(xpos2 > width) { xpos2 = -thick; } - if(xpos3 < -thin) { xpos3 = width; } - if(xpos3 > width) { xpos3 = -thin; } - if(xpos4 < -thick) { xpos4 = width; } - if(xpos4 > width) { xpos4 = -thick; } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Distance1D" }); - } -} diff --git a/android/examples/Basics/Math/Distance1D/applet/Distance1D.pde b/android/examples/Basics/Math/Distance1D/applet/Distance1D.pde deleted file mode 100644 index a17b3febc..000000000 --- a/android/examples/Basics/Math/Distance1D/applet/Distance1D.pde +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Distance 1D. - * - * Move the mouse left and right to control the - * speed and direction of the moving shapes. - */ - -int thin = 8; -int thick = 36; -float xpos1 = 134.0; -float xpos2 = 44.0; -float xpos3 = 58.0; -float xpos4 = 120.0; - -void setup() -{ - size(200, 200); - noStroke(); - frameRate(60); -} - -void draw() -{ - background(0); - - float mx = mouseX * 0.4 - width/5.0; - - fill(102); - rect(xpos2, 0, thick, height/2); - fill(204); - rect(xpos1, 0, thin, height/2); - fill(102); - rect(xpos4, height/2, thick, height/2); - fill(204); - rect(xpos3, height/2, thin, height/2); - - xpos1 += mx/16; - xpos2 += mx/64; - xpos3 -= mx/16; - xpos4 -= mx/64; - - if(xpos1 < -thin) { xpos1 = width; } - if(xpos1 > width) { xpos1 = -thin; } - if(xpos2 < -thick) { xpos2 = width; } - if(xpos2 > width) { xpos2 = -thick; } - if(xpos3 < -thin) { xpos3 = width; } - if(xpos3 > width) { xpos3 = -thin; } - if(xpos4 < -thick) { xpos4 = width; } - if(xpos4 > width) { xpos4 = -thick; } -} - diff --git a/android/examples/Basics/Math/Distance1D/applet/loading.gif b/android/examples/Basics/Math/Distance1D/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/Distance1D/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/Distance2D/applet/Distance2D.java b/android/examples/Basics/Math/Distance2D/applet/Distance2D.java deleted file mode 100644 index c4fe4f70e..000000000 --- a/android/examples/Basics/Math/Distance2D/applet/Distance2D.java +++ /dev/null @@ -1,49 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Distance2D extends PApplet { - -/** - * Distance 2D. - * - * Move the mouse across the image to obscure and reveal the matrix. - * Measures the distance from the mouse to each square and sets the - * size proportionally. - */ - -float max_distance; - -public void setup() { - size(200, 200); - smooth(); - noStroke(); - max_distance = dist(0, 0, width, height); -} - -public void draw() -{ - background(51); - - for(int i = 0; i <= width; i += 20) { - for(int j = 0; j <= height; j += 20) { - float size = dist(mouseX, mouseY, i, j); - size = size/max_distance * 66; - ellipse(i, j, size, size); - } - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Distance2D" }); - } -} diff --git a/android/examples/Basics/Math/Distance2D/applet/Distance2D.pde b/android/examples/Basics/Math/Distance2D/applet/Distance2D.pde deleted file mode 100644 index e2bfe4b44..000000000 --- a/android/examples/Basics/Math/Distance2D/applet/Distance2D.pde +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Distance 2D. - * - * Move the mouse across the image to obscure and reveal the matrix. - * Measures the distance from the mouse to each square and sets the - * size proportionally. - */ - -float max_distance; - -void setup() { - size(200, 200); - smooth(); - noStroke(); - max_distance = dist(0, 0, width, height); -} - -void draw() -{ - background(51); - - for(int i = 0; i <= width; i += 20) { - for(int j = 0; j <= height; j += 20) { - float size = dist(mouseX, mouseY, i, j); - size = size/max_distance * 66; - ellipse(i, j, size, size); - } - } -} diff --git a/android/examples/Basics/Math/Distance2D/applet/loading.gif b/android/examples/Basics/Math/Distance2D/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/Distance2D/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.java b/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.java deleted file mode 100644 index bea794379..000000000 --- a/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.java +++ /dev/null @@ -1,41 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class DoubleRandom extends PApplet { - public void setup() {/** - * Double Random - * by Ira Greenberg. - * - * Using 2 random() calls the and point() function - * to create an irregular sawtooth line. - */ - -size(200, 200); -background(0); -int totalPts = 300; -float steps = totalPts+1; -stroke(255); -float rand = 0; - -for (int i=1; i< steps; i++){ - point( (width/steps) * i, (height/2) + random(-rand, rand) ); - rand += random(-5, 5); -} - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "DoubleRandom" }); - } -} diff --git a/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.pde b/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.pde deleted file mode 100644 index 10b1fe0c9..000000000 --- a/android/examples/Basics/Math/DoubleRandom/applet/DoubleRandom.pde +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Double Random - * by Ira Greenberg. - * - * Using 2 random() calls the and point() function - * to create an irregular sawtooth line. - */ - -size(200, 200); -background(0); -int totalPts = 300; -float steps = totalPts+1; -stroke(255); -float rand = 0; - -for (int i=1; i< steps; i++){ - point( (width/steps) * i, (height/2) + random(-rand, rand) ); - rand += random(-5, 5); -} - diff --git a/android/examples/Basics/Math/DoubleRandom/applet/loading.gif b/android/examples/Basics/Math/DoubleRandom/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/DoubleRandom/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.java b/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.java deleted file mode 100644 index 2049a3988..000000000 --- a/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.java +++ /dev/null @@ -1,60 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Graphing2DEquation extends PApplet { - -/** - * Graphing 2D Equations - * by Daniel Shiffman. - * - * Graphics the following equation: - * sin(n*cos(r) + 5*theta) - * where n is a function of horizontal mouse location. - */ - -public void setup() { - size(200,200); - frameRate(30); -} - -public void draw() { - loadPixels(); - float n = (mouseX * 10.0f) / width; - float w = 16.0f; // 2D space width - float h = 16.0f; // 2D space height - float dx = w / width; // Increment x this amount per pixel - float dy = h / height; // Increment y this amount per pixel - float x = -w/2; // Start x at -1 * width / 2 - for (int i = 0; i < width; i++) { - float y = -h/2; // Start y at -1 * height / 2 - for (int j = 0; j < height; j++) { - float r = sqrt((x*x) + (y*y)); // Convert cartesian to polar - float theta = atan2(y,x); // Convert cartesian to polar - // Compute 2D polar coordinate function - float val = sin(n*cos(r) + 5 * theta); // Results in a value between -1 and 1 - //float val = cos(r); // Another simple function - //float val = sin(theta); // Another simple function - // Map resulting vale to grayscale value - pixels[i+j*width] = color((val + 1.0f) * 255.0f/2.0f); // Scale to between 0 and 255 - y += dy; // Increment y - } - x += dx; // Increment x - } - updatePixels(); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Graphing2DEquation" }); - } -} diff --git a/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.pde b/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.pde deleted file mode 100644 index bd20ed864..000000000 --- a/android/examples/Basics/Math/Graphing2DEquation/applet/Graphing2DEquation.pde +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Graphing 2D Equations - * by Daniel Shiffman. - * - * Graphics the following equation: - * sin(n*cos(r) + 5*theta) - * where n is a function of horizontal mouse location. - */ - -void setup() { - size(200,200); - frameRate(30); -} - -void draw() { - loadPixels(); - float n = (mouseX * 10.0) / width; - float w = 16.0; // 2D space width - float h = 16.0; // 2D space height - float dx = w / width; // Increment x this amount per pixel - float dy = h / height; // Increment y this amount per pixel - float x = -w/2; // Start x at -1 * width / 2 - for (int i = 0; i < width; i++) { - float y = -h/2; // Start y at -1 * height / 2 - for (int j = 0; j < height; j++) { - float r = sqrt((x*x) + (y*y)); // Convert cartesian to polar - float theta = atan2(y,x); // Convert cartesian to polar - // Compute 2D polar coordinate function - float val = sin(n*cos(r) + 5 * theta); // Results in a value between -1 and 1 - //float val = cos(r); // Another simple function - //float val = sin(theta); // Another simple function - // Map resulting vale to grayscale value - pixels[i+j*width] = color((val + 1.0) * 255.0/2.0); // Scale to between 0 and 255 - y += dy; // Increment y - } - x += dx; // Increment x - } - updatePixels(); -} - diff --git a/android/examples/Basics/Math/Graphing2DEquation/applet/loading.gif b/android/examples/Basics/Math/Graphing2DEquation/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/Graphing2DEquation/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.java b/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.java deleted file mode 100644 index 87cdd99d6..000000000 --- a/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class IncrementDecrement extends PApplet { - -/** - * Increment Decrement. - * - * Writing "a++" is equivalent to "a = a + 1". - * Writing "a--" is equivalent to "a = a - 1". - */ - -int a; -int b; -boolean direction; - -public void setup() -{ - size(200, 200); - colorMode(RGB, width); - a = 0; - b = width; - direction = true; - frameRate(30); -} - -public void draw() -{ - a++; - if(a > width) { - a = 0; - direction = !direction; - } - if(direction == true){ - stroke(a); - } else { - stroke(width-a); - } - line(a, 0, a, height/2); - - b--; - if(b < 0) { - b = width; - } - if(direction == true) { - stroke(width-b); - } else { - stroke(b); - } - line(b, height/2+1, b, height); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "IncrementDecrement" }); - } -} diff --git a/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.pde b/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.pde deleted file mode 100644 index 8398c5faa..000000000 --- a/android/examples/Basics/Math/IncrementDecrement/applet/IncrementDecrement.pde +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Increment Decrement. - * - * Writing "a++" is equivalent to "a = a + 1". - * Writing "a--" is equivalent to "a = a - 1". - */ - -int a; -int b; -boolean direction; - -void setup() -{ - size(200, 200); - colorMode(RGB, width); - a = 0; - b = width; - direction = true; - frameRate(30); -} - -void draw() -{ - a++; - if(a > width) { - a = 0; - direction = !direction; - } - if(direction == true){ - stroke(a); - } else { - stroke(width-a); - } - line(a, 0, a, height/2); - - b--; - if(b < 0) { - b = width; - } - if(direction == true) { - stroke(width-b); - } else { - stroke(b); - } - line(b, height/2+1, b, height); -} diff --git a/android/examples/Basics/Math/IncrementDecrement/applet/loading.gif b/android/examples/Basics/Math/IncrementDecrement/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/IncrementDecrement/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/Modulo/applet/Modulo.java b/android/examples/Basics/Math/Modulo/applet/Modulo.java deleted file mode 100644 index b83b996bd..000000000 --- a/android/examples/Basics/Math/Modulo/applet/Modulo.java +++ /dev/null @@ -1,51 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Modulo extends PApplet { - -/** - * Modulo. - * - * The modulo operator (%) returns the remainder of a number - * divided by another. As in this example, it is often used - * to keep numerical values within a set range. - */ - -int num = 20; -float c; - -public void setup() -{ - size(200,200); - fill(255); - frameRate(30); -} - -public void draw() -{ - background(0); - c+=0.1f; - for(int i=1; i <= >= -// Equality: == != -// Logical AND: && -// Logical OR: || -// Assignment: = += -= *= /= %= - -size(200, 200); -background(51); -noFill(); -stroke(51); - -stroke(204); -for(int i=0; i< width-20; i+= 4) { - // The 30 is added to 70 and then evaluated - // if it is greater than the current value of "i" - // For clarity, write as "if(i > (30 + 70)) {" - if(i > 30 + 70) { - line(i, 0, i, 50); - } -} - -stroke(255); -// The 2 is multiplied by the 8 and the result is added to the 5 -// For clarity, write as "rect(5 + (2 * 8), 0, 90, 20);" -rect(4 + 2 * 8, 52, 90, 48); -rect((4 + 2) * 8, 100, 90, 49); - -stroke(153); -for(int i=0; i< width; i+= 2) { - // The relational statements are evaluated - // first, and then the logical AND statements and - // finally the logical OR. For clarity, write as: - // "if(((i > 10) && (i < 50)) || ((i > 80) && (i < 160))) {" - if(i > 20 && i < 50 || i > 100 && i < width-20) { - line(i, 151, i, height-1); - } -} - - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "OperatorPrecedence" }); - } -} diff --git a/android/examples/Basics/Math/OperatorPrecedence/applet/OperatorPrecedence.pde b/android/examples/Basics/Math/OperatorPrecedence/applet/OperatorPrecedence.pde deleted file mode 100644 index 7f8cf52ca..000000000 --- a/android/examples/Basics/Math/OperatorPrecedence/applet/OperatorPrecedence.pde +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Operator_Precedence - * - * If you don't explicitly state the order in which - * an expression is evaluated, they are evaluated based - * on the operator precedence. For example, in the statement - * "4+2*8", the 2 will first be multiplied by 8 and then the result will - * be added to 4. This is because the "*" has a higher precedence - * than the "+". To avoid ambiguity in reading the program, - * it is recommended that is statement is written as "4+(2*8)". - * The order of evaluation can be controlled through placement of - * parenthesis in the code. A table of operator precedence follows below. - * - */ - -// The highest precedence is at the top of the list and -// the lowest is at the bottom. -// Multiplicative: * / % -// Additive: + - -// Relational: < > <= >= -// Equality: == != -// Logical AND: && -// Logical OR: || -// Assignment: = += -= *= /= %= - -size(200, 200); -background(51); -noFill(); -stroke(51); - -stroke(204); -for(int i=0; i< width-20; i+= 4) { - // The 30 is added to 70 and then evaluated - // if it is greater than the current value of "i" - // For clarity, write as "if(i > (30 + 70)) {" - if(i > 30 + 70) { - line(i, 0, i, 50); - } -} - -stroke(255); -// The 2 is multiplied by the 8 and the result is added to the 5 -// For clarity, write as "rect(5 + (2 * 8), 0, 90, 20);" -rect(4 + 2 * 8, 52, 90, 48); -rect((4 + 2) * 8, 100, 90, 49); - -stroke(153); -for(int i=0; i< width; i+= 2) { - // The relational statements are evaluated - // first, and then the logical AND statements and - // finally the logical OR. For clarity, write as: - // "if(((i > 10) && (i < 50)) || ((i > 80) && (i < 160))) {" - if(i > 20 && i < 50 || i > 100 && i < width-20) { - line(i, 151, i, height-1); - } -} - - diff --git a/android/examples/Basics/Math/OperatorPrecedence/applet/loading.gif b/android/examples/Basics/Math/OperatorPrecedence/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/OperatorPrecedence/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.java b/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.java deleted file mode 100644 index 75a8ea736..000000000 --- a/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.java +++ /dev/null @@ -1,72 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class PolarToCartesian extends PApplet { - -/** - * PolarToCartesian - * by Daniel Shiffman. - * - * Convert a polar coordinate (r,theta) to cartesian (x,y): - * x = r * cos(theta) - * y = r * sin(theta) - */ - -float r; - -// Angle and angular velocity, accleration -float theta; -float theta_vel; -float theta_acc; - -public void setup() { - size(200,200); - frameRate(30); - smooth(); - - // Initialize all values - r = 50.0f; - theta = 0.0f; - theta_vel = 0.0f; - theta_acc = 0.0001f; -} - -public void draw() { - background(0); - // Translate the origin point to the center of the screen - translate(width/2,height/2); - - // Convert polar to cartesian - float x = r * cos(theta); - float y = r * sin(theta); - - // Draw the ellipse at the cartesian coordinate - ellipseMode(CENTER); - noStroke(); - fill(200); - ellipse(x,y,16,16); - - // Apply acceleration and velocity to angle (r remains static in this example) - theta_vel += theta_acc; - theta += theta_vel; - -} - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "PolarToCartesian" }); - } -} diff --git a/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.pde b/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.pde deleted file mode 100644 index fdcd948db..000000000 --- a/android/examples/Basics/Math/PolarToCartesian/applet/PolarToCartesian.pde +++ /dev/null @@ -1,52 +0,0 @@ -/** - * PolarToCartesian - * by Daniel Shiffman. - * - * Convert a polar coordinate (r,theta) to cartesian (x,y): - * x = r * cos(theta) - * y = r * sin(theta) - */ - -float r; - -// Angle and angular velocity, accleration -float theta; -float theta_vel; -float theta_acc; - -void setup() { - size(200,200); - frameRate(30); - smooth(); - - // Initialize all values - r = 50.0f; - theta = 0.0f; - theta_vel = 0.0f; - theta_acc = 0.0001f; -} - -void draw() { - background(0); - // Translate the origin point to the center of the screen - translate(width/2,height/2); - - // Convert polar to cartesian - float x = r * cos(theta); - float y = r * sin(theta); - - // Draw the ellipse at the cartesian coordinate - ellipseMode(CENTER); - noStroke(); - fill(200); - ellipse(x,y,16,16); - - // Apply acceleration and velocity to angle (r remains static in this example) - theta_vel += theta_acc; - theta += theta_vel; - -} - - - - diff --git a/android/examples/Basics/Math/PolarToCartesian/applet/loading.gif b/android/examples/Basics/Math/PolarToCartesian/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/PolarToCartesian/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/Random/applet/Random.java b/android/examples/Basics/Math/Random/applet/Random.java deleted file mode 100644 index ca26fea54..000000000 --- a/android/examples/Basics/Math/Random/applet/Random.java +++ /dev/null @@ -1,40 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Random extends PApplet { - public void setup() {/** - * Random. - * - * Random numbers create the basis of this image. - * Each time the program is loaded the result is different. - */ - -size(200, 200); -smooth(); -background(0); -strokeWeight(10); - -for(int i = 0; i < width; i++) { - float r = random(255); - float x = random(0, width); - stroke(r, 100); - line(i, 0, x, height); -} - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Random" }); - } -} diff --git a/android/examples/Basics/Math/Random/applet/Random.pde b/android/examples/Basics/Math/Random/applet/Random.pde deleted file mode 100644 index 5fa97b8f0..000000000 --- a/android/examples/Basics/Math/Random/applet/Random.pde +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Random. - * - * Random numbers create the basis of this image. - * Each time the program is loaded the result is different. - */ - -size(200, 200); -smooth(); -background(0); -strokeWeight(10); - -for(int i = 0; i < width; i++) { - float r = random(255); - float x = random(0, width); - stroke(r, 100); - line(i, 0, x, height); -} - diff --git a/android/examples/Basics/Math/Random/applet/loading.gif b/android/examples/Basics/Math/Random/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/Random/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/Sine/applet/Sine.java b/android/examples/Basics/Math/Sine/applet/Sine.java deleted file mode 100644 index a29502d3b..000000000 --- a/android/examples/Basics/Math/Sine/applet/Sine.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Sine extends PApplet { - -/** - * Sine. - * - * Smoothly scaling size with the sin() function. - */ - -float spin = 0.0f; -float diameter = 84.0f; -float angle; - -float angle_rot; -int rad_points = 90; - -public void setup() -{ - size(200, 200); - noStroke(); - smooth(); -} - -public void draw() -{ - background(153); - - translate(130, 65); - - fill(255); - ellipse(0, 0, 16, 16); - - angle_rot = 0; - fill(51); - - for(int i=0; i<5; i++) { - pushMatrix(); - rotate(angle_rot + -45); - ellipse(-116, 0, diameter, diameter); - popMatrix(); - angle_rot += PI*2/5; - } - - diameter = 34 * sin(angle) + 168; - - angle += 0.02f; - if (angle > TWO_PI) { angle = 0; } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Sine" }); - } -} diff --git a/android/examples/Basics/Math/Sine/applet/Sine.pde b/android/examples/Basics/Math/Sine/applet/Sine.pde deleted file mode 100644 index 848add369..000000000 --- a/android/examples/Basics/Math/Sine/applet/Sine.pde +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Sine. - * - * Smoothly scaling size with the sin() function. - */ - -float spin = 0.0; -float diameter = 84.0; -float angle; - -float angle_rot; -int rad_points = 90; - -void setup() -{ - size(200, 200); - noStroke(); - smooth(); -} - -void draw() -{ - background(153); - - translate(130, 65); - - fill(255); - ellipse(0, 0, 16, 16); - - angle_rot = 0; - fill(51); - - for(int i=0; i<5; i++) { - pushMatrix(); - rotate(angle_rot + -45); - ellipse(-116, 0, diameter, diameter); - popMatrix(); - angle_rot += PI*2/5; - } - - diameter = 34 * sin(angle) + 168; - - angle += 0.02; - if (angle > TWO_PI) { angle = 0; } -} - diff --git a/android/examples/Basics/Math/Sine/applet/loading.gif b/android/examples/Basics/Math/Sine/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/Sine/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/SineCosine/applet/SineCosine.java b/android/examples/Basics/Math/SineCosine/applet/SineCosine.java deleted file mode 100644 index c308f7fed..000000000 --- a/android/examples/Basics/Math/SineCosine/applet/SineCosine.java +++ /dev/null @@ -1,79 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class SineCosine extends PApplet { - -/** - * Sine Cosine. - * - * Linear movement with sin() and cos(). - * Numbers between 0 and PI*2 (TWO_PI which is roughly 6.28) - * are put into these functions and numbers between -1 and 1 are - * returned. These values are then scaled to produce larger movements. - */ - -int i = 45; -int j = 225; -float pos1 = 0; -float pos2 = 0; -float pos3 = 0; -float pos4 = 0; -int sc = 40; - -public void setup() -{ - size(200, 200); - noStroke(); - smooth(); -} - -public void draw() -{ - background(0); - - fill(51); - rect(60, 60, 80, 80); - - fill(255); - ellipse(pos1, 36, 32, 32); - - fill(153); - ellipse(36, pos2, 32, 32); - - fill(255); - ellipse(pos3, 164, 32, 32); - - fill(153); - ellipse(164, pos4, 32, 32); - - i += 3; - j -= 3; - - if(i > 405) { - i = 45; - j = 225; - } - - float ang1 = radians(i); // convert degrees to radians - float ang2 = radians(j); // convert degrees to radians - pos1 = width/2 + (sc * cos(ang1)); - pos2 = width/2 + (sc * sin(ang1)); - pos3 = width/2 + (sc * cos(ang2)); - pos4 = width/2 + (sc * sin(ang2)); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "SineCosine" }); - } -} diff --git a/android/examples/Basics/Math/SineCosine/applet/SineCosine.pde b/android/examples/Basics/Math/SineCosine/applet/SineCosine.pde deleted file mode 100644 index 4a40ddee2..000000000 --- a/android/examples/Basics/Math/SineCosine/applet/SineCosine.pde +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Sine Cosine. - * - * Linear movement with sin() and cos(). - * Numbers between 0 and PI*2 (TWO_PI which is roughly 6.28) - * are put into these functions and numbers between -1 and 1 are - * returned. These values are then scaled to produce larger movements. - */ - -int i = 45; -int j = 225; -float pos1 = 0; -float pos2 = 0; -float pos3 = 0; -float pos4 = 0; -int sc = 40; - -void setup() -{ - size(200, 200); - noStroke(); - smooth(); -} - -void draw() -{ - background(0); - - fill(51); - rect(60, 60, 80, 80); - - fill(255); - ellipse(pos1, 36, 32, 32); - - fill(153); - ellipse(36, pos2, 32, 32); - - fill(255); - ellipse(pos3, 164, 32, 32); - - fill(153); - ellipse(164, pos4, 32, 32); - - i += 3; - j -= 3; - - if(i > 405) { - i = 45; - j = 225; - } - - float ang1 = radians(i); // convert degrees to radians - float ang2 = radians(j); // convert degrees to radians - pos1 = width/2 + (sc * cos(ang1)); - pos2 = width/2 + (sc * sin(ang1)); - pos3 = width/2 + (sc * cos(ang2)); - pos4 = width/2 + (sc * sin(ang2)); -} - diff --git a/android/examples/Basics/Math/SineCosine/applet/loading.gif b/android/examples/Basics/Math/SineCosine/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/SineCosine/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Math/SineWave/applet/SineWave.java b/android/examples/Basics/Math/SineWave/applet/SineWave.java deleted file mode 100644 index 165700473..000000000 --- a/android/examples/Basics/Math/SineWave/applet/SineWave.java +++ /dev/null @@ -1,75 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class SineWave extends PApplet { - -/** - * Sine Wave - * by Daniel Shiffman. - * - * Render a simple sine wave. - */ - -int xspacing = 8; // How far apart should each horizontal location be spaced -int w; // Width of entire wave - -float theta = 0.0f; // Start angle at 0 -float amplitude = 75.0f; // Height of wave -float period = 500.0f; // How many pixels before the wave repeats -float dx; // Value for incrementing X, a function of period and xspacing -float[] yvalues; // Using an array to store height values for the wave - -public void setup() { - size(200,200); - frameRate(30); - colorMode(RGB,255,255,255,100); - smooth(); - w = width+16; - dx = (TWO_PI / period) * xspacing; - yvalues = new float[w/xspacing]; -} - -public void draw() { - background(0); - calcWave(); - renderWave(); - -} - -public void calcWave() { - // Increment theta (try different values for 'angular velocity' here - theta += 0.02f; - - // For every x value, calculate a y value with sine function - float x = theta; - for (int i = 0; i < yvalues.length; i++) { - yvalues[i] = sin(x)*amplitude; - x+=dx; - } -} - -public void renderWave() { - // A simple way to draw the wave with an ellipse at each location - for (int x = 0; x < yvalues.length; x++) { - noStroke(); - fill(255,50); - ellipseMode(CENTER); - ellipse(x*xspacing,width/2+yvalues[x],16,16); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "SineWave" }); - } -} diff --git a/android/examples/Basics/Math/SineWave/applet/SineWave.pde b/android/examples/Basics/Math/SineWave/applet/SineWave.pde deleted file mode 100644 index da47bed36..000000000 --- a/android/examples/Basics/Math/SineWave/applet/SineWave.pde +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Sine Wave - * by Daniel Shiffman. - * - * Render a simple sine wave. - */ - -int xspacing = 8; // How far apart should each horizontal location be spaced -int w; // Width of entire wave - -float theta = 0.0; // Start angle at 0 -float amplitude = 75.0; // Height of wave -float period = 500.0; // How many pixels before the wave repeats -float dx; // Value for incrementing X, a function of period and xspacing -float[] yvalues; // Using an array to store height values for the wave - -void setup() { - size(200,200); - frameRate(30); - colorMode(RGB,255,255,255,100); - smooth(); - w = width+16; - dx = (TWO_PI / period) * xspacing; - yvalues = new float[w/xspacing]; -} - -void draw() { - background(0); - calcWave(); - renderWave(); - -} - -void calcWave() { - // Increment theta (try different values for 'angular velocity' here - theta += 0.02; - - // For every x value, calculate a y value with sine function - float x = theta; - for (int i = 0; i < yvalues.length; i++) { - yvalues[i] = sin(x)*amplitude; - x+=dx; - } -} - -void renderWave() { - // A simple way to draw the wave with an ellipse at each location - for (int x = 0; x < yvalues.length; x++) { - noStroke(); - fill(255,50); - ellipseMode(CENTER); - ellipse(x*xspacing,width/2+yvalues[x],16,16); - } -} - diff --git a/android/examples/Basics/Math/SineWave/applet/loading.gif b/android/examples/Basics/Math/SineWave/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Math/SineWave/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.java b/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.java deleted file mode 100644 index 3da16d412..000000000 --- a/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.java +++ /dev/null @@ -1,125 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class CompositeObjects extends PApplet { - -/** - * Composite Objects - * - * An object can include several other objects. Creating such composite objects - * is a good way to use the principles of modularity and build higher levels of - * abstraction within a program. - */ - -EggRing er1, er2; - -public void setup() -{ - size(200, 200); - smooth(); - er1 = new EggRing(66, 132, 0.1f, 66); - er2 = new EggRing(132, 180, 0.05f, 132); -} - -public void draw() -{ - background(0); - er1.transmit(); - er2.transmit(); -} - -class EggRing -{ - Egg ovoid; - Ring circle = new Ring(); - EggRing(int x, int y, float t, float sp) { - ovoid = new Egg(x, y, t, sp); - circle.start(x, y - sp/2); - } - public void transmit() { - ovoid.wobble(); - ovoid.display(); - circle.grow(); - circle.display(); - if (circle.on == false) { - circle.on = true; - } - } -} - -class Egg { - float x, y; // X-coordinate, y-coordinate - float tilt; // Left and right angle offset - float angle; // Used to define the tilt - float scalar; // Height of the egg - // Constructor - Egg(int xpos, int ypos, float t, float s) { - x = xpos; - y = ypos; - tilt = t; - scalar = s / 100.0f; - } - public void wobble() { - tilt = cos(angle) / 8; - angle += 0.1f; - } - public void display() { - noStroke(); - fill(255); - pushMatrix(); - translate(x, y); - rotate(tilt); - scale(scalar); - beginShape(); - vertex(0, -100); - bezierVertex(25, -100, 40, -65, 40, -40); - bezierVertex(40, -15, 25, 0, 0, 0); - bezierVertex(-25, 0, -40, -15, -40, -40); - bezierVertex(-40, -65, -25, -100, 0, -100); - endShape(); - popMatrix(); - } -} - -class Ring { - float x, y; // X-coordinate, y-coordinate - float diameter; // Diameter of the ring - boolean on = false; // Turns the display on and off - public void start(float xpos, float ypos) { - x = xpos; - y = ypos; - on = true; - diameter = 1; - } - public void grow() { - if (on == true) { - diameter += 0.5f; - if (diameter > width*2) { - diameter = 0.0f; - } - } - } - public void display() { - if (on == true) { - noFill(); - strokeWeight(4); - stroke(155, 153); - ellipse(x, y, diameter, diameter); - } - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "CompositeObjects" }); - } -} diff --git a/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.pde b/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.pde deleted file mode 100644 index 171c03ae9..000000000 --- a/android/examples/Basics/Objects/CompositeObjects/applet/CompositeObjects.pde +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Composite Objects - * - * An object can include several other objects. Creating such composite objects - * is a good way to use the principles of modularity and build higher levels of - * abstraction within a program. - */ - -EggRing er1, er2; - -void setup() -{ - size(200, 200); - smooth(); - er1 = new EggRing(66, 132, 0.1, 66); - er2 = new EggRing(132, 180, 0.05, 132); -} - -void draw() -{ - background(0); - er1.transmit(); - er2.transmit(); -} - -class EggRing -{ - Egg ovoid; - Ring circle = new Ring(); - EggRing(int x, int y, float t, float sp) { - ovoid = new Egg(x, y, t, sp); - circle.start(x, y - sp/2); - } - void transmit() { - ovoid.wobble(); - ovoid.display(); - circle.grow(); - circle.display(); - if (circle.on == false) { - circle.on = true; - } - } -} - -class Egg { - float x, y; // X-coordinate, y-coordinate - float tilt; // Left and right angle offset - float angle; // Used to define the tilt - float scalar; // Height of the egg - // Constructor - Egg(int xpos, int ypos, float t, float s) { - x = xpos; - y = ypos; - tilt = t; - scalar = s / 100.0; - } - void wobble() { - tilt = cos(angle) / 8; - angle += 0.1; - } - void display() { - noStroke(); - fill(255); - pushMatrix(); - translate(x, y); - rotate(tilt); - scale(scalar); - beginShape(); - vertex(0, -100); - bezierVertex(25, -100, 40, -65, 40, -40); - bezierVertex(40, -15, 25, 0, 0, 0); - bezierVertex(-25, 0, -40, -15, -40, -40); - bezierVertex(-40, -65, -25, -100, 0, -100); - endShape(); - popMatrix(); - } -} - -class Ring { - float x, y; // X-coordinate, y-coordinate - float diameter; // Diameter of the ring - boolean on = false; // Turns the display on and off - void start(float xpos, float ypos) { - x = xpos; - y = ypos; - on = true; - diameter = 1; - } - void grow() { - if (on == true) { - diameter += 0.5; - if (diameter > width*2) { - diameter = 0.0; - } - } - } - void display() { - if (on == true) { - noFill(); - strokeWeight(4); - stroke(155, 153); - ellipse(x, y, diameter, diameter); - } - } -} diff --git a/android/examples/Basics/Objects/CompositeObjects/applet/loading.gif b/android/examples/Basics/Objects/CompositeObjects/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Objects/CompositeObjects/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Objects/Inheritance/applet/Inheritance.java b/android/examples/Basics/Objects/Inheritance/applet/Inheritance.java deleted file mode 100644 index 6b517719f..000000000 --- a/android/examples/Basics/Objects/Inheritance/applet/Inheritance.java +++ /dev/null @@ -1,98 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Inheritance extends PApplet { - -/** - * Inheritance - * - * A class can be defined using another class as a foundation. In object-oriented - * programming terminology, one class can inherit fi elds and methods from another. - * An object that inherits from another is called a subclass, and the object it - * inherits from is called a superclass. A subclass extends the superclass. - */ - -SpinSpots spots; -SpinArm arm; - -public void setup() -{ - size(200, 200); - smooth(); - arm = new SpinArm(width/2, height/2, 0.01f); - spots = new SpinSpots(width/2, height/2, -0.02f, 33.0f); -} - -public void draw() -{ - background(204); - arm.update(); - arm.display(); - spots.update(); - spots.display(); -} - -class Spin -{ - float x, y, speed; - float angle = 0.0f; - Spin(float xpos, float ypos, float s) { - x = xpos; - y = ypos; - speed = s; - } - public void update() { - angle += speed; - } -} - -class SpinArm extends Spin -{ - SpinArm(float x, float y, float s) { - super(x, y, s); - } - public void display() { - strokeWeight(1); - stroke(0); - pushMatrix(); - translate(x, y); - angle += speed; - rotate(angle); - line(0, 0, 66, 0); - popMatrix(); - } -} - -class SpinSpots extends Spin -{ - float dim; - SpinSpots(float x, float y, float s, float d) { - super(x, y, s); - dim = d; - } - public void display() { - noStroke(); - pushMatrix(); - translate(x, y); - angle += speed; - rotate(angle); - ellipse(-dim/2, 0, dim, dim); - ellipse(dim/2, 0, dim, dim); - popMatrix(); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Inheritance" }); - } -} diff --git a/android/examples/Basics/Objects/Inheritance/applet/Inheritance.pde b/android/examples/Basics/Objects/Inheritance/applet/Inheritance.pde deleted file mode 100644 index 6c4af0bc8..000000000 --- a/android/examples/Basics/Objects/Inheritance/applet/Inheritance.pde +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Inheritance - * - * A class can be defined using another class as a foundation. In object-oriented - * programming terminology, one class can inherit fi elds and methods from another. - * An object that inherits from another is called a subclass, and the object it - * inherits from is called a superclass. A subclass extends the superclass. - */ - -SpinSpots spots; -SpinArm arm; - -void setup() -{ - size(200, 200); - smooth(); - arm = new SpinArm(width/2, height/2, 0.01); - spots = new SpinSpots(width/2, height/2, -0.02, 33.0); -} - -void draw() -{ - background(204); - arm.update(); - arm.display(); - spots.update(); - spots.display(); -} - -class Spin -{ - float x, y, speed; - float angle = 0.0; - Spin(float xpos, float ypos, float s) { - x = xpos; - y = ypos; - speed = s; - } - void update() { - angle += speed; - } -} - -class SpinArm extends Spin -{ - SpinArm(float x, float y, float s) { - super(x, y, s); - } - void display() { - strokeWeight(1); - stroke(0); - pushMatrix(); - translate(x, y); - angle += speed; - rotate(angle); - line(0, 0, 66, 0); - popMatrix(); - } -} - -class SpinSpots extends Spin -{ - float dim; - SpinSpots(float x, float y, float s, float d) { - super(x, y, s); - dim = d; - } - void display() { - noStroke(); - pushMatrix(); - translate(x, y); - angle += speed; - rotate(angle); - ellipse(-dim/2, 0, dim, dim); - ellipse(dim/2, 0, dim, dim); - popMatrix(); - } -} diff --git a/android/examples/Basics/Objects/Inheritance/applet/loading.gif b/android/examples/Basics/Objects/Inheritance/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Objects/Inheritance/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.java b/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.java deleted file mode 100644 index db8031348..000000000 --- a/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.java +++ /dev/null @@ -1,67 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class MultipleConstructors extends PApplet { - -/** - * Multiple constructors - * - * A class can have multiple constructors that assign the fields in different ways. - * Sometimes it's beneficial to specify every aspect of an object's data by assigning - * parameters to the fields, but other times it might be appropriate to define only - * one or a few. - */ - -Spot sp1, sp2; -public void setup() -{ - size(200, 200); - background(204); - smooth(); - noLoop(); - // Run the constructor without parameters - sp1 = new Spot(); - // Run the constructor with three parameters - sp2 = new Spot(122, 100, 40); -} - -public void draw() { - sp1.display(); - sp2.display(); -} - -class Spot { - float x, y, radius; - // First version of the Spot constructor; - // the fields are assigned default values - Spot() { - x = 66; - y = 100; - radius = 16; - } - // Second version of the Spot constructor; - // the fields are assigned with parameters - Spot(float xpos, float ypos, float r) { - x = xpos; - y = ypos; - radius = r; - } - public void display() { - ellipse(x, y, radius*2, radius*2); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "MultipleConstructors" }); - } -} diff --git a/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.pde b/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.pde deleted file mode 100644 index fd57edbfd..000000000 --- a/android/examples/Basics/Objects/MultipleConstructors/applet/MultipleConstructors.pde +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Multiple constructors - * - * A class can have multiple constructors that assign the fields in different ways. - * Sometimes it's beneficial to specify every aspect of an object's data by assigning - * parameters to the fields, but other times it might be appropriate to define only - * one or a few. - */ - -Spot sp1, sp2; -void setup() -{ - size(200, 200); - background(204); - smooth(); - noLoop(); - // Run the constructor without parameters - sp1 = new Spot(); - // Run the constructor with three parameters - sp2 = new Spot(122, 100, 40); -} - -void draw() { - sp1.display(); - sp2.display(); -} - -class Spot { - float x, y, radius; - // First version of the Spot constructor; - // the fields are assigned default values - Spot() { - x = 66; - y = 100; - radius = 16; - } - // Second version of the Spot constructor; - // the fields are assigned with parameters - Spot(float xpos, float ypos, float r) { - x = xpos; - y = ypos; - radius = r; - } - void display() { - ellipse(x, y, radius*2, radius*2); - } -} diff --git a/android/examples/Basics/Objects/MultipleConstructors/applet/loading.gif b/android/examples/Basics/Objects/MultipleConstructors/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Objects/MultipleConstructors/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.java b/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.java deleted file mode 100644 index d6646893c..000000000 --- a/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.java +++ /dev/null @@ -1,323 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Neighborhood extends PApplet { - -/** - * Neighborhood (OOP Example) - * By Ira Greenberg - * - * Draw a neighborhood of houses using - * Door, Window, Roof and House classes. - * Good example of class composition, with component - * Door, Window, Roof class references encapsulated - * within House class. This arrangement allows - * House class to handle placement and sizing of - * its components, while still allowing user - * customization of the individual components. - */ - -public void setup(){ - size(200, 200); - background(190); - smooth(); - // Ground plane - int groundHeight = 10; - fill(0); - rect(0, height-groundHeight, width, groundHeight); - fill(255); - - // Center the houses - translate(12, 0); - - // Houses - Door door1 = new Door(20, 40); - Window window1 = new Window(50, 62, false, Window.DOUBLE); - Roof roof1 = new Roof(Roof.DOME); - House house1 = new House(75, 75, door1, window1, roof1, House.MIDDLE_DOOR); - house1.drawHouse(0, height-groundHeight-house1.h, true); - - Door door2 = new Door(20, 40); - Window window2 = new Window(50, 62, true, Window.QUAD); - Roof roof2 = new Roof(Roof.GAMBREL); - House house2 = new House(100, 60, door2, window2, roof2, House.LEFT_DOOR); - house2.drawHouse(house1.x + house1.w, height-groundHeight-house2.h, true); -} - -class Door{ - //door properties - int x; - int y; - int w; - int h; - - // for knob - int knobLoc = 1; - //constants - final static int RT = 0; - final static int LFT = 1; - - // constructor - Door(int w, int h){ - this.w = w; - this.h = h; - } - - // draw the door - public void drawDoor(int x, int y) { - rect(x, y, w, h); - int knobsize = w/10; - if (knobLoc == 0){ - //right side - ellipse(x+w-knobsize, y+h/2, knobsize, knobsize); - } - else { - //left side - ellipse(x+knobsize, y+h/2, knobsize, knobsize); - } - } - - // set knob position - public void setKnob(int knobLoc){ - this. knobLoc = knobLoc; - } -} - -class Window{ - //window properties - int x; - int y; - int w; - int h; - - // customized features - boolean hasSash = false; - - // single, double, quad pane - int style = 0; - //constants - final static int SINGLE = 0; - final static int DOUBLE = 1; - final static int QUAD = 2; - - // constructor 1 - Window(int w, int h){ - this.w = w; - this.h = h; - } - // constructor 2 - Window(int w, int h, int style){ - this.w = w; - this.h = h; - this.style = style; - } - // constructor 3 - Window(int w, int h, boolean hasSash, int style){ - this.w = w; - this.h = h; - this.hasSash = hasSash; - this.style = style; - } - - // draw the window - public void drawWindow(int x, int y) { - //local variables - int margin = 0; - int winHt = 0; - int winWdth = 0; - - if (hasSash){ - margin = w/15; - } - - switch(style){ - case 0: - //outer window (sash) - rect(x, y, w, h); - //inner window - rect(x+margin, y+margin, w-margin*2, h-margin*2); - break; - case 1: - winHt = (h-margin*3)/2; - //outer window (sash) - rect(x, y, w, h); - //inner window (top) - rect(x+margin, y+margin, w-margin*2, winHt); - //inner windows (bottom) - rect(x+margin, y+winHt+margin*2, w-margin*2, winHt); - break; - case 2: - winWdth = (w-margin*3)/2; - winHt = (h-margin*3)/2; - //outer window (sash) - rect(x, y, w, h); - //inner window (top-left) - rect(x+margin, y+margin, winWdth, winHt); - //inner window (top-right) - rect(x+winWdth+margin*2, y+margin, winWdth, winHt); - //inner windows (bottom-left) - rect(x+margin, y+winHt+margin*2, winWdth, winHt); - //inner windows (bottom-right) - rect(x+winWdth+margin*2, y+winHt+margin*2, winWdth, winHt); - break; - } - } - - // set window style (number of panes) - public void setStyle(int style){ - this.style = style; - } -} - -class Roof{ - //roof properties - int x; - int y; - int w; - int h; - - // roof style - int style = 0; - //constants - final static int CATHEDRAL = 0; - final static int GAMBREL = 1; - final static int DOME = 2; - - // default constructor - Roof(){ - } - - // constructor 2 - Roof(int style){ - this.style = style; - } - - // draw the roof - public void drawRoof(int x, int y, int w, int h) { - switch(style){ - case 0: - beginShape(); - vertex(x, y); - vertex(x+w/2, y-h/3); - vertex(x+w, y); - endShape(CLOSE); - break; - case 1: - beginShape(); - vertex(x, y); - vertex(x+w/7, y-h/4); - vertex(x+w/2, y-h/2); - vertex(x+(w-w/7), y-h/4); - vertex(x+w, y); - endShape(CLOSE); - break; - case 2: - ellipseMode(CORNER); - arc(x, y-h/2, w, h, PI, TWO_PI); - line(x, y, x+w, y); - break; - } - - } - - // set roof style - public void setStyle(int style){ - this.style = style; - } -} - -class House{ - //house properties - int x; - int y; - int w; - int h; - - //component reference variables - Door door; - Window window; - Roof roof; - - //optional autosize variable - boolean AutoSizeComponents = false; - - //door placement - int doorLoc = 0; - //constants - final static int MIDDLE_DOOR = 0; - final static int LEFT_DOOR = 1; - final static int RIGHT_DOOR = 2; - - //constructor - House(int w, int h, Door door, Window window, Roof roof, int doorLoc) { - this.w = w; - this.h = h; - this.door = door; - this.window = window; - this.roof = roof; - this.doorLoc = doorLoc; - } - - public void drawHouse(int x, int y, boolean AutoSizeComponents) { - this.x = x; - this.y =y; - this.AutoSizeComponents = AutoSizeComponents; - - //automatically sizes doors and windows - if(AutoSizeComponents){ - //autosize door - door.h = h/4; - door.w = door.h/2; - - //autosize windows - window.h = h/3; - window.w = window.h/2; - - } - // draw bldg block - rect(x, y, w, h); - - // draw door - switch(doorLoc){ - case 0: - door.drawDoor(x+w/2-door.w/2, y+h-door.h); - break; - case 1: - door.drawDoor(x+w/8, y+h-door.h); - break; - case 2: - door.drawDoor(x+w-w/8-door.w, y+h-door.h); - break; - } - - // draw windows - int windowMargin = (w-window.w*2)/3; - window.drawWindow(x+windowMargin, y+h/6); - window.drawWindow(x+windowMargin*2+window.w, y+h/6); - - // draw roof - roof.drawRoof(x, y, w, h); - } - - // catch drawHouse method without boolean argument - public void drawHouse(int x, int y){ - // recall with required 3rd argument - drawHouse(x, y, false); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Neighborhood" }); - } -} diff --git a/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.pde b/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.pde deleted file mode 100644 index f70893d25..000000000 --- a/android/examples/Basics/Objects/Neighborhood/applet/Neighborhood.pde +++ /dev/null @@ -1,303 +0,0 @@ -/** - * Neighborhood (OOP Example) - * By Ira Greenberg - * - * Draw a neighborhood of houses using - * Door, Window, Roof and House classes. - * Good example of class composition, with component - * Door, Window, Roof class references encapsulated - * within House class. This arrangement allows - * House class to handle placement and sizing of - * its components, while still allowing user - * customization of the individual components. - */ - -void setup(){ - size(200, 200); - background(190); - smooth(); - // Ground plane - int groundHeight = 10; - fill(0); - rect(0, height-groundHeight, width, groundHeight); - fill(255); - - // Center the houses - translate(12, 0); - - // Houses - Door door1 = new Door(20, 40); - Window window1 = new Window(50, 62, false, Window.DOUBLE); - Roof roof1 = new Roof(Roof.DOME); - House house1 = new House(75, 75, door1, window1, roof1, House.MIDDLE_DOOR); - house1.drawHouse(0, height-groundHeight-house1.h, true); - - Door door2 = new Door(20, 40); - Window window2 = new Window(50, 62, true, Window.QUAD); - Roof roof2 = new Roof(Roof.GAMBREL); - House house2 = new House(100, 60, door2, window2, roof2, House.LEFT_DOOR); - house2.drawHouse(house1.x + house1.w, height-groundHeight-house2.h, true); -} - -class Door{ - //door properties - int x; - int y; - int w; - int h; - - // for knob - int knobLoc = 1; - //constants - final static int RT = 0; - final static int LFT = 1; - - // constructor - Door(int w, int h){ - this.w = w; - this.h = h; - } - - // draw the door - void drawDoor(int x, int y) { - rect(x, y, w, h); - int knobsize = w/10; - if (knobLoc == 0){ - //right side - ellipse(x+w-knobsize, y+h/2, knobsize, knobsize); - } - else { - //left side - ellipse(x+knobsize, y+h/2, knobsize, knobsize); - } - } - - // set knob position - void setKnob(int knobLoc){ - this. knobLoc = knobLoc; - } -} - -class Window{ - //window properties - int x; - int y; - int w; - int h; - - // customized features - boolean hasSash = false; - - // single, double, quad pane - int style = 0; - //constants - final static int SINGLE = 0; - final static int DOUBLE = 1; - final static int QUAD = 2; - - // constructor 1 - Window(int w, int h){ - this.w = w; - this.h = h; - } - // constructor 2 - Window(int w, int h, int style){ - this.w = w; - this.h = h; - this.style = style; - } - // constructor 3 - Window(int w, int h, boolean hasSash, int style){ - this.w = w; - this.h = h; - this.hasSash = hasSash; - this.style = style; - } - - // draw the window - void drawWindow(int x, int y) { - //local variables - int margin = 0; - int winHt = 0; - int winWdth = 0; - - if (hasSash){ - margin = w/15; - } - - switch(style){ - case 0: - //outer window (sash) - rect(x, y, w, h); - //inner window - rect(x+margin, y+margin, w-margin*2, h-margin*2); - break; - case 1: - winHt = (h-margin*3)/2; - //outer window (sash) - rect(x, y, w, h); - //inner window (top) - rect(x+margin, y+margin, w-margin*2, winHt); - //inner windows (bottom) - rect(x+margin, y+winHt+margin*2, w-margin*2, winHt); - break; - case 2: - winWdth = (w-margin*3)/2; - winHt = (h-margin*3)/2; - //outer window (sash) - rect(x, y, w, h); - //inner window (top-left) - rect(x+margin, y+margin, winWdth, winHt); - //inner window (top-right) - rect(x+winWdth+margin*2, y+margin, winWdth, winHt); - //inner windows (bottom-left) - rect(x+margin, y+winHt+margin*2, winWdth, winHt); - //inner windows (bottom-right) - rect(x+winWdth+margin*2, y+winHt+margin*2, winWdth, winHt); - break; - } - } - - // set window style (number of panes) - void setStyle(int style){ - this.style = style; - } -} - -class Roof{ - //roof properties - int x; - int y; - int w; - int h; - - // roof style - int style = 0; - //constants - final static int CATHEDRAL = 0; - final static int GAMBREL = 1; - final static int DOME = 2; - - // default constructor - Roof(){ - } - - // constructor 2 - Roof(int style){ - this.style = style; - } - - // draw the roof - void drawRoof(int x, int y, int w, int h) { - switch(style){ - case 0: - beginShape(); - vertex(x, y); - vertex(x+w/2, y-h/3); - vertex(x+w, y); - endShape(CLOSE); - break; - case 1: - beginShape(); - vertex(x, y); - vertex(x+w/7, y-h/4); - vertex(x+w/2, y-h/2); - vertex(x+(w-w/7), y-h/4); - vertex(x+w, y); - endShape(CLOSE); - break; - case 2: - ellipseMode(CORNER); - arc(x, y-h/2, w, h, PI, TWO_PI); - line(x, y, x+w, y); - break; - } - - } - - // set roof style - void setStyle(int style){ - this.style = style; - } -} - -class House{ - //house properties - int x; - int y; - int w; - int h; - - //component reference variables - Door door; - Window window; - Roof roof; - - //optional autosize variable - boolean AutoSizeComponents = false; - - //door placement - int doorLoc = 0; - //constants - final static int MIDDLE_DOOR = 0; - final static int LEFT_DOOR = 1; - final static int RIGHT_DOOR = 2; - - //constructor - House(int w, int h, Door door, Window window, Roof roof, int doorLoc) { - this.w = w; - this.h = h; - this.door = door; - this.window = window; - this.roof = roof; - this.doorLoc = doorLoc; - } - - void drawHouse(int x, int y, boolean AutoSizeComponents) { - this.x = x; - this.y =y; - this.AutoSizeComponents = AutoSizeComponents; - - //automatically sizes doors and windows - if(AutoSizeComponents){ - //autosize door - door.h = h/4; - door.w = door.h/2; - - //autosize windows - window.h = h/3; - window.w = window.h/2; - - } - // draw bldg block - rect(x, y, w, h); - - // draw door - switch(doorLoc){ - case 0: - door.drawDoor(x+w/2-door.w/2, y+h-door.h); - break; - case 1: - door.drawDoor(x+w/8, y+h-door.h); - break; - case 2: - door.drawDoor(x+w-w/8-door.w, y+h-door.h); - break; - } - - // draw windows - int windowMargin = (w-window.w*2)/3; - window.drawWindow(x+windowMargin, y+h/6); - window.drawWindow(x+windowMargin*2+window.w, y+h/6); - - // draw roof - roof.drawRoof(x, y, w, h); - } - - // catch drawHouse method without boolean argument - void drawHouse(int x, int y){ - // recall with required 3rd argument - drawHouse(x, y, false); - } -} - diff --git a/android/examples/Basics/Objects/Neighborhood/applet/loading.gif b/android/examples/Basics/Objects/Neighborhood/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Objects/Neighborhood/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Objects/Objects/applet/Objects.java b/android/examples/Basics/Objects/Objects/applet/Objects.java deleted file mode 100644 index 88f03739f..000000000 --- a/android/examples/Basics/Objects/Objects/applet/Objects.java +++ /dev/null @@ -1,91 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Objects extends PApplet { - -/** - * Objects - * by hbarragan. - * - * Move the cursor across the image to change the speed and positions - * of the geometry. The class MRect defines a group of lines. - */ - -MRect r1, r2, r3, r4; - -public void setup() -{ - size(200, 200); - fill(255, 204); - noStroke(); - r1 = new MRect(1, 134.0f, 0.532f, 0.083f*height, 10.0f, 60.0f); - r2 = new MRect(2, 44.0f, 0.166f, 0.332f*height, 5.0f, 50.0f); - r3 = new MRect(2, 58.0f, 0.332f, 0.4482f*height, 10.0f, 35.0f); - r4 = new MRect(1, 120.0f, 0.0498f, 0.913f*height, 15.0f, 60.0f); -} - -public void draw() -{ - background(0); - - r1.display(); - r2.display(); - r3.display(); - r4.display(); - - r1.move(mouseX-(width/2), mouseY+(height*0.1f), 30); - r2.move((mouseX+(width*0.05f))%width, mouseY+(height*0.025f), 20); - r3.move(mouseX/4, mouseY-(height*0.025f), 40); - r4.move(mouseX-(width/2), (height-mouseY), 50); -} - -class MRect -{ - int w; // single bar width - float xpos; // rect xposition - float h; // rect height - float ypos ; // rect yposition - float d; // single bar distance - float t; // number of bars - - MRect(int iw, float ixp, float ih, float iyp, float id, float it) { - w = iw; - xpos = ixp; - h = ih; - ypos = iyp; - d = id; - t = it; - } - - public void move (float posX, float posY, float damping) { - float dif = ypos - posY; - if (abs(dif) > 1) { - ypos -= dif/damping; - } - dif = xpos - posX; - if (abs(dif) > 1) { - xpos -= dif/damping; - } - } - - public void display() { - for (int i=0; i 1) { - ypos -= dif/damping; - } - dif = xpos - posX; - if (abs(dif) > 1) { - xpos -= dif/damping; - } - } - - void display() { - for (int i=0; i 1) { - level = level - 1; - drawCircle(x - radius/2, radius/2, level); - drawCircle(x + radius/2, radius/2, level); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Recursion" }); - } -} diff --git a/android/examples/Basics/Structure/Recursion/applet/Recursion.pde b/android/examples/Basics/Structure/Recursion/applet/Recursion.pde deleted file mode 100644 index 2e77668f4..000000000 --- a/android/examples/Basics/Structure/Recursion/applet/Recursion.pde +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Recursion. - * - * A demonstration of recursion, which means functions call themselves. - * Notice how the drawCircle() function calls itself at the end of its block. - * It continues to do this until the variable "level" is equal to 1. - */ - -void setup() -{ - size(200, 200); - noStroke(); - smooth(); - noLoop(); -} - -void draw() -{ - drawCircle(126, 170, 6); -} - -void drawCircle(int x, int radius, int level) -{ - float tt = 126 * level/4.0; - fill(tt); - ellipse(x, 100, radius*2, radius*2); - if(level > 1) { - level = level - 1; - drawCircle(x - radius/2, radius/2, level); - drawCircle(x + radius/2, radius/2, level); - } -} diff --git a/android/examples/Basics/Structure/Recursion/applet/loading.gif b/android/examples/Basics/Structure/Recursion/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Structure/Recursion/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Structure/Recursion2/applet/Recursion2.java b/android/examples/Basics/Structure/Recursion2/applet/Recursion2.java deleted file mode 100644 index baa0fa0bb..000000000 --- a/android/examples/Basics/Structure/Recursion2/applet/Recursion2.java +++ /dev/null @@ -1,52 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Recursion2 extends PApplet { - -/** - * Recursion. - * - * A demonstration of recursion, which means functions call themselves. - * Notice how the drawCircle() function calls itself at the end of its block. - * It continues to do this until the variable "level" is equal to 1. - */ - -public void setup() -{ - size(200, 200); - noStroke(); - smooth(); - drawCircle(100, 100, 80, 8); -} - -public void drawCircle(float x, float y, int radius, int level) -{ - float tt = 126 * level/6.0f; - fill(tt, 153); - ellipse(x, y, radius*2, radius*2); - if(level > 1) { - level = level - 1; - int num = PApplet.parseInt(random(2, 6)); - for(int i=0; i 1) { - level = level - 1; - int num = int(random(2, 6)); - for(int i=0; i width + size) { - x = -size; - } - - translate(x, height/2-size/2); - fill(255); - rect(-size/2, -size/2, size, size); - - // Transforms accumulate. - // Notice how this rect moves twice - // as fast as the other, but it has - // the same parameter for the x-axis value - translate(x, size); - fill(0); - rect(-size/2, -size/2, size, size); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Translate" }); - } -} diff --git a/android/examples/Basics/Transform/Translate/applet/Translate.pde b/android/examples/Basics/Transform/Translate/applet/Translate.pde deleted file mode 100644 index 81b39af9d..000000000 --- a/android/examples/Basics/Transform/Translate/applet/Translate.pde +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Translate. - * - * The translate() function allows objects to be moved - * to any location within the window. The first parameter - * sets the x-axis offset and the second parameter sets the - * y-axis offset. - */ - -float x, y; -float size = 40.0; - -void setup() -{ - size(200,200); - noStroke(); - frameRate(30); -} - -void draw() -{ - background(102); - - x = x + 0.8; - - if (x > width + size) { - x = -size; - } - - translate(x, height/2-size/2); - fill(255); - rect(-size/2, -size/2, size, size); - - // Transforms accumulate. - // Notice how this rect moves twice - // as fast as the other, but it has - // the same parameter for the x-axis value - translate(x, size); - fill(0); - rect(-size/2, -size/2, size, size); -} diff --git a/android/examples/Basics/Transform/Translate/applet/loading.gif b/android/examples/Basics/Transform/Translate/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Transform/Translate/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.java b/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.java deleted file mode 100644 index b4bf9b0ad..000000000 --- a/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.java +++ /dev/null @@ -1,63 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class TriangleFlower extends PApplet { - -/** - * Triangle Flower - * by Ira Greenberg. - * - * Using rotate() and triangle() functions generate a pretty - * flower. Uncomment the line "// rotate(rot+=radians(spin));" - * in the triBlur() function for a nice variation. - */ - -Point[]p = new Point[3]; -float shift = 1.0f; -float fade = 0; -float fillCol = 0; -float rot = 0; -float spin = 0; - -public void setup(){ - size(200, 200); - background(0); - smooth(); - fade = 255.0f/(width/2.0f/shift); - spin = 360.0f/(width/2.0f/shift); - p[0] = new Point(-width/2, height/2); - p[1] = new Point(width/2, height/2); - p[2] = new Point(0, -height/2); - noStroke(); - translate(width/2, height/2); - triBlur(); -} - -public void triBlur(){ - fill(fillCol); - fillCol+=fade; - rotate(spin); - // another interesting variation: uncomment the line below - // rotate(rot+=radians(spin)); - triangle(p[0].x+=shift, p[0].y-=shift/2, p[1].x-=shift, p[1].y-=shift/2, p[2].x, p[2].y+=shift); - if(p[0].x<0){ - // recursive call - triBlur(); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "TriangleFlower" }); - } -} diff --git a/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.pde b/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.pde deleted file mode 100644 index e46988519..000000000 --- a/android/examples/Basics/Transform/TriangleFlower/applet/TriangleFlower.pde +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Triangle Flower - * by Ira Greenberg. - * - * Using rotate() and triangle() functions generate a pretty - * flower. Uncomment the line "// rotate(rot+=radians(spin));" - * in the triBlur() function for a nice variation. - */ - -Point[]p = new Point[3]; -float shift = 1.0; -float fade = 0; -float fillCol = 0; -float rot = 0; -float spin = 0; - -void setup(){ - size(200, 200); - background(0); - smooth(); - fade = 255.0/(width/2.0/shift); - spin = 360.0/(width/2.0/shift); - p[0] = new Point(-width/2, height/2); - p[1] = new Point(width/2, height/2); - p[2] = new Point(0, -height/2); - noStroke(); - translate(width/2, height/2); - triBlur(); -} - -void triBlur(){ - fill(fillCol); - fillCol+=fade; - rotate(spin); - // another interesting variation: uncomment the line below - // rotate(rot+=radians(spin)); - triangle(p[0].x+=shift, p[0].y-=shift/2, p[1].x-=shift, p[1].y-=shift/2, p[2].x, p[2].y+=shift); - if(p[0].x<0){ - // recursive call - triBlur(); - } -} - diff --git a/android/examples/Basics/Transform/TriangleFlower/applet/loading.gif b/android/examples/Basics/Transform/TriangleFlower/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Transform/TriangleFlower/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Typography/Letters/applet/Letters.java b/android/examples/Basics/Typography/Letters/applet/Letters.java deleted file mode 100644 index da77d549a..000000000 --- a/android/examples/Basics/Typography/Letters/applet/Letters.java +++ /dev/null @@ -1,86 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Letters extends PApplet { - -/** - * Letters. - * - * Draws letters to the screen. - */ - -PFont fontA; - -public void setup() -{ - size(200, 200); - background(0); - // Load the font. Fonts must be placed within the data - // directory of your sketch. A font must first be created - // using the 'Create Font...' option in the Tools menu. - fontA = loadFont("CourierNew36.vlw"); - textFont(fontA, 36); - textAlign(CENTER); - noLoop(); -} - -public void draw() -{ - // Set the gray value of the letters - fill(255); - - // Set the left and top margin - int margin = 6; - int gap = 30; - translate(margin*1.5f, margin*2); - - // Create a matrix of letterforms - int counter = 0; - for(int i=0; i= 26) { - counter = 0; - } - } - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Letters" }); - } -} diff --git a/android/examples/Basics/Typography/Letters/applet/Letters.pde b/android/examples/Basics/Typography/Letters/applet/Letters.pde deleted file mode 100644 index 82e943f2f..000000000 --- a/android/examples/Basics/Typography/Letters/applet/Letters.pde +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Letters. - * - * Draws letters to the screen. - */ - -PFont fontA; - -void setup() -{ - size(200, 200); - background(0); - // Load the font. Fonts must be placed within the data - // directory of your sketch. A font must first be created - // using the 'Create Font...' option in the Tools menu. - fontA = loadFont("CourierNew36.vlw"); - textFont(fontA, 36); - textAlign(CENTER); - noLoop(); -} - -void draw() -{ - // Set the gray value of the letters - fill(255); - - // Set the left and top margin - int margin = 6; - int gap = 30; - translate(margin*1.5, margin*2); - - // Create a matrix of letterforms - int counter = 0; - for(int i=0; i= 26) { - counter = 0; - } - } - } -} - diff --git a/android/examples/Basics/Typography/Letters/applet/loading.gif b/android/examples/Basics/Typography/Letters/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Typography/Letters/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Typography/Words/applet/Words.java b/android/examples/Basics/Typography/Words/applet/Words.java deleted file mode 100644 index 192678348..000000000 --- a/android/examples/Basics/Typography/Words/applet/Words.java +++ /dev/null @@ -1,62 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Words extends PApplet { - -/** - * Words. - * - * The text() function is used for writing words to the screen. - * - * Created 15 January 2003 - * Updated 11 August 2008 - */ - - -int x = 30; -PFont fontA; - -public void setup() -{ - size(200, 200); - background(102); - - // Load the font. Fonts must be placed within the data - // directory of your sketch. Use Tools > Create Font - // to create a distributable bitmap font. - // For vector fonts, use the createFont() function. - fontA = loadFont("Ziggurat-HTF-Black-32.vlw"); - - // Set the font and its size (in units of pixels) - textFont(fontA, 32); - - // Only draw once - noLoop(); -} - -public void draw() { - // Use fill() to change the value or color of the text - fill(0); - text("ichi", x, 60); - fill(51); - text("ni", x, 95); - fill(204); - text("san", x, 130); - fill(255); - text("shi", x, 165); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Words" }); - } -} diff --git a/android/examples/Basics/Typography/Words/applet/Words.pde b/android/examples/Basics/Typography/Words/applet/Words.pde deleted file mode 100644 index e7622a4c7..000000000 --- a/android/examples/Basics/Typography/Words/applet/Words.pde +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Words. - * - * The text() function is used for writing words to the screen. - * - * Created 15 January 2003 - * Updated 11 August 2008 - */ - - -int x = 30; -PFont fontA; - -void setup() -{ - size(200, 200); - background(102); - - // Load the font. Fonts must be placed within the data - // directory of your sketch. Use Tools > Create Font - // to create a distributable bitmap font. - // For vector fonts, use the createFont() function. - fontA = loadFont("Ziggurat-HTF-Black-32.vlw"); - - // Set the font and its size (in units of pixels) - textFont(fontA, 32); - - // Only draw once - noLoop(); -} - -void draw() { - // Use fill() to change the value or color of the text - fill(0); - text("ichi", x, 60); - fill(51); - text("ni", x, 95); - fill(204); - text("san", x, 130); - fill(255); - text("shi", x, 165); -} diff --git a/android/examples/Basics/Typography/Words/applet/loading.gif b/android/examples/Basics/Typography/Words/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Typography/Words/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.java b/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.java deleted file mode 100644 index 1ee4b1a64..000000000 --- a/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.java +++ /dev/null @@ -1,93 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class EmbeddedLinks extends PApplet { - -/** - * Loading URLs. - * - * Click on the left button to open a different URL in the same window (Only - * works online). Click on the right button to open a URL in a new browser window. -*/ - -boolean overLeftButton = false; -boolean overRightButton = false; - -public void setup() -{ - size(200, 200); -} - -public void draw() -{ - background(204); - - // Left buttom - if(overLeftButton == true) { - fill(255); - } else { - noFill(); - } - rect(20, 60, 75, 75); - rect(50, 90, 15, 15); - - // Right button - if(overRightButton == true) { - fill(255); - } else { - noFill(); - } - rect(105, 60, 75, 75); - line(135, 105, 155, 85); - line(140, 85, 155, 85); - line(155, 85, 155, 100); -} - -public void mousePressed() -{ - if(overLeftButton) { - link("http://www.processing.org"); - } else if (overRightButton) { - link("http://www.processing.org", "_new"); - } -} - -public void mouseMoved() { - checkButtons(); -} - -public void mouseDragged() { - checkButtons(); -} - -public void checkButtons() { - if(mouseX > 20 && mouseX < 95 && - mouseY > 60 && mouseY <135) { - overLeftButton = true; - } else if (mouseX > 105 && mouseX < 180 && - mouseY > 60 && mouseY <135) { - overRightButton = true; - } else { - overLeftButton = overRightButton = false; - } - -} - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "EmbeddedLinks" }); - } -} diff --git a/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.pde b/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.pde deleted file mode 100644 index ab41385c7..000000000 --- a/android/examples/Basics/Web/EmbeddedLinks/applet/EmbeddedLinks.pde +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Loading URLs. - * - * Click on the left button to open a different URL in the same window (Only - * works online). Click on the right button to open a URL in a new browser window. -*/ - -boolean overLeftButton = false; -boolean overRightButton = false; - -void setup() -{ - size(200, 200); -} - -void draw() -{ - background(204); - - // Left buttom - if(overLeftButton == true) { - fill(255); - } else { - noFill(); - } - rect(20, 60, 75, 75); - rect(50, 90, 15, 15); - - // Right button - if(overRightButton == true) { - fill(255); - } else { - noFill(); - } - rect(105, 60, 75, 75); - line(135, 105, 155, 85); - line(140, 85, 155, 85); - line(155, 85, 155, 100); -} - -void mousePressed() -{ - if(overLeftButton) { - link("http://www.processing.org"); - } else if (overRightButton) { - link("http://www.processing.org", "_new"); - } -} - -void mouseMoved() { - checkButtons(); -} - -void mouseDragged() { - checkButtons(); -} - -void checkButtons() { - if(mouseX > 20 && mouseX < 95 && - mouseY > 60 && mouseY <135) { - overLeftButton = true; - } else if (mouseX > 105 && mouseX < 180 && - mouseY > 60 && mouseY <135) { - overRightButton = true; - } else { - overLeftButton = overRightButton = false; - } - -} - - - - diff --git a/android/examples/Basics/Web/EmbeddedLinks/applet/loading.gif b/android/examples/Basics/Web/EmbeddedLinks/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Web/EmbeddedLinks/applet/loading.gif and /dev/null differ diff --git a/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.java b/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.java deleted file mode 100644 index 76bab8631..000000000 --- a/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.java +++ /dev/null @@ -1,37 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class LoadingImages extends PApplet { - public void setup() {/** - * Loading Images. - * - * Loading a recent image from the US National Weather Service. - * Notice the date in the upper left corner of the image. - * Processing applications can only load images from the network - * while running in the Processing environment. This example will - * not run in a web broswer and will only work when the computer - * is connected to the Internet. - */ - -size(200, 200); -PImage img1; -img1 = loadImage("http://www.processing.org/img/processing_beta_cover.gif"); -image(img1, 0, 45); - - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "LoadingImages" }); - } -} diff --git a/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.pde b/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.pde deleted file mode 100644 index 325fbba56..000000000 --- a/android/examples/Basics/Web/LoadingImages/applet/LoadingImages.pde +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Loading Images. - * - * Loading a recent image from the US National Weather Service. - * Notice the date in the upper left corner of the image. - * Processing applications can only load images from the network - * while running in the Processing environment. This example will - * not run in a web broswer and will only work when the computer - * is connected to the Internet. - */ - -size(200, 200); -PImage img1; -img1 = loadImage("http://www.processing.org/img/processing_beta_cover.gif"); -image(img1, 0, 45); - diff --git a/android/examples/Basics/Web/LoadingImages/applet/loading.gif b/android/examples/Basics/Web/LoadingImages/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Basics/Web/LoadingImages/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.java b/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.java deleted file mode 100644 index 52f4341d4..000000000 --- a/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.java +++ /dev/null @@ -1,122 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class ArrayListClass extends PApplet { - -/** - * ArrayList of objects - * by Daniel Shiffman. - * - * This example demonstrates how to use a Java ArrayList to store - * a variable number of objects. Items can be added and removed - * from the ArrayList. - * - * Click the mouse to add bouncing balls. - */ - -ArrayList balls; -int ballWidth = 48; - -public void setup() { - size(200, 200); - smooth(); - noStroke(); - - // Create an empty ArrayList - balls = new ArrayList(); - - // Start by adding one element - balls.add(new Ball(width/2, 0, ballWidth)); -} - -public void draw() { - background(255); - - // With an array, we say balls.length, with an ArrayList, we say balls.size() - // The length of an ArrayList is dynamic - // Notice how we are looping through the ArrayList backwards - // This is because we are deleting elements from the list - for (int i = balls.size()-1; i >= 0; i--) { - // An ArrayList doesn't know what it is storing so we have to cast the object coming out - Ball ball = (Ball) balls.get(i); - ball.move(); - ball.display(); - if (ball.finished()) { - // Items can be deleted with remove() - balls.remove(i); - } - - } - -} - -public void mousePressed() { - // A new ball object is added to the ArrayList (by default to the end) - balls.add(new Ball(mouseX, mouseY, ballWidth)); -} - -// Simple bouncing ball class - -class Ball { - - float x; - float y; - float speed; - float gravity; - float w; - float life = 255; - - Ball(float tempX, float tempY, float tempW) { - x = tempX; - y = tempY; - w = tempW; - speed = 0; - gravity = 0.1f; - } - - public void move() { - // Add gravity to speed - speed = speed + gravity; - // Add speed to y location - y = y + speed; - // If square reaches the bottom - // Reverse speed - if (y > height) { - // Dampening - speed = speed * -0.8f; - y = height; - } - } - - public boolean finished() { - // Balls fade out - life--; - if (life < 0) { - return true; - } else { - return false; - } - } - - public void display() { - // Display the circle - fill(0,life); - //stroke(0,life); - ellipse(x,y,w,w); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "ArrayListClass" }); - } -} diff --git a/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.pde b/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.pde deleted file mode 100644 index 09521cb17..000000000 --- a/android/examples/Topics/Advanced Data/ArrayListClass/applet/ArrayListClass.pde +++ /dev/null @@ -1,52 +0,0 @@ -/** - * ArrayList of objects - * by Daniel Shiffman. - * - * This example demonstrates how to use a Java ArrayList to store - * a variable number of objects. Items can be added and removed - * from the ArrayList. - * - * Click the mouse to add bouncing balls. - */ - -ArrayList balls; -int ballWidth = 48; - -void setup() { - size(200, 200); - smooth(); - noStroke(); - - // Create an empty ArrayList - balls = new ArrayList(); - - // Start by adding one element - balls.add(new Ball(width/2, 0, ballWidth)); -} - -void draw() { - background(255); - - // With an array, we say balls.length, with an ArrayList, we say balls.size() - // The length of an ArrayList is dynamic - // Notice how we are looping through the ArrayList backwards - // This is because we are deleting elements from the list - for (int i = balls.size()-1; i >= 0; i--) { - // An ArrayList doesn't know what it is storing so we have to cast the object coming out - Ball ball = (Ball) balls.get(i); - ball.move(); - ball.display(); - if (ball.finished()) { - // Items can be deleted with remove() - balls.remove(i); - } - - } - -} - -void mousePressed() { - // A new ball object is added to the ArrayList (by default to the end) - balls.add(new Ball(mouseX, mouseY, ballWidth)); -} - diff --git a/android/examples/Topics/Advanced Data/ArrayListClass/applet/Ball.pde b/android/examples/Topics/Advanced Data/ArrayListClass/applet/Ball.pde deleted file mode 100644 index 3f613b787..000000000 --- a/android/examples/Topics/Advanced Data/ArrayListClass/applet/Ball.pde +++ /dev/null @@ -1,50 +0,0 @@ -// Simple bouncing ball class - -class Ball { - - float x; - float y; - float speed; - float gravity; - float w; - float life = 255; - - Ball(float tempX, float tempY, float tempW) { - x = tempX; - y = tempY; - w = tempW; - speed = 0; - gravity = 0.1; - } - - void move() { - // Add gravity to speed - speed = speed + gravity; - // Add speed to y location - y = y + speed; - // If square reaches the bottom - // Reverse speed - if (y > height) { - // Dampening - speed = speed * -0.8; - y = height; - } - } - - boolean finished() { - // Balls fade out - life--; - if (life < 0) { - return true; - } else { - return false; - } - } - - void display() { - // Display the circle - fill(0,life); - //stroke(0,life); - ellipse(x,y,w,w); - } -} diff --git a/android/examples/Topics/Advanced Data/ArrayListClass/applet/loading.gif b/android/examples/Topics/Advanced Data/ArrayListClass/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Advanced Data/ArrayListClass/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.java b/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.java deleted file mode 100644 index 9b485958f..000000000 --- a/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.java +++ /dev/null @@ -1,126 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class HashMapClass extends PApplet { - -/** - * HashMap example - * by Daniel Shiffman. - * - * This example demonstrates how to use a HashMap to store - * a collection of objects referenced by a key. - * This is much like an array, only instead of accessing elements - * with a numeric index, we use a String. - * If you are familiar with associative arrays from other languages, - * this is the same idea. - * - * This example uses the HashMap to perform a simple concordance - * http://en.wikipedia.org/wiki/Concordance_(publishing) - */ - - -// HashMap object -HashMap words; - -// Array of all words from input file -String[] tokens; -int counter; - -PFont f; - -public void setup() { - size(640, 360); - words = new HashMap(); - - // Load file and chop it up - String[] lines = loadStrings("dracula.txt"); - String allText = join(lines," "); - tokens = splitTokens(allText," ,.?!:;[]-"); - f = createFont("Georgia",36,true); -} - -public void draw() { - background(255); - fill(0); - - // Look at words one at a time - String s = tokens[counter]; - counter = (counter + 1) % tokens.length; - - // Is the word in the HashMap - if (words.containsKey(s)) { - // Get the word object and increase the count - // We access objects from a HashMap via its key, the String - Word w = (Word) words.get(s); - w.count(); - } else { - // Otherwise make a new word - Word w = new Word(s); - // And add to the HashMap - // put() takes two arguments, "key" and "value" - // The key for us is the String and the value is the Word object - words.put(s,w); - } - - // Make an iterator to look at all the things in the HashMap - Iterator i = words.values().iterator(); - - // x and y will be used to locate each word - float x = 0; - float y = height-10; - - while (i.hasNext()) { - // Look at each word - Word w = (Word) i.next(); - - // Only display words that appear 3 times - if (w.count > 3) { - // The size is the count - int fsize = constrain(w.count,0,100); - textFont(f,fsize); - text(w.word,x,y); - // Move along the x-axis - x+=textWidth(w.word+" "); - } - - // If x gets to the end, move Y - if (x > width) { - x = 0; - y -= 100; - // If y gets to the end, we're done - if (y < 0) { - break; - } - } - } -} -class Word { - - int count; - String word; - - Word(String s) { - word = s; - count = 1; - } - - public void count() { - count++; - } - -} - - static public void main(String args[]) { - PApplet.main(new String[] { "HashMapClass" }); - } -} diff --git a/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.pde b/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.pde deleted file mode 100644 index 3f0489aa7..000000000 --- a/android/examples/Topics/Advanced Data/HashMapClass/applet/HashMapClass.pde +++ /dev/null @@ -1,91 +0,0 @@ -/** - * HashMap example - * by Daniel Shiffman. - * - * This example demonstrates how to use a HashMap to store - * a collection of objects referenced by a key. - * This is much like an array, only instead of accessing elements - * with a numeric index, we use a String. - * If you are familiar with associative arrays from other languages, - * this is the same idea. - * - * This example uses the HashMap to perform a simple concordance - * http://en.wikipedia.org/wiki/Concordance_(publishing) - */ - - -// HashMap object -HashMap words; - -// Array of all words from input file -String[] tokens; -int counter; - -PFont f; - -void setup() { - size(640, 360); - words = new HashMap(); - - // Load file and chop it up - String[] lines = loadStrings("dracula.txt"); - String allText = join(lines," "); - tokens = splitTokens(allText," ,.?!:;[]-"); - f = createFont("Georgia",36,true); -} - -void draw() { - background(255); - fill(0); - - // Look at words one at a time - String s = tokens[counter]; - counter = (counter + 1) % tokens.length; - - // Is the word in the HashMap - if (words.containsKey(s)) { - // Get the word object and increase the count - // We access objects from a HashMap via its key, the String - Word w = (Word) words.get(s); - w.count(); - } else { - // Otherwise make a new word - Word w = new Word(s); - // And add to the HashMap - // put() takes two arguments, "key" and "value" - // The key for us is the String and the value is the Word object - words.put(s,w); - } - - // Make an iterator to look at all the things in the HashMap - Iterator i = words.values().iterator(); - - // x and y will be used to locate each word - float x = 0; - float y = height-10; - - while (i.hasNext()) { - // Look at each word - Word w = (Word) i.next(); - - // Only display words that appear 3 times - if (w.count > 3) { - // The size is the count - int fsize = constrain(w.count,0,100); - textFont(f,fsize); - text(w.word,x,y); - // Move along the x-axis - x+=textWidth(w.word+" "); - } - - // If x gets to the end, move Y - if (x > width) { - x = 0; - y -= 100; - // If y gets to the end, we're done - if (y < 0) { - break; - } - } - } -} diff --git a/android/examples/Topics/Advanced Data/HashMapClass/applet/Word.pde b/android/examples/Topics/Advanced Data/HashMapClass/applet/Word.pde deleted file mode 100644 index cc8568491..000000000 --- a/android/examples/Topics/Advanced Data/HashMapClass/applet/Word.pde +++ /dev/null @@ -1,15 +0,0 @@ -class Word { - - int count; - String word; - - Word(String s) { - word = s; - count = 1; - } - - void count() { - count++; - } - -} diff --git a/android/examples/Topics/Advanced Data/HashMapClass/applet/loading.gif b/android/examples/Topics/Advanced Data/HashMapClass/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Advanced Data/HashMapClass/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.java b/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.java deleted file mode 100644 index c0c731c82..000000000 --- a/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.java +++ /dev/null @@ -1,86 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class AnimatedSprite extends PApplet { - -/** - * Animated Sprite (Shifty + Teddy) - * by James Patterson. - * - * Press the mouse button to change animations. - * Demonstrates loading, displaying, and animating GIF images. - * It would be easy to write a program to display - * animated GIFs, but would not allow as much control over - * the display sequence and rate of display. - */ - -Animation animation1, animation2; -float xpos, ypos; -float drag = 30.0f; - -public void setup() { - size(200, 200); - background(255, 204, 0); - frameRate(24); - animation1 = new Animation("PT_Shifty_", 38); - animation2 = new Animation("PT_Teddy_", 60); -} - -public void draw() { - float difx = mouseX - xpos; - if (abs(difx) > 1.0f) { - xpos = xpos + difx/drag; - xpos = constrain(xpos, 0, width); - } - - // Display the sprite at the position xpos, ypos - if (mousePressed) { - background(153, 153, 0); - animation1.display(xpos-animation1.getWidth()/2, ypos); - } else { - background(255, 204, 0); - animation2.display(xpos-animation1.getWidth()/2, ypos); - } -} -// Class for animating a sequence of GIFs - -class Animation { - PImage[] images; - int imageCount; - int frame; - - Animation(String imagePrefix, int count) { - imageCount = count; - images = new PImage[imageCount]; - - for (int i = 0; i < imageCount; i++) { - // Use nf() to number format 'i' into four digits - String filename = imagePrefix + nf(i, 4) + ".gif"; - images[i] = loadImage(filename); - } - } - - public void display(float xpos, float ypos) { - frame = (frame+1) % imageCount; - image(images[frame], xpos, ypos); - } - - public int getWidth() { - return images[0].width; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "AnimatedSprite" }); - } -} diff --git a/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.pde b/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.pde deleted file mode 100644 index 1c13f0199..000000000 --- a/android/examples/Topics/Animation/AnimatedSprite/applet/AnimatedSprite.pde +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Animated Sprite (Shifty + Teddy) - * by James Patterson. - * - * Press the mouse button to change animations. - * Demonstrates loading, displaying, and animating GIF images. - * It would be easy to write a program to display - * animated GIFs, but would not allow as much control over - * the display sequence and rate of display. - */ - -Animation animation1, animation2; -float xpos, ypos; -float drag = 30.0; - -void setup() { - size(200, 200); - background(255, 204, 0); - frameRate(24); - animation1 = new Animation("PT_Shifty_", 38); - animation2 = new Animation("PT_Teddy_", 60); -} - -void draw() { - float difx = mouseX - xpos; - if (abs(difx) > 1.0) { - xpos = xpos + difx/drag; - xpos = constrain(xpos, 0, width); - } - - // Display the sprite at the position xpos, ypos - if (mousePressed) { - background(153, 153, 0); - animation1.display(xpos-animation1.getWidth()/2, ypos); - } else { - background(255, 204, 0); - animation2.display(xpos-animation1.getWidth()/2, ypos); - } -} diff --git a/android/examples/Topics/Animation/AnimatedSprite/applet/Animation.pde b/android/examples/Topics/Animation/AnimatedSprite/applet/Animation.pde deleted file mode 100644 index 6c98ef20b..000000000 --- a/android/examples/Topics/Animation/AnimatedSprite/applet/Animation.pde +++ /dev/null @@ -1,27 +0,0 @@ -// Class for animating a sequence of GIFs - -class Animation { - PImage[] images; - int imageCount; - int frame; - - Animation(String imagePrefix, int count) { - imageCount = count; - images = new PImage[imageCount]; - - for (int i = 0; i < imageCount; i++) { - // Use nf() to number format 'i' into four digits - String filename = imagePrefix + nf(i, 4) + ".gif"; - images[i] = loadImage(filename); - } - } - - void display(float xpos, float ypos) { - frame = (frame+1) % imageCount; - image(images[frame], xpos, ypos); - } - - int getWidth() { - return images[0].width; - } -} diff --git a/android/examples/Topics/Animation/AnimatedSprite/applet/loading.gif b/android/examples/Topics/Animation/AnimatedSprite/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Animation/AnimatedSprite/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Animation/Sequential/applet/Sequential.java b/android/examples/Topics/Animation/Sequential/applet/Sequential.java deleted file mode 100644 index 6118f5f8b..000000000 --- a/android/examples/Topics/Animation/Sequential/applet/Sequential.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Sequential extends PApplet { - -/** - * Sequential - * by James Patterson. - * - * Displaying a sequence of images creates the illusion of motion. - * Twelve images are loaded and each is displayed individually in a loop. - */ - -int numFrames = 12; // The number of frames in the animation -int frame = 0; -PImage[] images = new PImage[numFrames]; - -public void setup() -{ - size(200, 200); - frameRate(30); - - images[0] = loadImage("PT_anim0000.gif"); - images[1] = loadImage("PT_anim0001.gif"); - images[2] = loadImage("PT_anim0002.gif"); - images[3] = loadImage("PT_anim0003.gif"); - images[4] = loadImage("PT_anim0004.gif"); - images[5] = loadImage("PT_anim0005.gif"); - images[6] = loadImage("PT_anim0006.gif"); - images[7] = loadImage("PT_anim0007.gif"); - images[8] = loadImage("PT_anim0008.gif"); - images[9] = loadImage("PT_anim0009.gif"); - images[10] = loadImage("PT_anim0010.gif"); - images[11] = loadImage("PT_anim0011.gif"); - - // If you don't want to load each image separately - // and you know how many frames you have, you - // can create the filenames as the program runs. - // The nf() command does number formatting, which will - // ensure that the number is (in this case) 4 digits. - //for(int i=0; i 3) && world[x][y][0] == 1) - { - world[x][y][1] = -1; - } - } - } -} - -// Count the number of adjacent cells 'on' -public int neighbors(int x, int y) -{ - return world[(x + 1) % sx][y][0] + - world[x][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][y][0] + - world[x][(y + sy - 1) % sy][0] + - world[(x + 1) % sx][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][(y + sy - 1) % sy][0] + - world[(x + 1) % sx][(y + sy - 1) % sy][0]; -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Conway" }); - } -} diff --git a/android/examples/Topics/Cellular Automata/Conway/applet/Conway.pde b/android/examples/Topics/Cellular Automata/Conway/applet/Conway.pde deleted file mode 100644 index d75bb342b..000000000 --- a/android/examples/Topics/Cellular Automata/Conway/applet/Conway.pde +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Conway's Game of Life - * by Mike Davis. - * - * This program is a simple version of Conway's - * game of Life. A lit point turns off if there - * are fewer than two or more than three surrounding - * lit points. An unlit point turns on if there - * are exactly three lit neighbors. The 'density' - * parameter determines how much of the board will - * start out lit. - */ - -int sx, sy; -float density = 0.5; -int[][][] world; - -void setup() -{ - size(640, 200, P3D); - frameRate(12); - sx = width; - sy = height; - world = new int[sx][sy][2]; - stroke(255); - - // Set random cells to 'on' - for (int i = 0; i < sx * sy * density; i++) { - world[(int)random(sx)][(int)random(sy)][1] = 1; - } -} - -void draw() -{ - background(0); - - // Drawing and update cycle - for (int x = 0; x < sx; x=x+1) { - for (int y = 0; y < sy; y=y+1) { - //if (world[x][y][1] == 1) - // Change recommended by The.Lucky.Mutt - if ((world[x][y][1] == 1) || (world[x][y][1] == 0 && world[x][y][0] == 1)) - { - world[x][y][0] = 1; - point(x, y); - } - if (world[x][y][1] == -1) - { - world[x][y][0] = 0; - } - world[x][y][1] = 0; - } - } - // Birth and death cycle - for (int x = 0; x < sx; x=x+1) { - for (int y = 0; y < sy; y=y+1) { - int count = neighbors(x, y); - if (count == 3 && world[x][y][0] == 0) - { - world[x][y][1] = 1; - } - if ((count < 2 || count > 3) && world[x][y][0] == 1) - { - world[x][y][1] = -1; - } - } - } -} - -// Count the number of adjacent cells 'on' -int neighbors(int x, int y) -{ - return world[(x + 1) % sx][y][0] + - world[x][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][y][0] + - world[x][(y + sy - 1) % sy][0] + - world[(x + 1) % sx][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][(y + 1) % sy][0] + - world[(x + sx - 1) % sx][(y + sy - 1) % sy][0] + - world[(x + 1) % sx][(y + sy - 1) % sy][0]; -} diff --git a/android/examples/Topics/Cellular Automata/Conway/applet/loading.gif b/android/examples/Topics/Cellular Automata/Conway/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Cellular Automata/Conway/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.java b/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.java deleted file mode 100644 index 840dad342..000000000 --- a/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.java +++ /dev/null @@ -1,153 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Spore1 extends PApplet { - -/** - * Spore 1 - * by Mike Davis. - * - * A short program for alife experiments. Click in the window to restart. - * Each cell is represented by a pixel on the display as well as an entry in - * the array 'cells'. Each cell has a run() method, which performs actions - * based on the cell's surroundings. Cells run one at a time (to avoid conflicts - * like wanting to move to the same space) and in random order. - */ - -World w; -int numcells = 0; -int maxcells = 6700; -Cell[] cells = new Cell[maxcells]; -int spore_color; -// set lower for smoother animation, higher for faster simulation -int runs_per_loop = 10000; -int black = color(0, 0, 0); - -public void setup() -{ - size(640, 200, P2D); - frameRate(24); - clearscr(); - w = new World(); - spore_color = color(172, 255, 128); - seed(); -} - -public void seed() -{ - // Add cells at random places - for (int i = 0; i < maxcells; i++) - { - int cX = (int)random(width); - int cY = (int)random(height); - if (w.getpix(cX, cY) == black) - { - w.setpix(cX, cY, spore_color); - cells[numcells] = new Cell(cX, cY); - numcells++; - } - } -} - -public void draw() -{ - // Run cells in random order - for (int i = 0; i < runs_per_loop; i++) { - int selected = min((int)random(numcells), numcells - 1); - cells[selected].run(); - } -} - -public void clearscr() -{ - background(0); -} - -class Cell -{ - int x, y; - Cell(int xin, int yin) - { - x = xin; - y = yin; - } - - // Perform action based on surroundings - public void run() - { - // Fix cell coordinates - while(x < 0) { - x+=width; - } - while(x > width - 1) { - x-=width; - } - while(y < 0) { - y+=height; - } - while(y > height - 1) { - y-=height; - } - - // Cell instructions - if (w.getpix(x + 1, y) == black) { - move(0, 1); - } else if (w.getpix(x, y - 1) != black && w.getpix(x, y + 1) != black) { - move((int)random(9) - 4, (int)random(9) - 4); - } - } - - // Will move the cell (dx, dy) units if that space is empty - public void move(int dx, int dy) { - if (w.getpix(x + dx, y + dy) == black) { - w.setpix(x + dx, y + dy, w.getpix(x, y)); - w.setpix(x, y, color(0)); - x += dx; - y += dy; - } - } -} - -// The World class simply provides two functions, get and set, which access the -// display in the same way as getPixel and setPixel. The only difference is that -// the World class's get and set do screen wraparound ("toroidal coordinates"). -class World -{ - public void setpix(int x, int y, int c) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - set(x, y, c); - } - - public int getpix(int x, int y) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - return get(x, y); - } -} - -public void mousePressed() -{ - numcells = 0; - setup(); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Spore1" }); - } -} diff --git a/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.pde b/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.pde deleted file mode 100644 index 46ec059b1..000000000 --- a/android/examples/Topics/Cellular Automata/Spore1/applet/Spore1.pde +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Spore 1 - * by Mike Davis. - * - * A short program for alife experiments. Click in the window to restart. - * Each cell is represented by a pixel on the display as well as an entry in - * the array 'cells'. Each cell has a run() method, which performs actions - * based on the cell's surroundings. Cells run one at a time (to avoid conflicts - * like wanting to move to the same space) and in random order. - */ - -World w; -int numcells = 0; -int maxcells = 6700; -Cell[] cells = new Cell[maxcells]; -color spore_color; -// set lower for smoother animation, higher for faster simulation -int runs_per_loop = 10000; -color black = color(0, 0, 0); - -void setup() -{ - size(640, 200, P2D); - frameRate(24); - clearscr(); - w = new World(); - spore_color = color(172, 255, 128); - seed(); -} - -void seed() -{ - // Add cells at random places - for (int i = 0; i < maxcells; i++) - { - int cX = (int)random(width); - int cY = (int)random(height); - if (w.getpix(cX, cY) == black) - { - w.setpix(cX, cY, spore_color); - cells[numcells] = new Cell(cX, cY); - numcells++; - } - } -} - -void draw() -{ - // Run cells in random order - for (int i = 0; i < runs_per_loop; i++) { - int selected = min((int)random(numcells), numcells - 1); - cells[selected].run(); - } -} - -void clearscr() -{ - background(0); -} - -class Cell -{ - int x, y; - Cell(int xin, int yin) - { - x = xin; - y = yin; - } - - // Perform action based on surroundings - void run() - { - // Fix cell coordinates - while(x < 0) { - x+=width; - } - while(x > width - 1) { - x-=width; - } - while(y < 0) { - y+=height; - } - while(y > height - 1) { - y-=height; - } - - // Cell instructions - if (w.getpix(x + 1, y) == black) { - move(0, 1); - } else if (w.getpix(x, y - 1) != black && w.getpix(x, y + 1) != black) { - move((int)random(9) - 4, (int)random(9) - 4); - } - } - - // Will move the cell (dx, dy) units if that space is empty - void move(int dx, int dy) { - if (w.getpix(x + dx, y + dy) == black) { - w.setpix(x + dx, y + dy, w.getpix(x, y)); - w.setpix(x, y, color(0)); - x += dx; - y += dy; - } - } -} - -// The World class simply provides two functions, get and set, which access the -// display in the same way as getPixel and setPixel. The only difference is that -// the World class's get and set do screen wraparound ("toroidal coordinates"). -class World -{ - void setpix(int x, int y, int c) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - set(x, y, c); - } - - color getpix(int x, int y) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - return get(x, y); - } -} - -void mousePressed() -{ - numcells = 0; - setup(); -} - diff --git a/android/examples/Topics/Cellular Automata/Spore1/applet/loading.gif b/android/examples/Topics/Cellular Automata/Spore1/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Cellular Automata/Spore1/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.java b/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.java deleted file mode 100644 index b90c5c513..000000000 --- a/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.java +++ /dev/null @@ -1,196 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Spore2 extends PApplet { - -/** - * Spore 2 - * by Mike Davis. - * - * A short program for alife experiments. Click in the window to restart. - * Each cell is represented by a pixel on the display as well as an entry in - * the array 'cells'. Each cell has a run() method, which performs actions - * based on the cell's surroundings. Cells run one at a time (to avoid conflicts - * like wanting to move to the same space) and in random order. - */ - -World w; -int maxcells = 8000; -int numcells; -Cell[] cells = new Cell[maxcells]; -int spore1, spore2, spore3, spore4; -int black = color(0, 0, 0); -// set lower for smoother animation, higher for faster simulation -int runs_per_loop = 10000; - -public void setup() -{ - size(640, 200, P2D); - frameRate(24); - clearscr(); - w = new World(); - spore1 = color(128, 172, 255); - spore2 = color(64, 128, 255); - spore3 = color(255, 128, 172); - spore4 = color(255, 64, 128); - numcells = 0; - seed(); -} - -public void seed() -{ - // Add cells at random places - for (int i = 0; i < maxcells; i++) - { - int cX = PApplet.parseInt(random(width)); - int cY = PApplet.parseInt(random(height)); - int c; - float r = random(1); - if (r < 0.25f) c = spore1; - else if (r < 0.5f) c = spore2; - else if (r < 0.75f) c = spore3; - else c = spore4; - if (w.getpix(cX, cY) == black) - { - w.setpix(cX, cY, c); - cells[numcells] = new Cell(cX, cY); - numcells++; - } - } -} - -public void draw() -{ - // Run cells in random order - for (int i = 0; i < runs_per_loop; i++) { - int selected = min((int)random(numcells), numcells - 1); - cells[selected].run(); - } - - println(frameRate); -} - -public void clearscr() -{ - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - set(x, y, color(0)); - } - } -} - -class Cell -{ - int x, y; - Cell(int xin, int yin) - { - x = xin; - y = yin; - } - // Perform action based on surroundings - public void run() - { - // Fix cell coordinates - while(x < 0) { - x+=width; - } - while(x > width - 1) { - x-=width; - } - while(y < 0) { - y+=height; - } - while(y > height - 1) { - y-=height; - } - - // Cell instructions - int myColor = w.getpix(x, y); - if (myColor == spore1) { - if (w.getpix(x - 1, y + 1) == black && w.getpix(x + 1, y + 1) == black && w.getpix(x, y + 1) == black) move(0, 1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) != black) move(0, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) == black) move(-1, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) != black) move(0, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) == black) move(1, -1); - else move((int)random(3) - 1, 0); - } else if (myColor == spore2) { - if (w.getpix(x - 1, y + 1) == black && w.getpix(x + 1, y + 1) == black && w.getpix(x, y + 1) == black) move(0, 1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) != black) move(0, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) == black) move(1, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) != black) move(0, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) == black) move(-1, -1); - else move((int)random(3) - 1, 0); - } - else if (myColor == spore3) - { - if (w.getpix(x - 1, y - 1) == black && w.getpix(x + 1, y - 1) == black && w.getpix(x, y - 1) == black) move(0, -1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) != black) move(0, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) == black) move(-1, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) != black) move(0, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) == black) move(1, 1); - else move((int)random(3) - 1, 0); - } - else if (myColor == spore4) - { - if (w.getpix(x - 1, y - 1) == black && w.getpix(x + 1, y - 1) == black && w.getpix(x, y - 1) == black) move(0, -1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) != black) move(0, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) == black) move(1, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) != black) move(0, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) == black) move(-1, 1); - else move((int)random(3) - 1, 0); - } - } - - // Will move the cell (dx, dy) units if that space is empty - public void move(int dx, int dy) { - if (w.getpix(x + dx, y + dy) == black) { - w.setpix(x + dx, y + dy, w.getpix(x, y)); - w.setpix(x, y, color(0)); - x += dx; - y += dy; - } - } -} - -// The World class simply provides two functions, get and set, which access the -// display in the same way as getPixel and setPixel. The only difference is that -// the World class's get and set do screen wraparound ("toroidal coordinates"). -class World -{ - public void setpix(int x, int y, int c) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - set(x, y, c); - } - - public int getpix(int x, int y) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - return get(x, y); - } -} - -public void mousePressed() -{ - setup(); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Spore2" }); - } -} diff --git a/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.pde b/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.pde deleted file mode 100644 index fdca1b043..000000000 --- a/android/examples/Topics/Cellular Automata/Spore2/applet/Spore2.pde +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Spore 2 - * by Mike Davis. - * - * A short program for alife experiments. Click in the window to restart. - * Each cell is represented by a pixel on the display as well as an entry in - * the array 'cells'. Each cell has a run() method, which performs actions - * based on the cell's surroundings. Cells run one at a time (to avoid conflicts - * like wanting to move to the same space) and in random order. - */ - -World w; -int maxcells = 8000; -int numcells; -Cell[] cells = new Cell[maxcells]; -color spore1, spore2, spore3, spore4; -color black = color(0, 0, 0); -// set lower for smoother animation, higher for faster simulation -int runs_per_loop = 10000; - -void setup() -{ - size(640, 200, P2D); - frameRate(24); - clearscr(); - w = new World(); - spore1 = color(128, 172, 255); - spore2 = color(64, 128, 255); - spore3 = color(255, 128, 172); - spore4 = color(255, 64, 128); - numcells = 0; - seed(); -} - -void seed() -{ - // Add cells at random places - for (int i = 0; i < maxcells; i++) - { - int cX = int(random(width)); - int cY = int(random(height)); - int c; - float r = random(1); - if (r < 0.25) c = spore1; - else if (r < 0.5) c = spore2; - else if (r < 0.75) c = spore3; - else c = spore4; - if (w.getpix(cX, cY) == black) - { - w.setpix(cX, cY, c); - cells[numcells] = new Cell(cX, cY); - numcells++; - } - } -} - -void draw() -{ - // Run cells in random order - for (int i = 0; i < runs_per_loop; i++) { - int selected = min((int)random(numcells), numcells - 1); - cells[selected].run(); - } - - println(frameRate); -} - -void clearscr() -{ - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - set(x, y, color(0)); - } - } -} - -class Cell -{ - int x, y; - Cell(int xin, int yin) - { - x = xin; - y = yin; - } - // Perform action based on surroundings - void run() - { - // Fix cell coordinates - while(x < 0) { - x+=width; - } - while(x > width - 1) { - x-=width; - } - while(y < 0) { - y+=height; - } - while(y > height - 1) { - y-=height; - } - - // Cell instructions - int myColor = w.getpix(x, y); - if (myColor == spore1) { - if (w.getpix(x - 1, y + 1) == black && w.getpix(x + 1, y + 1) == black && w.getpix(x, y + 1) == black) move(0, 1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) != black) move(0, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) == black) move(-1, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) != black) move(0, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) == black) move(1, -1); - else move((int)random(3) - 1, 0); - } else if (myColor == spore2) { - if (w.getpix(x - 1, y + 1) == black && w.getpix(x + 1, y + 1) == black && w.getpix(x, y + 1) == black) move(0, 1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) != black) move(0, -1); - else if (w.getpix(x + 1, y) == spore1 && w.getpix(x + 1, y - 1) == black) move(1, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) != black) move(0, -1); - else if (w.getpix(x - 1, y) == spore2 && w.getpix(x - 1, y - 1) == black) move(-1, -1); - else move((int)random(3) - 1, 0); - } - else if (myColor == spore3) - { - if (w.getpix(x - 1, y - 1) == black && w.getpix(x + 1, y - 1) == black && w.getpix(x, y - 1) == black) move(0, -1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) != black) move(0, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) == black) move(-1, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) != black) move(0, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) == black) move(1, 1); - else move((int)random(3) - 1, 0); - } - else if (myColor == spore4) - { - if (w.getpix(x - 1, y - 1) == black && w.getpix(x + 1, y - 1) == black && w.getpix(x, y - 1) == black) move(0, -1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) != black) move(0, 1); - else if (w.getpix(x + 1, y) == spore3 && w.getpix(x + 1, y + 1) == black) move(1, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) != black) move(0, 1); - else if (w.getpix(x - 1, y) == spore4 && w.getpix(x - 1, y + 1) == black) move(-1, 1); - else move((int)random(3) - 1, 0); - } - } - - // Will move the cell (dx, dy) units if that space is empty - void move(int dx, int dy) { - if (w.getpix(x + dx, y + dy) == black) { - w.setpix(x + dx, y + dy, w.getpix(x, y)); - w.setpix(x, y, color(0)); - x += dx; - y += dy; - } - } -} - -// The World class simply provides two functions, get and set, which access the -// display in the same way as getPixel and setPixel. The only difference is that -// the World class's get and set do screen wraparound ("toroidal coordinates"). -class World -{ - void setpix(int x, int y, int c) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - set(x, y, c); - } - - color getpix(int x, int y) { - while(x < 0) x+=width; - while(x > width - 1) x-=width; - while(y < 0) y+=height; - while(y > height - 1) y-=height; - return get(x, y); - } -} - -void mousePressed() -{ - setup(); -} - diff --git a/android/examples/Topics/Cellular Automata/Spore2/applet/loading.gif b/android/examples/Topics/Cellular Automata/Spore2/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Cellular Automata/Spore2/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Cellular Automata/Wolfram/applet/CA.pde b/android/examples/Topics/Cellular Automata/Wolfram/applet/CA.pde deleted file mode 100644 index 30d02a378..000000000 --- a/android/examples/Topics/Cellular Automata/Wolfram/applet/CA.pde +++ /dev/null @@ -1,94 +0,0 @@ -class CA { - - int[] cells; // An array of 0s and 1s - int generation; // How many generations? - int scl; // How many pixels wide/high is each cell? - - int[] rules; // An array to store the ruleset, for example {0,1,1,0,1,1,0,1} - - CA(int[] r) { - rules = r; - scl = 1; - cells = new int[width/scl]; - restart(); - } - - CA() { - scl = 1; - cells = new int[width/scl]; - randomize(); - restart(); - } - - // Set the rules of the CA - void setRules(int[] r) { - rules = r; - } - - // Make a random ruleset - void randomize() { - for (int i = 0; i < 8; i++) { - rules[i] = int(random(2)); - } - } - - // Reset to generation 0 - void restart() { - for (int i = 0; i < cells.length; i++) { - cells[i] = 0; - } - cells[cells.length/2] = 1; // We arbitrarily start with just the middle cell having a state of "1" - generation = 0; - } - - // The process of creating the new generation - void generate() { - // First we create an empty array for the new values - int[] nextgen = new int[cells.length]; - // For every spot, determine new state by examing current state, and neighbor states - // Ignore edges that only have one neighor - for (int i = 1; i < cells.length-1; i++) { - int left = cells[i-1]; // Left neighbor state - int me = cells[i]; // Current state - int right = cells[i+1]; // Right neighbor state - nextgen[i] = rules(left,me,right); // Compute next generation state based on ruleset - } - // Copy the array into current value - cells = (int[]) nextgen.clone(); - generation++; - } - - // This is the easy part, just draw the cells, fill 255 for '1', fill 0 for '0' - void render() { - for (int i = 0; i < cells.length; i++) { - if (cells[i] == 1) fill(255); - else fill(0); - noStroke(); - rect(i*scl,generation*scl, scl,scl); - } - } - - // Implementing the Wolfram rules - // Could be improved and made more concise, but here we can explicitly see what is going on for each case - int rules (int a, int b, int c) { - if (a == 1 && b == 1 && c == 1) return rules[0]; - if (a == 1 && b == 1 && c == 0) return rules[1]; - if (a == 1 && b == 0 && c == 1) return rules[2]; - if (a == 1 && b == 0 && c == 0) return rules[3]; - if (a == 0 && b == 1 && c == 1) return rules[4]; - if (a == 0 && b == 1 && c == 0) return rules[5]; - if (a == 0 && b == 0 && c == 1) return rules[6]; - if (a == 0 && b == 0 && c == 0) return rules[7]; - return 0; - } - - // The CA is done if it reaches the bottom of the screen - boolean finished() { - if (generation > height/scl) { - return true; - } else { - return false; - } - } -} - diff --git a/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.java b/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.java deleted file mode 100644 index 4674c38af..000000000 --- a/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.java +++ /dev/null @@ -1,152 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Wolfram extends PApplet { - -/** - * Wolfram Cellular Automata - * by Daniel Shiffman. - * - * Simple demonstration of a Wolfram 1-dimensional cellular automata - * When the system reaches bottom of the window, it restarts with a new ruleset - * Mouse click restarts as well. - */ - -CA ca; // An instance object to describe the Wolfram basic Cellular Automata - -public void setup() { - size(640, 360, P2D); - frameRate(30); - background(0); - int[] ruleset = {0,1,0,1,1,0,1,0}; // An initial rule system - ca = new CA(ruleset); // Initialize CA -} - -public void draw() { - ca.render(); // Draw the CA - ca.generate(); // Generate the next level - - if (ca.finished()) { // If we're done, clear the screen, pick a new ruleset and restart - background(0); - ca.randomize(); - ca.restart(); - } -} - -public void mousePressed() { - background(0); - ca.randomize(); - ca.restart(); -} - - - -class CA { - - int[] cells; // An array of 0s and 1s - int generation; // How many generations? - int scl; // How many pixels wide/high is each cell? - - int[] rules; // An array to store the ruleset, for example {0,1,1,0,1,1,0,1} - - CA(int[] r) { - rules = r; - scl = 1; - cells = new int[width/scl]; - restart(); - } - - CA() { - scl = 1; - cells = new int[width/scl]; - randomize(); - restart(); - } - - // Set the rules of the CA - public void setRules(int[] r) { - rules = r; - } - - // Make a random ruleset - public void randomize() { - for (int i = 0; i < 8; i++) { - rules[i] = PApplet.parseInt(random(2)); - } - } - - // Reset to generation 0 - public void restart() { - for (int i = 0; i < cells.length; i++) { - cells[i] = 0; - } - cells[cells.length/2] = 1; // We arbitrarily start with just the middle cell having a state of "1" - generation = 0; - } - - // The process of creating the new generation - public void generate() { - // First we create an empty array for the new values - int[] nextgen = new int[cells.length]; - // For every spot, determine new state by examing current state, and neighbor states - // Ignore edges that only have one neighor - for (int i = 1; i < cells.length-1; i++) { - int left = cells[i-1]; // Left neighbor state - int me = cells[i]; // Current state - int right = cells[i+1]; // Right neighbor state - nextgen[i] = rules(left,me,right); // Compute next generation state based on ruleset - } - // Copy the array into current value - cells = (int[]) nextgen.clone(); - generation++; - } - - // This is the easy part, just draw the cells, fill 255 for '1', fill 0 for '0' - public void render() { - for (int i = 0; i < cells.length; i++) { - if (cells[i] == 1) fill(255); - else fill(0); - noStroke(); - rect(i*scl,generation*scl, scl,scl); - } - } - - // Implementing the Wolfram rules - // Could be improved and made more concise, but here we can explicitly see what is going on for each case - public int rules (int a, int b, int c) { - if (a == 1 && b == 1 && c == 1) return rules[0]; - if (a == 1 && b == 1 && c == 0) return rules[1]; - if (a == 1 && b == 0 && c == 1) return rules[2]; - if (a == 1 && b == 0 && c == 0) return rules[3]; - if (a == 0 && b == 1 && c == 1) return rules[4]; - if (a == 0 && b == 1 && c == 0) return rules[5]; - if (a == 0 && b == 0 && c == 1) return rules[6]; - if (a == 0 && b == 0 && c == 0) return rules[7]; - return 0; - } - - // The CA is done if it reaches the bottom of the screen - public boolean finished() { - if (generation > height/scl) { - return true; - } else { - return false; - } - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Wolfram" }); - } -} diff --git a/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.pde b/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.pde deleted file mode 100644 index 328e6b9b9..000000000 --- a/android/examples/Topics/Cellular Automata/Wolfram/applet/Wolfram.pde +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Wolfram Cellular Automata - * by Daniel Shiffman. - * - * Simple demonstration of a Wolfram 1-dimensional cellular automata - * When the system reaches bottom of the window, it restarts with a new ruleset - * Mouse click restarts as well. - */ - -CA ca; // An instance object to describe the Wolfram basic Cellular Automata - -void setup() { - size(640, 360, P2D); - frameRate(30); - background(0); - int[] ruleset = {0,1,0,1,1,0,1,0}; // An initial rule system - ca = new CA(ruleset); // Initialize CA -} - -void draw() { - ca.render(); // Draw the CA - ca.generate(); // Generate the next level - - if (ca.finished()) { // If we're done, clear the screen, pick a new ruleset and restart - background(0); - ca.randomize(); - ca.restart(); - } -} - -void mousePressed() { - background(0); - ca.randomize(); - ca.restart(); -} - - - diff --git a/android/examples/Topics/Cellular Automata/Wolfram/applet/loading.gif b/android/examples/Topics/Cellular Automata/Wolfram/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Cellular Automata/Wolfram/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/Animator/applet/Animator.java b/android/examples/Topics/Drawing/Animator/applet/Animator.java deleted file mode 100644 index 6fe4e0183..000000000 --- a/android/examples/Topics/Drawing/Animator/applet/Animator.java +++ /dev/null @@ -1,69 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Animator extends PApplet { - -/** - * Animator. - * - * Click and drag to draw and start the program. - * - * A simple animation tool that displays a continuous cycle of - * twenty-four images. Each image is displayed for 30 milliseconds - * to create animation. While each image is displayed, it\u2019s possible - * to draw directly into it by pressing the mouse and moving the cursor. - * - */ - -int currentFrame = 0; -PImage[] frames = new PImage[24]; -int lastTime = 0; - -public void setup() -{ - size(640, 200); - strokeWeight(12); - smooth(); - background(204); - for (int i = 0; i < frames.length; i++) { - frames[i] = get(); // Create a blank frame - } -} - -public void draw() -{ - int currentTime = millis(); - if (currentTime > lastTime+30) { - nextFrame(); - lastTime = currentTime; - } - if (mousePressed == true) { - line(pmouseX, pmouseY, mouseX, mouseY); - } -} - -public void nextFrame() -{ - frames[currentFrame] = get(); // Get the display window - currentFrame++; // Increment to next frame - if (currentFrame >= frames.length) { - currentFrame = 0; - } - image(frames[currentFrame], 0, 0); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Animator" }); - } -} diff --git a/android/examples/Topics/Drawing/Animator/applet/Animator.pde b/android/examples/Topics/Drawing/Animator/applet/Animator.pde deleted file mode 100644 index 883602eea..000000000 --- a/android/examples/Topics/Drawing/Animator/applet/Animator.pde +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Animator. - * - * Click and drag to draw and start the program. - * - * A simple animation tool that displays a continuous cycle of - * twenty-four images. Each image is displayed for 30 milliseconds - * to create animation. While each image is displayed, it’s possible - * to draw directly into it by pressing the mouse and moving the cursor. - * - */ - -int currentFrame = 0; -PImage[] frames = new PImage[24]; -int lastTime = 0; - -void setup() -{ - size(640, 200); - strokeWeight(12); - smooth(); - background(204); - for (int i = 0; i < frames.length; i++) { - frames[i] = get(); // Create a blank frame - } -} - -void draw() -{ - int currentTime = millis(); - if (currentTime > lastTime+30) { - nextFrame(); - lastTime = currentTime; - } - if (mousePressed == true) { - line(pmouseX, pmouseY, mouseX, mouseY); - } -} - -void nextFrame() -{ - frames[currentFrame] = get(); // Get the display window - currentFrame++; // Increment to next frame - if (currentFrame >= frames.length) { - currentFrame = 0; - } - image(frames[currentFrame], 0, 0); -} - diff --git a/android/examples/Topics/Drawing/Animator/applet/loading.gif b/android/examples/Topics/Drawing/Animator/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/Animator/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.java b/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.java deleted file mode 100644 index 1d2178c95..000000000 --- a/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.java +++ /dev/null @@ -1,37 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class ContinuousLines extends PApplet { - -/** - * Continuous Lines. - * - * Click and drag the mouse to draw a line. - */ - -public void setup() { - size(640, 200); - background(102); -} - -public void draw() { - stroke(255); - if(mousePressed) { - line(mouseX, mouseY, pmouseX, pmouseY); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "ContinuousLines" }); - } -} diff --git a/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.pde b/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.pde deleted file mode 100644 index 9687331ba..000000000 --- a/android/examples/Topics/Drawing/ContinuousLines/applet/ContinuousLines.pde +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Continuous Lines. - * - * Click and drag the mouse to draw a line. - */ - -void setup() { - size(640, 200); - background(102); -} - -void draw() { - stroke(255); - if(mousePressed) { - line(mouseX, mouseY, pmouseX, pmouseY); - } -} diff --git a/android/examples/Topics/Drawing/ContinuousLines/applet/loading.gif b/android/examples/Topics/Drawing/ContinuousLines/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/ContinuousLines/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.java b/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.java deleted file mode 100644 index b444c5e95..000000000 --- a/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.java +++ /dev/null @@ -1,104 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class CustomTool extends PApplet { - -/** - * Custom Tool. - * - * Move the cursor across the screen to draw. - * In addition to creating software tools to simulate pens and pencils, - * it is possible to create unique tools to draw with. - */ - -int dots = 1000; -float[] dX = new float[dots]; -float[] dY = new float[dots]; - -float l_0 = 0.0f; -float h_0 = 0.0f; - -float legX = 0.0f; -float legY = 0.0f; -float thighX = 0.0f; -float thighY = 0.0f; - -float l = 60.0f; // Length of the 'leg' -float h = 90.0f; // Height of the 'leg' - -float nmx, nmy = 0.0f; -float mx, my = 0.0f; - -int currentValue = 0; -int valdir = 1; - -public void setup() -{ - size(640, 360); - noStroke(); - smooth(); - background(102); -} - -public void draw() -{ - // Smooth the mouse - nmx = mouseX; - nmy = mouseY; - if((abs(mx - nmx) > 1.0f) || (abs(my - nmy) > 1.0f)) { - mx = mx - (mx-nmx)/20.0f; - my = my - (my-nmy)/20.0f; - - // Set the drawing value - currentValue += 1* valdir; - if(currentValue > 255 || currentValue <= 0) { - valdir *= -1; - } - } - - iKinematics(); - kinematics(); - - pushMatrix(); - translate(width/2, height/2); - stroke(currentValue); - line(thighX, thighY, legX, legY); - popMatrix(); - - stroke(255); - point(legX + width/2, legY + height/2); -} - -public void kinematics() -{ - thighX = h*cos(h_0); - thighY = h*sin(h_0); - legX = thighX + l*cos(h_0 - l_0); - legY = thighY + l*sin(h_0 - l_0); -} - -public void iKinematics() -{ - float tx = mx - width/2.0f; - float ty = my - height/2.0f; - float c2 = (tx*tx + ty*ty - h*h - l*l)/(2*h*l); //in degrees - float s2 = sqrt(abs(1 - c2*c2)); // the sign here determines the bend in the joint - l_0 = -atan2(s2, c2); - h_0 = atan2(ty, tx) - atan2(l*s2, h+l*c2); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "CustomTool" }); - } -} diff --git a/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.pde b/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.pde deleted file mode 100644 index 96c3ec67c..000000000 --- a/android/examples/Topics/Drawing/CustomTool/applet/CustomTool.pde +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Custom Tool. - * - * Move the cursor across the screen to draw. - * In addition to creating software tools to simulate pens and pencils, - * it is possible to create unique tools to draw with. - */ - -int dots = 1000; -float[] dX = new float[dots]; -float[] dY = new float[dots]; - -float l_0 = 0.0; -float h_0 = 0.0; - -float legX = 0.0; -float legY = 0.0; -float thighX = 0.0; -float thighY = 0.0; - -float l = 60.0; // Length of the 'leg' -float h = 90.0; // Height of the 'leg' - -float nmx, nmy = 0.0; -float mx, my = 0.0; - -int currentValue = 0; -int valdir = 1; - -void setup() -{ - size(640, 360); - noStroke(); - smooth(); - background(102); -} - -void draw() -{ - // Smooth the mouse - nmx = mouseX; - nmy = mouseY; - if((abs(mx - nmx) > 1.0) || (abs(my - nmy) > 1.0)) { - mx = mx - (mx-nmx)/20.0; - my = my - (my-nmy)/20.0; - - // Set the drawing value - currentValue += 1* valdir; - if(currentValue > 255 || currentValue <= 0) { - valdir *= -1; - } - } - - iKinematics(); - kinematics(); - - pushMatrix(); - translate(width/2, height/2); - stroke(currentValue); - line(thighX, thighY, legX, legY); - popMatrix(); - - stroke(255); - point(legX + width/2, legY + height/2); -} - -void kinematics() -{ - thighX = h*cos(h_0); - thighY = h*sin(h_0); - legX = thighX + l*cos(h_0 - l_0); - legY = thighY + l*sin(h_0 - l_0); -} - -void iKinematics() -{ - float tx = mx - width/2.0; - float ty = my - height/2.0; - float c2 = (tx*tx + ty*ty - h*h - l*l)/(2*h*l); //in degrees - float s2 = sqrt(abs(1 - c2*c2)); // the sign here determines the bend in the joint - l_0 = -atan2(s2, c2); - h_0 = atan2(ty, tx) - atan2(l*s2, h+l*c2); -} - diff --git a/android/examples/Topics/Drawing/CustomTool/applet/loading.gif b/android/examples/Topics/Drawing/CustomTool/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/CustomTool/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/Pattern/applet/Pattern.java b/android/examples/Topics/Drawing/Pattern/applet/Pattern.java deleted file mode 100644 index eb395338c..000000000 --- a/android/examples/Topics/Drawing/Pattern/applet/Pattern.java +++ /dev/null @@ -1,54 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Pattern extends PApplet { - -/** - * Patterns. - * - * Move the cursor over the image to draw with a software tool - * which responds to the speed of the mouse. - */ - -public void setup() -{ - size(640, 360); - background(102); - smooth(); -} - -public void draw() -{ - // Call the variableEllipse() method and send it the - // parameters for the current mouse position - // and the previous mouse position - variableEllipse(mouseX, mouseY, pmouseX, pmouseY); -} - - -// The simple method variableEllipse() was created specifically -// for this program. It calculates the speed of the mouse -// and draws a small ellipse if the mouse is moving slowly -// and draws a large ellipse if the mouse is moving quickly - -public void variableEllipse(int x, int y, int px, int py) -{ - float speed = abs(x-px) + abs(y-py); - stroke(speed); - ellipse(x, y, speed, speed); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Pattern" }); - } -} diff --git a/android/examples/Topics/Drawing/Pattern/applet/Pattern.pde b/android/examples/Topics/Drawing/Pattern/applet/Pattern.pde deleted file mode 100644 index 882b19d74..000000000 --- a/android/examples/Topics/Drawing/Pattern/applet/Pattern.pde +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Patterns. - * - * Move the cursor over the image to draw with a software tool - * which responds to the speed of the mouse. - */ - -void setup() -{ - size(640, 360); - background(102); - smooth(); -} - -void draw() -{ - // Call the variableEllipse() method and send it the - // parameters for the current mouse position - // and the previous mouse position - variableEllipse(mouseX, mouseY, pmouseX, pmouseY); -} - - -// The simple method variableEllipse() was created specifically -// for this program. It calculates the speed of the mouse -// and draws a small ellipse if the mouse is moving slowly -// and draws a large ellipse if the mouse is moving quickly - -void variableEllipse(int x, int y, int px, int py) -{ - float speed = abs(x-px) + abs(y-py); - stroke(speed); - ellipse(x, y, speed, speed); -} diff --git a/android/examples/Topics/Drawing/Pattern/applet/loading.gif b/android/examples/Topics/Drawing/Pattern/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/Pattern/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/Pulses/applet/Pulses.java b/android/examples/Topics/Drawing/Pulses/applet/Pulses.java deleted file mode 100644 index 4646c9a5d..000000000 --- a/android/examples/Topics/Drawing/Pulses/applet/Pulses.java +++ /dev/null @@ -1,53 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Pulses extends PApplet { - -/** - * Pulses. - * - * Software drawing instruments can follow a rhythm or abide by rules independent - * of drawn gestures. This is a form of collaborative drawing in which the draftsperson - * controls some aspects of the image and the software controls others. - */ - -int angle = 0; - -public void setup() { - size(640, 360); - background(102); - smooth(); - noStroke(); - fill(0, 102); -} - -public void draw() { - // Draw only when mouse is pressed - if (mousePressed == true) { - angle += 10; - float val = cos(radians(angle)) * 6.0f; - for (int a = 0; a < 360; a += 75) { - float xoff = cos(radians(a)) * val; - float yoff = sin(radians(a)) * val; - fill(0); - ellipse(mouseX + xoff, mouseY + yoff, val, val); - } - fill(255); - ellipse(mouseX, mouseY, 2, 2); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Pulses" }); - } -} diff --git a/android/examples/Topics/Drawing/Pulses/applet/Pulses.pde b/android/examples/Topics/Drawing/Pulses/applet/Pulses.pde deleted file mode 100644 index c8b07ec52..000000000 --- a/android/examples/Topics/Drawing/Pulses/applet/Pulses.pde +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Pulses. - * - * Software drawing instruments can follow a rhythm or abide by rules independent - * of drawn gestures. This is a form of collaborative drawing in which the draftsperson - * controls some aspects of the image and the software controls others. - */ - -int angle = 0; - -void setup() { - size(640, 360); - background(102); - smooth(); - noStroke(); - fill(0, 102); -} - -void draw() { - // Draw only when mouse is pressed - if (mousePressed == true) { - angle += 10; - float val = cos(radians(angle)) * 6.0; - for (int a = 0; a < 360; a += 75) { - float xoff = cos(radians(a)) * val; - float yoff = sin(radians(a)) * val; - fill(0); - ellipse(mouseX + xoff, mouseY + yoff, val, val); - } - fill(255); - ellipse(mouseX, mouseY, 2, 2); - } -} diff --git a/android/examples/Topics/Drawing/Pulses/applet/loading.gif b/android/examples/Topics/Drawing/Pulses/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/Pulses/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.java b/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.java deleted file mode 100644 index 48f6f20e4..000000000 --- a/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.java +++ /dev/null @@ -1,111 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class ScribblePlotter extends PApplet { - -/** - * Scribble Plotter - * by Ira Greenberg. - * - * Using 2-dimensional arrays, record end points - * and replot scribbles between points. - */ - -int SCRIBBLE = 0; -int HATCHING = 1; - -public void setup(){ - size(640, 360); - background(0); - - // Create arrays to hold x, y coords - float[]x = new float[4]; - float[]y = new float[4]; - // create a convenient 2-dimensional - // array to hold x, y arrays - float[][]xy = {x, y}; - - // Record points - // X positions - xy[0][0] = 125; - xy[0][1] = 475; - xy[0][2] = 475; - xy[0][3] = 125; - - // Y positions - xy[1][0] = 100; - xy[1][1] = 100; - xy[1][2] = 260; - xy[1][3] = 260; - - // Call plotting function - makeRect(xy); -} - -public void makeRect(float[][]pts){ - stroke(255); - smooth(); - - // Scribble variables, that get passed as arguments to the scribble function - int steps = 100; - float scribVal = 3.0f; - for (int i = 0; i < pts[0].length; i++){ - // Plots vertices - strokeWeight(5); - point(pts[0][i], pts[1][i]); - - // Call scribble function - strokeWeight(.5f); - if (i > 0){ - scribble(pts[0][i], pts[1][i], pts[0][i-1], pts[1][i-1], steps, scribVal, SCRIBBLE); - } - if (i == pts[0].length-1){ - // Show some hatching between last 2 points - scribble(pts[0][i], pts[1][i], pts[0][0], pts[1][0], steps, scribVal*2, HATCHING); - } - } -} - -/* - Scribble function plots lines between end points, - determined by steps and scribVal arguments. - two styles are available: SCRIBBLE and HATCHING, which - are interestingly only dependent on parentheses - placement in the line() function calls. -*/ - -public void scribble(float x1, float y1, float x2, float y2, int steps, float scribVal, int style){ - - float xStep = (x2-x1)/steps; - float yStep = (y2-y1)/steps; - for (int i = 0; i < steps; i++){ - if(style == SCRIBBLE){ - if (i < steps-1){ - line(x1, y1, x1+=xStep+random(-scribVal, scribVal), y1+=yStep+random(-scribVal, scribVal)); - } - else { - // extra line needed to attach line back to point- not necessary in HATCHING style - line(x1, y1, x2, y2); - } - } - else if (style == HATCHING){ - line(x1, y1, (x1+=xStep)+random(-scribVal, scribVal), (y1+=yStep)+random(-scribVal, scribVal)); - } - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "ScribblePlotter" }); - } -} diff --git a/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.pde b/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.pde deleted file mode 100644 index f5dcbf6ef..000000000 --- a/android/examples/Topics/Drawing/ScribblePlotter/applet/ScribblePlotter.pde +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Scribble Plotter - * by Ira Greenberg. - * - * Using 2-dimensional arrays, record end points - * and replot scribbles between points. - */ - -int SCRIBBLE = 0; -int HATCHING = 1; - -void setup(){ - size(640, 360); - background(0); - - // Create arrays to hold x, y coords - float[]x = new float[4]; - float[]y = new float[4]; - // create a convenient 2-dimensional - // array to hold x, y arrays - float[][]xy = {x, y}; - - // Record points - // X positions - xy[0][0] = 125; - xy[0][1] = 475; - xy[0][2] = 475; - xy[0][3] = 125; - - // Y positions - xy[1][0] = 100; - xy[1][1] = 100; - xy[1][2] = 260; - xy[1][3] = 260; - - // Call plotting function - makeRect(xy); -} - -void makeRect(float[][]pts){ - stroke(255); - smooth(); - - // Scribble variables, that get passed as arguments to the scribble function - int steps = 100; - float scribVal = 3.0; - for (int i = 0; i < pts[0].length; i++){ - // Plots vertices - strokeWeight(5); - point(pts[0][i], pts[1][i]); - - // Call scribble function - strokeWeight(.5); - if (i > 0){ - scribble(pts[0][i], pts[1][i], pts[0][i-1], pts[1][i-1], steps, scribVal, SCRIBBLE); - } - if (i == pts[0].length-1){ - // Show some hatching between last 2 points - scribble(pts[0][i], pts[1][i], pts[0][0], pts[1][0], steps, scribVal*2, HATCHING); - } - } -} - -/* - Scribble function plots lines between end points, - determined by steps and scribVal arguments. - two styles are available: SCRIBBLE and HATCHING, which - are interestingly only dependent on parentheses - placement in the line() function calls. -*/ - -void scribble(float x1, float y1, float x2, float y2, int steps, float scribVal, int style){ - - float xStep = (x2-x1)/steps; - float yStep = (y2-y1)/steps; - for (int i = 0; i < steps; i++){ - if(style == SCRIBBLE){ - if (i < steps-1){ - line(x1, y1, x1+=xStep+random(-scribVal, scribVal), y1+=yStep+random(-scribVal, scribVal)); - } - else { - // extra line needed to attach line back to point- not necessary in HATCHING style - line(x1, y1, x2, y2); - } - } - else if (style == HATCHING){ - line(x1, y1, (x1+=xStep)+random(-scribVal, scribVal), (y1+=yStep)+random(-scribVal, scribVal)); - } - } -} - diff --git a/android/examples/Topics/Drawing/ScribblePlotter/applet/loading.gif b/android/examples/Topics/Drawing/ScribblePlotter/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Drawing/ScribblePlotter/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/FireCube/applet/FireCube.java b/android/examples/Topics/Effects/FireCube/applet/FireCube.java deleted file mode 100644 index e21d13601..000000000 --- a/android/examples/Topics/Effects/FireCube/applet/FireCube.java +++ /dev/null @@ -1,132 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class FireCube extends PApplet { - -/** - * Fire Cube demo effect - * by luis2048. - * - * A rotating wireframe cube with flames rising up the screen. - * The fire effect has been used quite often for oldskool demos. - * First you create a palette of 256 colors ranging from red to - * yellow (including black). For every frame, calculate each row - * of pixels based on the two rows below it: The value of each pixel, - * becomes the sum of the 3 pixels below it (one directly below, one - * to the left, and one to the right), and one pixel directly two - * rows below it. Then divide the sum so that the fire dies out as - * it rises. - */ - -// This will contain the pixels used to calculate the fire effect -int[][] fire; - -// Flame colors -int[] palette; -float angle; -int[] calc1,calc2,calc3,calc4,calc5; - -PGraphics pg; - -public void setup(){ - size(640, 360, P3D); - - // Create buffered image for 3d cube - pg = createGraphics(width, height, P3D); - - calc1 = new int[width]; - calc3 = new int[width]; - calc4 = new int[width]; - calc2 = new int[height]; - calc5 = new int[height]; - - colorMode(HSB); - - fire = new int[width][height]; - palette = new int[255]; - - // Generate the palette - for(int x = 0; x < palette.length; x++) { - //Hue goes from 0 to 85: red to yellow - //Saturation is always the maximum: 255 - //Lightness is 0..255 for x=0..128, and 255 for x=128..255 - palette[x] = color(x/3, 255, constrain(x*3, 0, 255)); - } - - // Precalculate which pixel values to add during animation loop - // this speeds up the effect by 10fps - for (int x = 0; x < width; x++) { - calc1[x] = x % width; - calc3[x] = (x - 1 + width) % width; - calc4[x] = (x + 1) % width; - } - - for(int y = 0; y < height; y++) { - calc2[y] = (y + 1) % height; - calc5[y] = (y + 2) % height; - } -} - -public void draw() { - angle = angle + 0.05f; - - // Rotating wireframe cube - pg.beginDraw(); - pg.translate(width >> 1, height >> 1); - pg.rotateX(sin(angle/2)); - pg.rotateY(cos(angle/2)); - pg.background(0); - pg.stroke(128); - pg.scale(25); - pg.noFill(); - pg.box(4); - pg.endDraw(); - - // Randomize the bottom row of the fire buffer - for(int x = 0; x < width; x++) - { - fire[x][height-1] = PApplet.parseInt(random(0,190)) ; - } - - loadPixels(); - - int counter = 0; - // Do the fire calculations for every pixel, from top to bottom - for (int y = 0; y < height; y++) { - for(int x = 0; x < width; x++) { - // Add pixel values around current pixel - - fire[x][y] = - ((fire[calc3[x]][calc2[y]] - + fire[calc1[x]][calc2[y]] - + fire[calc4[x]][calc2[y]] - + fire[calc1[x]][calc5[y]]) << 5) / 129; - - // Output everything to screen using our palette colors - pixels[counter] = palette[fire[x][y]]; - - // Extract the red value using right shift and bit mask - // equivalent of red(pg.pixels[x+y*w]) - if ((pg.pixels[counter++] >> 16 & 0xFF) == 128) { - // Only map 3D cube 'lit' pixels onto fire array needed for next frame - fire[x][y] = 128; - } - } - } - updatePixels(); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "FireCube" }); - } -} diff --git a/android/examples/Topics/Effects/FireCube/applet/FireCube.pde b/android/examples/Topics/Effects/FireCube/applet/FireCube.pde deleted file mode 100644 index b66a50c1d..000000000 --- a/android/examples/Topics/Effects/FireCube/applet/FireCube.pde +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Fire Cube demo effect - * by luis2048. - * - * A rotating wireframe cube with flames rising up the screen. - * The fire effect has been used quite often for oldskool demos. - * First you create a palette of 256 colors ranging from red to - * yellow (including black). For every frame, calculate each row - * of pixels based on the two rows below it: The value of each pixel, - * becomes the sum of the 3 pixels below it (one directly below, one - * to the left, and one to the right), and one pixel directly two - * rows below it. Then divide the sum so that the fire dies out as - * it rises. - */ - -// This will contain the pixels used to calculate the fire effect -int[][] fire; - -// Flame colors -color[] palette; -float angle; -int[] calc1,calc2,calc3,calc4,calc5; - -PGraphics pg; - -void setup(){ - size(640, 360, P3D); - - // Create buffered image for 3d cube - pg = createGraphics(width, height, P3D); - - calc1 = new int[width]; - calc3 = new int[width]; - calc4 = new int[width]; - calc2 = new int[height]; - calc5 = new int[height]; - - colorMode(HSB); - - fire = new int[width][height]; - palette = new color[255]; - - // Generate the palette - for(int x = 0; x < palette.length; x++) { - //Hue goes from 0 to 85: red to yellow - //Saturation is always the maximum: 255 - //Lightness is 0..255 for x=0..128, and 255 for x=128..255 - palette[x] = color(x/3, 255, constrain(x*3, 0, 255)); - } - - // Precalculate which pixel values to add during animation loop - // this speeds up the effect by 10fps - for (int x = 0; x < width; x++) { - calc1[x] = x % width; - calc3[x] = (x - 1 + width) % width; - calc4[x] = (x + 1) % width; - } - - for(int y = 0; y < height; y++) { - calc2[y] = (y + 1) % height; - calc5[y] = (y + 2) % height; - } -} - -void draw() { - angle = angle + 0.05; - - // Rotating wireframe cube - pg.beginDraw(); - pg.translate(width >> 1, height >> 1); - pg.rotateX(sin(angle/2)); - pg.rotateY(cos(angle/2)); - pg.background(0); - pg.stroke(128); - pg.scale(25); - pg.noFill(); - pg.box(4); - pg.endDraw(); - - // Randomize the bottom row of the fire buffer - for(int x = 0; x < width; x++) - { - fire[x][height-1] = int(random(0,190)) ; - } - - loadPixels(); - - int counter = 0; - // Do the fire calculations for every pixel, from top to bottom - for (int y = 0; y < height; y++) { - for(int x = 0; x < width; x++) { - // Add pixel values around current pixel - - fire[x][y] = - ((fire[calc3[x]][calc2[y]] - + fire[calc1[x]][calc2[y]] - + fire[calc4[x]][calc2[y]] - + fire[calc1[x]][calc5[y]]) << 5) / 129; - - // Output everything to screen using our palette colors - pixels[counter] = palette[fire[x][y]]; - - // Extract the red value using right shift and bit mask - // equivalent of red(pg.pixels[x+y*w]) - if ((pg.pixels[counter++] >> 16 & 0xFF) == 128) { - // Only map 3D cube 'lit' pixels onto fire array needed for next frame - fire[x][y] = 128; - } - } - } - updatePixels(); -} diff --git a/android/examples/Topics/Effects/FireCube/applet/loading.gif b/android/examples/Topics/Effects/FireCube/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/FireCube/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/Lens/applet/Lens.java b/android/examples/Topics/Effects/Lens/applet/Lens.java deleted file mode 100644 index 1ec9e055c..000000000 --- a/android/examples/Topics/Effects/Lens/applet/Lens.java +++ /dev/null @@ -1,125 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Lens extends PApplet { - -/** - * Lens Demo Effect - * by luis2048. - * - * A picture is shown and it looks like a magnifying glass - * is drawn over the picture. One of the most famous demos - * that has a lens effect is 2nd reality by future crew. - * The trick is to precalculate the entire effect. Just make - * an array that for each pixel in the destination picture - * tells which pixel to take from the source picture. This - * array is called the transformation array. The tricky part - * is to calculate the transformation array to make the - * destination look like a lens is beeing held over the source - * picture. Based on lens formula by on Abe Racadabra. - */ - -int lensD = 256; // Lens diameter -int[] lensArray = new int[lensD*lensD]; // Height and width of lens - -PGraphics lensEffect; -PImage lensImage; -PImage lensImage2; - -int xx = 0; -int yy = 0; -int dx = 1; -int dy = 1; - -public void setup() { - - size(640, 360); - - // Create buffered image for lens effect - lensEffect = createGraphics(width, height, JAVA2D); - - // Load background image - lensEffect.beginDraw(); - lensEffect.image(loadImage("red_smoke.jpg"), 0, 0, - lensEffect.width, lensEffect.height); - lensEffect.endDraw(); - - // Create buffered image for image to warp - lensImage = createGraphics(lensD, lensD, JAVA2D); - lensImage2 = createGraphics(lensD, lensD, JAVA2D); - - // Lens algorithm (transformation array) - int magFactor = 40; // Magnification factor - int m, a, b; - - int r = lensD / 2; - float s = sqrt(r*r - magFactor*magFactor); - - for (int y = -r; y < r; y++) { - for (int x = -r ;x < r; x++) { - if(x*x + y*y >= s*s) { - a = x; - b = y; - } - else { - float z = sqrt(r*r - x*x - y*y); - a = PApplet.parseInt(x * magFactor / z + 0.5f); - b = PApplet.parseInt(y * magFactor / z + 0.5f); - } - lensArray[(y + r)*lensD + (x + r)] = (b + r) * lensD + (a + r); - } - } -} - -public void draw() { - - // Bounce lens around the screen - if((xx+dx+lensD > lensEffect.width) || (xx+dx < 0)) { - dx =- dx; - } - if((yy+dy+lensD > lensEffect.height) || (yy+dy < 0)) { - dy =- dy; - } - xx += dx; - yy += dy; - - lensImage = createGraphics(lensD, lensD, JAVA2D); - - // save the backgrounlensD of lensHeight*lensWilensDth pixels rectangle at the coorlensDinates - // where the lens effect will be applielensD. - lensImage2.copy(lensEffect, xx, yy, lensD, lensD, 0, 0, lensD, lensD); - - // output into a bufferelensD image for reuse - lensImage.loadPixels(); - - // For each pixel in the destination rectangle, apply the color - // from the appropriate pixel in the saved background. The lensArray - // array tells the offset into the saved background. - for (int i = 0; i < lensImage.pixels.length; i++) { - lensImage.pixels[i] = lensImage2.pixels[lensArray[i]]; - } - lensImage.updatePixels(); - - // Restore the original picture - image(lensEffect, 0, 0, width, height); - - // Overlay the lens square - image(lensImage, xx, yy, lensD, lensD); - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Lens" }); - } -} diff --git a/android/examples/Topics/Effects/Lens/applet/Lens.pde b/android/examples/Topics/Effects/Lens/applet/Lens.pde deleted file mode 100644 index 766a10600..000000000 --- a/android/examples/Topics/Effects/Lens/applet/Lens.pde +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Lens Demo Effect - * by luis2048. - * - * A picture is shown and it looks like a magnifying glass - * is drawn over the picture. One of the most famous demos - * that has a lens effect is 2nd reality by future crew. - * The trick is to precalculate the entire effect. Just make - * an array that for each pixel in the destination picture - * tells which pixel to take from the source picture. This - * array is called the transformation array. The tricky part - * is to calculate the transformation array to make the - * destination look like a lens is beeing held over the source - * picture. Based on lens formula by on Abe Racadabra. - */ - -int lensD = 256; // Lens diameter -int[] lensArray = new int[lensD*lensD]; // Height and width of lens - -PGraphics lensEffect; -PImage lensImage; -PImage lensImage2; - -int xx = 0; -int yy = 0; -int dx = 1; -int dy = 1; - -void setup() { - - size(640, 360); - - // Create buffered image for lens effect - lensEffect = createGraphics(width, height, JAVA2D); - - // Load background image - lensEffect.beginDraw(); - lensEffect.image(loadImage("red_smoke.jpg"), 0, 0, - lensEffect.width, lensEffect.height); - lensEffect.endDraw(); - - // Create buffered image for image to warp - lensImage = createGraphics(lensD, lensD, JAVA2D); - lensImage2 = createGraphics(lensD, lensD, JAVA2D); - - // Lens algorithm (transformation array) - int magFactor = 40; // Magnification factor - int m, a, b; - - int r = lensD / 2; - float s = sqrt(r*r - magFactor*magFactor); - - for (int y = -r; y < r; y++) { - for (int x = -r ;x < r; x++) { - if(x*x + y*y >= s*s) { - a = x; - b = y; - } - else { - float z = sqrt(r*r - x*x - y*y); - a = int(x * magFactor / z + 0.5); - b = int(y * magFactor / z + 0.5); - } - lensArray[(y + r)*lensD + (x + r)] = (b + r) * lensD + (a + r); - } - } -} - -void draw() { - - // Bounce lens around the screen - if((xx+dx+lensD > lensEffect.width) || (xx+dx < 0)) { - dx =- dx; - } - if((yy+dy+lensD > lensEffect.height) || (yy+dy < 0)) { - dy =- dy; - } - xx += dx; - yy += dy; - - lensImage = createGraphics(lensD, lensD, JAVA2D); - - // save the backgrounlensD of lensHeight*lensWilensDth pixels rectangle at the coorlensDinates - // where the lens effect will be applielensD. - lensImage2.copy(lensEffect, xx, yy, lensD, lensD, 0, 0, lensD, lensD); - - // output into a bufferelensD image for reuse - lensImage.loadPixels(); - - // For each pixel in the destination rectangle, apply the color - // from the appropriate pixel in the saved background. The lensArray - // array tells the offset into the saved background. - for (int i = 0; i < lensImage.pixels.length; i++) { - lensImage.pixels[i] = lensImage2.pixels[lensArray[i]]; - } - lensImage.updatePixels(); - - // Restore the original picture - image(lensEffect, 0, 0, width, height); - - // Overlay the lens square - image(lensImage, xx, yy, lensD, lensD); - -} - diff --git a/android/examples/Topics/Effects/Lens/applet/loading.gif b/android/examples/Topics/Effects/Lens/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/Lens/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/Metaball/applet/Metaball.java b/android/examples/Topics/Effects/Metaball/applet/Metaball.java deleted file mode 100644 index fe2731751..000000000 --- a/android/examples/Topics/Effects/Metaball/applet/Metaball.java +++ /dev/null @@ -1,96 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Metaball extends PApplet { - -/** - * Metaball Demo Effect - * by luis2048. - * - * Organic-looking n-dimensional objects. The technique for rendering - * metaballs was invented by Jim Blinn in the early 1980s. Each metaball - * is defined as a function in n-dimensions. - */ - -int numBlobs = 3; - -int[] blogPx = { 0, 90, 90 }; -int[] blogPy = { 0, 120, 45 }; - -// Movement vector for each blob -int[] blogDx = { 1, 1, 1 }; -int[] blogDy = { 1, 1, 1 }; - -PGraphics pg; -int[][] vy,vx; - -public void setup() { - size(640, 360); - pg = createGraphics(160, 90, P2D); - vy = new int[numBlobs][pg.height]; - vx = new int[numBlobs][pg.width]; -} - -public void draw() { - for (int i=0; i pg.width) { - blogDx[i] = -1; - } - if (blogPy[i] < 0) { - blogDy[i] = 1; - } - if (blogPy[i] > pg.height) { - blogDy[i]=-1; - } - - for (int x = 0; x < pg.width; x++) { - vx[i][x] = PApplet.parseInt(sq(blogPx[i]-x)); - } - - for (int y = 0; y < pg.height; y++) { - vy[i][y] = PApplet.parseInt(sq(blogPy[i]-y)); - } - } - - // Output into a buffered image for reuse - pg.beginDraw(); - pg.loadPixels(); - for (int y = 0; y < pg.height; y++) { - for (int x = 0; x < pg.width; x++) { - int m = 1; - for (int i = 0; i < numBlobs; i++) { - // Increase this number to make your blobs bigger - m += 60000/(vy[i][y] + vx[i][x]+1); - } - pg.pixels[x+y*pg.width] = color(0, m+x, (x+m+y)/2); - } - } - pg.updatePixels(); - pg.endDraw(); - - // Display the results - image(pg, 0, 0, width, height); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Metaball" }); - } -} diff --git a/android/examples/Topics/Effects/Metaball/applet/Metaball.pde b/android/examples/Topics/Effects/Metaball/applet/Metaball.pde deleted file mode 100644 index cde5d1c4a..000000000 --- a/android/examples/Topics/Effects/Metaball/applet/Metaball.pde +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Metaball Demo Effect - * by luis2048. - * - * Organic-looking n-dimensional objects. The technique for rendering - * metaballs was invented by Jim Blinn in the early 1980s. Each metaball - * is defined as a function in n-dimensions. - */ - -int numBlobs = 3; - -int[] blogPx = { 0, 90, 90 }; -int[] blogPy = { 0, 120, 45 }; - -// Movement vector for each blob -int[] blogDx = { 1, 1, 1 }; -int[] blogDy = { 1, 1, 1 }; - -PGraphics pg; -int[][] vy,vx; - -void setup() { - size(640, 360); - pg = createGraphics(160, 90, P2D); - vy = new int[numBlobs][pg.height]; - vx = new int[numBlobs][pg.width]; -} - -void draw() { - for (int i=0; i pg.width) { - blogDx[i] = -1; - } - if (blogPy[i] < 0) { - blogDy[i] = 1; - } - if (blogPy[i] > pg.height) { - blogDy[i]=-1; - } - - for (int x = 0; x < pg.width; x++) { - vx[i][x] = int(sq(blogPx[i]-x)); - } - - for (int y = 0; y < pg.height; y++) { - vy[i][y] = int(sq(blogPy[i]-y)); - } - } - - // Output into a buffered image for reuse - pg.beginDraw(); - pg.loadPixels(); - for (int y = 0; y < pg.height; y++) { - for (int x = 0; x < pg.width; x++) { - int m = 1; - for (int i = 0; i < numBlobs; i++) { - // Increase this number to make your blobs bigger - m += 60000/(vy[i][y] + vx[i][x]+1); - } - pg.pixels[x+y*pg.width] = color(0, m+x, (x+m+y)/2); - } - } - pg.updatePixels(); - pg.endDraw(); - - // Display the results - image(pg, 0, 0, width, height); -} - diff --git a/android/examples/Topics/Effects/Metaball/applet/loading.gif b/android/examples/Topics/Effects/Metaball/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/Metaball/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/Plasma/applet/Plasma.java b/android/examples/Topics/Effects/Plasma/applet/Plasma.java deleted file mode 100644 index 7f09d75ac..000000000 --- a/android/examples/Topics/Effects/Plasma/applet/Plasma.java +++ /dev/null @@ -1,80 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Plasma extends PApplet { - -/** - * Plasma Demo Effect - * by luis2048. - * - * Cycles of changing colours warped to give an illusion - * of liquid, organic movement.Colors are the sum of sine - * functions and various formulas. Based on formula by Robert Klep. - */ - -int pixelSize=2; -PGraphics pg; - -public void setup(){ - size(640, 360); - // Create buffered image for plasma effect - pg = createGraphics(160, 90, P2D); - colorMode(HSB); - noSmooth(); -} - -public void draw() -{ - float xc = 25; - - // Enable this to control the speed of animation regardless of CPU power - // int timeDisplacement = millis()/30; - - // This runs plasma as fast as your computer can handle - int timeDisplacement = frameCount; - - // No need to do this math for every pixel - float calculation1 = sin( radians(timeDisplacement * 0.61655617f)); - float calculation2 = sin( radians(timeDisplacement * -3.6352262f)); - - // Output into a buffered image for reuse - pg.beginDraw(); - pg.loadPixels(); - - // Plasma algorithm - for (int x = 0; x < pg.width; x++, xc += pixelSize) - { - float yc = 25; - float s1 = 128 + 128 * sin(radians(xc) * calculation1 ); - - for (int y = 0; y < pg.height; y++, yc += pixelSize) - { - float s2 = 128 + 128 * sin(radians(yc) * calculation2 ); - float s3 = 128 + 128 * sin(radians((xc + yc + timeDisplacement * 5) / 2)); - float s = (s1+ s2 + s3) / 3; - pg.pixels[x+y*pg.width] = color(s, 255 - s / 2.0f, 255); - } - } - pg.updatePixels(); - pg.endDraw(); - - // display the results - image(pg,0,0,width,height); - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Plasma" }); - } -} diff --git a/android/examples/Topics/Effects/Plasma/applet/Plasma.pde b/android/examples/Topics/Effects/Plasma/applet/Plasma.pde deleted file mode 100644 index 04b20d84d..000000000 --- a/android/examples/Topics/Effects/Plasma/applet/Plasma.pde +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Plasma Demo Effect - * by luis2048. - * - * Cycles of changing colours warped to give an illusion - * of liquid, organic movement.Colors are the sum of sine - * functions and various formulas. Based on formula by Robert Klep. - */ - -int pixelSize=2; -PGraphics pg; - -void setup(){ - size(640, 360); - // Create buffered image for plasma effect - pg = createGraphics(160, 90, P2D); - colorMode(HSB); - noSmooth(); -} - -void draw() -{ - float xc = 25; - - // Enable this to control the speed of animation regardless of CPU power - // int timeDisplacement = millis()/30; - - // This runs plasma as fast as your computer can handle - int timeDisplacement = frameCount; - - // No need to do this math for every pixel - float calculation1 = sin( radians(timeDisplacement * 0.61655617)); - float calculation2 = sin( radians(timeDisplacement * -3.6352262)); - - // Output into a buffered image for reuse - pg.beginDraw(); - pg.loadPixels(); - - // Plasma algorithm - for (int x = 0; x < pg.width; x++, xc += pixelSize) - { - float yc = 25; - float s1 = 128 + 128 * sin(radians(xc) * calculation1 ); - - for (int y = 0; y < pg.height; y++, yc += pixelSize) - { - float s2 = 128 + 128 * sin(radians(yc) * calculation2 ); - float s3 = 128 + 128 * sin(radians((xc + yc + timeDisplacement * 5) / 2)); - float s = (s1+ s2 + s3) / 3; - pg.pixels[x+y*pg.width] = color(s, 255 - s / 2.0, 255); - } - } - pg.updatePixels(); - pg.endDraw(); - - // display the results - image(pg,0,0,width,height); - -} - diff --git a/android/examples/Topics/Effects/Plasma/applet/loading.gif b/android/examples/Topics/Effects/Plasma/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/Plasma/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/Tunnel/applet/Tunnel.java b/android/examples/Topics/Effects/Tunnel/applet/Tunnel.java deleted file mode 100644 index 90a166184..000000000 --- a/android/examples/Topics/Effects/Tunnel/applet/Tunnel.java +++ /dev/null @@ -1,133 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Tunnel extends PApplet { - -/** - * Tunnel Demo Effect - * by luis2048. - * - * This effect shows a tunnel in which you fly while the tunnel - * rotates, seemingly in 3D. The animation of the tunnel actually - * isn't calculated on the fly while the animation runs, but is - * precalculated. These calculations are stored in two tables: - * one for the angle and one for the distance. For every frame, - * go through every pixel (x,y) and use the angle and distance - * tables to get which pixel of the texture it should draw at the - * current pixel. To look like its rotating and zooming, the values - * of the angle and distance tables are shifted. - */ - -int x, y, radius, l; -PGraphics tunnelEffect; -PImage textureImg; - -// build lookup table -int[][] distanceTable; -int[][] angleTable; -int[][] shadeTable; -int w, h; - -public void setup(){ - size(640, 360); - - // Load texture 512 x 512 - textureImg=loadImage("red_smoke.jpg"); - - // Create buffer screen - tunnelEffect = createGraphics(320, 200, P2D); - w = tunnelEffect.width; - h = tunnelEffect.height; - - float ratio = 32.0f; - int angle; - int depth; - int shade = 0; - - // Make the tables twice as big as the screen. - // The center of the buffers is now the position (w,h). - distanceTable= new int[2 * w][2 * h]; - angleTable= new int[2 * w][2 * h]; - - for (int x = 0; x < w*2; x++) - { - for (int y = 0; y < h*2; y++) - { - depth = PApplet.parseInt(ratio * textureImg.height - / sqrt(PApplet.parseFloat((x - w) * (x - w) + (y - h) * (y - h)))) ; - angle = PApplet.parseInt(0.5f * textureImg.width * atan2(PApplet.parseFloat(y - h), - PApplet.parseFloat(x - w)) / PI) ; - - // The distance table contains for every pixel of the - // screen, the inverse of the distance to the center of - // the screen this pixel has. - distanceTable[x][y] = depth ; - - // The angle table contains the angle of every pixel of the screen, - // where the center of the screen represents the origin. - angleTable[x][y] = angle ; - } - } -} - - -public void draw() { - - tunnelEffect.beginDraw(); - tunnelEffect.loadPixels(); - - float timeDisplacement = millis() / 1000.0f; - - // Calculate the shift values out of the time value - int shiftX = PApplet.parseInt(textureImg.width * .2f * timeDisplacement+300); // speed of zoom - int shiftY = PApplet.parseInt(textureImg.height * .15f * timeDisplacement+300); //speed of spin - - // Calculate the look values out of the time value - // by using sine functions, it'll alternate between - // looking left/right and up/down - int shiftLookX = w / 2 + PApplet.parseInt(w / 4 * sin(timeDisplacement)); - int shiftLookY = h / 2 + PApplet.parseInt(h / 4 * sin(timeDisplacement * 1.5f)); - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - - // Make sure that x + shiftLookX never goes outside - // the dimensions of the table - int texture_x = constrain((distanceTable[x + shiftLookX][y + shiftLookY] - + shiftX) % textureImg.width ,0, textureImg.width); - - int texture_y = (angleTable[x + shiftLookX][y + shiftLookY] - + shiftY) % textureImg.height; - - tunnelEffect.pixels[x+y*w] = textureImg.pixels[texture_y - * textureImg.width + texture_x]; - - // Test lookuptables - // tunnelEffect.pixels[x+y*w] = color( 0,texture_x,texture_y); - } - } - - tunnelEffect.updatePixels(); - tunnelEffect.endDraw(); - - // Display the results - image(tunnelEffect, 0, 0, width, height); - -} - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Tunnel" }); - } -} diff --git a/android/examples/Topics/Effects/Tunnel/applet/Tunnel.pde b/android/examples/Topics/Effects/Tunnel/applet/Tunnel.pde deleted file mode 100644 index c5155fc86..000000000 --- a/android/examples/Topics/Effects/Tunnel/applet/Tunnel.pde +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Tunnel Demo Effect - * by luis2048. - * - * This effect shows a tunnel in which you fly while the tunnel - * rotates, seemingly in 3D. The animation of the tunnel actually - * isn't calculated on the fly while the animation runs, but is - * precalculated. These calculations are stored in two tables: - * one for the angle and one for the distance. For every frame, - * go through every pixel (x,y) and use the angle and distance - * tables to get which pixel of the texture it should draw at the - * current pixel. To look like its rotating and zooming, the values - * of the angle and distance tables are shifted. - */ - -int x, y, radius, l; -PGraphics tunnelEffect; -PImage textureImg; - -// build lookup table -int[][] distanceTable; -int[][] angleTable; -int[][] shadeTable; -int w, h; - -void setup(){ - size(640, 360); - - // Load texture 512 x 512 - textureImg=loadImage("red_smoke.jpg"); - - // Create buffer screen - tunnelEffect = createGraphics(320, 200, P2D); - w = tunnelEffect.width; - h = tunnelEffect.height; - - float ratio = 32.0; - int angle; - int depth; - int shade = 0; - - // Make the tables twice as big as the screen. - // The center of the buffers is now the position (w,h). - distanceTable= new int[2 * w][2 * h]; - angleTable= new int[2 * w][2 * h]; - - for (int x = 0; x < w*2; x++) - { - for (int y = 0; y < h*2; y++) - { - depth = int(ratio * textureImg.height - / sqrt(float((x - w) * (x - w) + (y - h) * (y - h)))) ; - angle = int(0.5 * textureImg.width * atan2(float(y - h), - float(x - w)) / PI) ; - - // The distance table contains for every pixel of the - // screen, the inverse of the distance to the center of - // the screen this pixel has. - distanceTable[x][y] = depth ; - - // The angle table contains the angle of every pixel of the screen, - // where the center of the screen represents the origin. - angleTable[x][y] = angle ; - } - } -} - - -void draw() { - - tunnelEffect.beginDraw(); - tunnelEffect.loadPixels(); - - float timeDisplacement = millis() / 1000.0; - - // Calculate the shift values out of the time value - int shiftX = int(textureImg.width * .2 * timeDisplacement+300); // speed of zoom - int shiftY = int(textureImg.height * .15 * timeDisplacement+300); //speed of spin - - // Calculate the look values out of the time value - // by using sine functions, it'll alternate between - // looking left/right and up/down - int shiftLookX = w / 2 + int(w / 4 * sin(timeDisplacement)); - int shiftLookY = h / 2 + int(h / 4 * sin(timeDisplacement * 1.5)); - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - - // Make sure that x + shiftLookX never goes outside - // the dimensions of the table - int texture_x = constrain((distanceTable[x + shiftLookX][y + shiftLookY] - + shiftX) % textureImg.width ,0, textureImg.width); - - int texture_y = (angleTable[x + shiftLookX][y + shiftLookY] - + shiftY) % textureImg.height; - - tunnelEffect.pixels[x+y*w] = textureImg.pixels[texture_y - * textureImg.width + texture_x]; - - // Test lookuptables - // tunnelEffect.pixels[x+y*w] = color( 0,texture_x,texture_y); - } - } - - tunnelEffect.updatePixels(); - tunnelEffect.endDraw(); - - // Display the results - image(tunnelEffect, 0, 0, width, height); - -} - - diff --git a/android/examples/Topics/Effects/Tunnel/applet/loading.gif b/android/examples/Topics/Effects/Tunnel/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/Tunnel/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.java b/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.java deleted file mode 100644 index f88ac2f34..000000000 --- a/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.java +++ /dev/null @@ -1,80 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class UnlimitedSprites extends PApplet { - -/** - * Unlimited Sprites Demo Effect - * by luis2048. - * - * An infinate number of sprites drawn to screen. It's basically - * a flick-book effect; you draw the same sprite in different - * positions on different bufffer 'screens' and flip between them. - * When you've drawn on all frames, you loop back to the beginning - * and repeat. - */ - -PGraphics[] spriteFrames = new PGraphics[6]; -PImage sprite; - -float x, y; -float xang = 0.0f; -float yang = 0.0f; -int surf = 0; - -public void setup() { - size(640, 360); - noSmooth(); - background(0); - - // Create sprite - sprite=loadImage("Aqua-Ball-48x48.png"); - - // Create blank surfaces to draw on - for (int i = 0; i < spriteFrames.length; i++) { - spriteFrames[i] = createGraphics(width, height, JAVA2D); - } -} - -public void draw() -{ - background(0); - - // Get X, Y positions - x = (width/2)*sin((radians(xang))*0.95f); - y = (height/2)*cos((radians(yang))*0.97f); - - // Inc the angle of the sine - xang += 1.17f; - yang += 1.39f; - - // Blit our 'bob' on the 'active' surface - spriteFrames[surf].beginDraw(); - spriteFrames[surf].image(sprite, x+(width/2)-32, y+(height/2)-32); - spriteFrames[surf].endDraw(); - - // Blit the active surface to the screen - image(spriteFrames[surf], 0, 0, width, height); - - // Inc the active surface number - surf = (surf+1) % spriteFrames.length; - - // Display the results - //image(spriteEffect, 0, 0, width, height); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "UnlimitedSprites" }); - } -} diff --git a/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.pde b/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.pde deleted file mode 100644 index 6395eeaa1..000000000 --- a/android/examples/Topics/Effects/UnlimitedSprites/applet/UnlimitedSprites.pde +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Unlimited Sprites Demo Effect - * by luis2048. - * - * An infinate number of sprites drawn to screen. It's basically - * a flick-book effect; you draw the same sprite in different - * positions on different bufffer 'screens' and flip between them. - * When you've drawn on all frames, you loop back to the beginning - * and repeat. - */ - -PGraphics[] spriteFrames = new PGraphics[6]; -PImage sprite; - -float x, y; -float xang = 0.0; -float yang = 0.0; -int surf = 0; - -void setup() { - size(640, 360); - noSmooth(); - background(0); - - // Create sprite - sprite=loadImage("Aqua-Ball-48x48.png"); - - // Create blank surfaces to draw on - for (int i = 0; i < spriteFrames.length; i++) { - spriteFrames[i] = createGraphics(width, height, JAVA2D); - } -} - -void draw() -{ - background(0); - - // Get X, Y positions - x = (width/2)*sin((radians(xang))*0.95); - y = (height/2)*cos((radians(yang))*0.97); - - // Inc the angle of the sine - xang += 1.17; - yang += 1.39; - - // Blit our 'bob' on the 'active' surface - spriteFrames[surf].beginDraw(); - spriteFrames[surf].image(sprite, x+(width/2)-32, y+(height/2)-32); - spriteFrames[surf].endDraw(); - - // Blit the active surface to the screen - image(spriteFrames[surf], 0, 0, width, height); - - // Inc the active surface number - surf = (surf+1) % spriteFrames.length; - - // Display the results - //image(spriteEffect, 0, 0, width, height); -} - diff --git a/android/examples/Topics/Effects/UnlimitedSprites/applet/loading.gif b/android/examples/Topics/Effects/UnlimitedSprites/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/UnlimitedSprites/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Effects/Wormhole/applet/Wormhole.java b/android/examples/Topics/Effects/Wormhole/applet/Wormhole.java deleted file mode 100644 index 3f2f27156..000000000 --- a/android/examples/Topics/Effects/Wormhole/applet/Wormhole.java +++ /dev/null @@ -1,90 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Wormhole extends PApplet { - -/** - * Wormhole Demo Effect - * by luis2048. - * - * A funnel-shaped hole sucking its texture to the middle. - * The effect is accomplished like the tunnel effect but with - * a 15 x 15 texture and static lookup table. The texture is shifted - * and mapped to the static lookup table. - */ - -PImage wormImg, wormTexture; -int[] reg = new int[15]; - -public void setup() { - size(640, 360); - noSmooth(); - - // Reference image used to transpose texture - wormImg = loadImage("wormhole.png"); - wormImg.resize(width, height); - wormImg.loadPixels(); - - // Texture image array - wormTexture = loadImage("texture.gif"); - wormTexture.loadPixels(); -} - -// Moves the bottom row of pixels to the top and shifting remaining pixels 1 over -public void shiftup() { - for (int k = 0; k < 15; k++) { - reg[k] = wormTexture.pixels[k]; - } - - for (int k = 15; k < 225; k++) { - wormTexture.pixels[k-15] = wormTexture.pixels[k]; - } - for (int k = 0; k < 15; k++) { - wormTexture.pixels[k+210] = reg[k]; - } -} - -// Moves left column of pixels to the right and shifting remaining pixels 1 over -public void shiftright() { - for(int k = 0; k < 15; k++) { - reg[k] = wormTexture.pixels[15*k+14]; - for(int i = 14;i > 0; i--) { - wormTexture.pixels[15*k+i] = wormTexture.pixels[15*k+(i-1)]; - } - wormTexture.pixels[15*k] = reg[k]; - } -} - -public void draw() { - // Load pixel data array - loadPixels(); - - // Loop through all pixels - for (int i = 0; i < pixels.length; i++){ - // Map texture to wormhole in a bit shift blue - pixels[i] = wormTexture.pixels[constrain(wormImg.pixels[i] & 0xFF , 0 , 224)]; - } - - updatePixels(); - - shiftright(); - shiftup(); -} - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Wormhole" }); - } -} diff --git a/android/examples/Topics/Effects/Wormhole/applet/Wormhole.pde b/android/examples/Topics/Effects/Wormhole/applet/Wormhole.pde deleted file mode 100644 index cb1762983..000000000 --- a/android/examples/Topics/Effects/Wormhole/applet/Wormhole.pde +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Wormhole Demo Effect - * by luis2048. - * - * A funnel-shaped hole sucking its texture to the middle. - * The effect is accomplished like the tunnel effect but with - * a 15 x 15 texture and static lookup table. The texture is shifted - * and mapped to the static lookup table. - */ - -PImage wormImg, wormTexture; -int[] reg = new int[15]; - -void setup() { - size(640, 360); - noSmooth(); - - // Reference image used to transpose texture - wormImg = loadImage("wormhole.png"); - wormImg.resize(width, height); - wormImg.loadPixels(); - - // Texture image array - wormTexture = loadImage("texture.gif"); - wormTexture.loadPixels(); -} - -// Moves the bottom row of pixels to the top and shifting remaining pixels 1 over -void shiftup() { - for (int k = 0; k < 15; k++) { - reg[k] = wormTexture.pixels[k]; - } - - for (int k = 15; k < 225; k++) { - wormTexture.pixels[k-15] = wormTexture.pixels[k]; - } - for (int k = 0; k < 15; k++) { - wormTexture.pixels[k+210] = reg[k]; - } -} - -// Moves left column of pixels to the right and shifting remaining pixels 1 over -void shiftright() { - for(int k = 0; k < 15; k++) { - reg[k] = wormTexture.pixels[15*k+14]; - for(int i = 14;i > 0; i--) { - wormTexture.pixels[15*k+i] = wormTexture.pixels[15*k+(i-1)]; - } - wormTexture.pixels[15*k] = reg[k]; - } -} - -void draw() { - // Load pixel data array - loadPixels(); - - // Loop through all pixels - for (int i = 0; i < pixels.length; i++){ - // Map texture to wormhole in a bit shift blue - pixels[i] = wormTexture.pixels[constrain(wormImg.pixels[i] & 0xFF , 0 , 224)]; - } - - updatePixels(); - - shiftright(); - shiftup(); -} - - - diff --git a/android/examples/Topics/Effects/Wormhole/applet/loading.gif b/android/examples/Topics/Effects/Wormhole/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Effects/Wormhole/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.java b/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.java deleted file mode 100644 index d8ae610a9..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.java +++ /dev/null @@ -1,195 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Koch extends PApplet { - -/** - * Koch Curve - * by Daniel Shiffman. - * - * Renders a simple fractal, the Koch snowflake. - * Each recursive level drawn in sequence. - */ - -KochFractal k; - -public void setup() { - size(640, 360); - background(0); - frameRate(1); // Animate slowly - k = new KochFractal(); - smooth(); -} - -public void draw() { - background(0); - // Draws the snowflake! - k.render(); - // Iterate - k.nextLevel(); - // Let's not do it more than 5 times. . . - if (k.getCount() > 5) { - k.restart(); - } - -} - - -// A class to manage the list of line segments in the snowflake pattern - -class KochFractal { - Point start; // A point for the start - Point end; // A point for the end - ArrayList lines; // A list to keep track of all the lines - int count; - - public KochFractal() - { - start = new Point(0,height/2 + height/4); - end = new Point(width,height/2 + height/4); - lines = new ArrayList(); - restart(); - } - - public void nextLevel() - { - // For every line that is in the arraylist - // create 4 more lines in a new arraylist - lines = iterate(lines); - count++; - } - - public void restart() - { - count = 0; // Reset count - lines.clear(); // Empty the array list - lines.add(new KochLine(start,end)); // Add the initial line (from one end point to the other) - } - - public int getCount() { - return count; - } - - // This is easy, just draw all the lines - public void render() - { - for(int i = 0; i < lines.size(); i++) { - KochLine l = (KochLine)lines.get(i); - l.render(); - } - } - - // This is where the **MAGIC** happens - // Step 1: Create an empty arraylist - // Step 2: For every line currently in the arraylist - // - calculate 4 line segments based on Koch algorithm - // - add all 4 line segments into the new arraylist - // Step 3: Return the new arraylist and it becomes the list of line segments for the structure - - // As we do this over and over again, each line gets broken into 4 lines, which gets broken into 4 lines, and so on. . . - public ArrayList iterate(ArrayList before) - { - ArrayList now = new ArrayList(); //Create emtpy list - for(int i = 0; i < before.size(); i++) - { - KochLine l = (KochLine)lines.get(i); // A line segment inside the list - // Calculate 5 koch points (done for us by the line object) - Point a = l.start(); - Point b = l.kochleft(); - Point c = l.kochmiddle(); - Point d = l.kochright(); - Point e = l.end(); - // Make line segments between all the points and add them - now.add(new KochLine(a,b)); - now.add(new KochLine(b,c)); - now.add(new KochLine(c,d)); - now.add(new KochLine(d,e)); - } - return now; - } - -} - - -// A class to describe one line segment in the fractal -// Includes methods to calculate midpoints along the line according to the Koch algorithm - -class KochLine { - - // Two points, - // a is the "left" point and - // b is the "right point - Point a,b; - - KochLine(Point a_, Point b_) { - a = a_.copy(); - b = b_.copy(); - } - - public void render() { - stroke(255); - line(a.x,a.y,b.x,b.y); - } - - public Point start() { - return a.copy(); - } - - public Point end() { - return b.copy(); - } - - // This is easy, just 1/3 of the way - public Point kochleft() - { - float x = a.x + (b.x - a.x) / 3f; - float y = a.y + (b.y - a.y) / 3f; - return new Point(x,y); - } - - // More complicated, have to use a little trig to figure out where this point is! - public Point kochmiddle() - { - float x = a.x + 0.5f * (b.x - a.x) + (sin(radians(60))*(b.y-a.y)) / 3; - float y = a.y + 0.5f * (b.y - a.y) - (sin(radians(60))*(b.x-a.x)) / 3; - return new Point(x,y); - } - - // Easy, just 2/3 of the way - public Point kochright() - { - float x = a.x + 2*(b.x - a.x) / 3f; - float y = a.y + 2*(b.y - a.y) / 3f; - return new Point(x,y); - } - -} - -class Point { - float x,y; - - Point(float x_, float y_) { - x = x_; - y = y_; - } - - public Point copy() { - return new Point(x,y); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Koch" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.pde b/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.pde deleted file mode 100644 index 317e1eb42..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Koch/applet/Koch.pde +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Koch Curve - * by Daniel Shiffman. - * - * Renders a simple fractal, the Koch snowflake. - * Each recursive level drawn in sequence. - */ - -KochFractal k; - -void setup() { - size(640, 360); - background(0); - frameRate(1); // Animate slowly - k = new KochFractal(); - smooth(); -} - -void draw() { - background(0); - // Draws the snowflake! - k.render(); - // Iterate - k.nextLevel(); - // Let's not do it more than 5 times. . . - if (k.getCount() > 5) { - k.restart(); - } - -} - - -// A class to manage the list of line segments in the snowflake pattern - -class KochFractal { - Point start; // A point for the start - Point end; // A point for the end - ArrayList lines; // A list to keep track of all the lines - int count; - - public KochFractal() - { - start = new Point(0,height/2 + height/4); - end = new Point(width,height/2 + height/4); - lines = new ArrayList(); - restart(); - } - - void nextLevel() - { - // For every line that is in the arraylist - // create 4 more lines in a new arraylist - lines = iterate(lines); - count++; - } - - void restart() - { - count = 0; // Reset count - lines.clear(); // Empty the array list - lines.add(new KochLine(start,end)); // Add the initial line (from one end point to the other) - } - - int getCount() { - return count; - } - - // This is easy, just draw all the lines - void render() - { - for(int i = 0; i < lines.size(); i++) { - KochLine l = (KochLine)lines.get(i); - l.render(); - } - } - - // This is where the **MAGIC** happens - // Step 1: Create an empty arraylist - // Step 2: For every line currently in the arraylist - // - calculate 4 line segments based on Koch algorithm - // - add all 4 line segments into the new arraylist - // Step 3: Return the new arraylist and it becomes the list of line segments for the structure - - // As we do this over and over again, each line gets broken into 4 lines, which gets broken into 4 lines, and so on. . . - ArrayList iterate(ArrayList before) - { - ArrayList now = new ArrayList(); //Create emtpy list - for(int i = 0; i < before.size(); i++) - { - KochLine l = (KochLine)lines.get(i); // A line segment inside the list - // Calculate 5 koch points (done for us by the line object) - Point a = l.start(); - Point b = l.kochleft(); - Point c = l.kochmiddle(); - Point d = l.kochright(); - Point e = l.end(); - // Make line segments between all the points and add them - now.add(new KochLine(a,b)); - now.add(new KochLine(b,c)); - now.add(new KochLine(c,d)); - now.add(new KochLine(d,e)); - } - return now; - } - -} - - -// A class to describe one line segment in the fractal -// Includes methods to calculate midpoints along the line according to the Koch algorithm - -class KochLine { - - // Two points, - // a is the "left" point and - // b is the "right point - Point a,b; - - KochLine(Point a_, Point b_) { - a = a_.copy(); - b = b_.copy(); - } - - void render() { - stroke(255); - line(a.x,a.y,b.x,b.y); - } - - Point start() { - return a.copy(); - } - - Point end() { - return b.copy(); - } - - // This is easy, just 1/3 of the way - Point kochleft() - { - float x = a.x + (b.x - a.x) / 3f; - float y = a.y + (b.y - a.y) / 3f; - return new Point(x,y); - } - - // More complicated, have to use a little trig to figure out where this point is! - Point kochmiddle() - { - float x = a.x + 0.5f * (b.x - a.x) + (sin(radians(60))*(b.y-a.y)) / 3; - float y = a.y + 0.5f * (b.y - a.y) - (sin(radians(60))*(b.x-a.x)) / 3; - return new Point(x,y); - } - - // Easy, just 2/3 of the way - Point kochright() - { - float x = a.x + 2*(b.x - a.x) / 3f; - float y = a.y + 2*(b.y - a.y) / 3f; - return new Point(x,y); - } - -} - -class Point { - float x,y; - - Point(float x_, float y_) { - x = x_; - y = y_; - } - - Point copy() { - return new Point(x,y); - } -} - diff --git a/android/examples/Topics/Fractals and L-Systems/Koch/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/Koch/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/Koch/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.java b/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.java deleted file mode 100644 index 61353d360..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.java +++ /dev/null @@ -1,95 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Mandelbrot extends PApplet { - -/** - * The Mandelbrot Set - * by Daniel Shiffman. - * - * Simple rendering of the Mandelbrot set. - */ - -// Establish a range of values on the complex plane -// A different range will allow us to "zoom" in or out on the fractal -// float xmin = -1.5; float ymin = -.1; float wh = 0.15; -float xmin = -2.5f; -float ymin = -2; -float wh = 4; - -public void setup() { - size(200, 200); - noLoop(); - background(0); -} - -public void draw() { - - loadPixels(); - - // Maximum number of iterations for each point on the complex plane - int maxiterations = 200; - - // x goes from xmin to xmax - float xmax = xmin + wh; - // y goes from ymin to ymax - float ymax = ymin + wh; - - // Calculate amount we increment x,y for each pixel - float dx = (xmax - xmin) / (width); - float dy = (ymax - ymin) / (height); - - // Start y - float y = ymin; - for(int j = 0; j < height; j++) { - // Start x - float x = xmin; - for(int i = 0; i < width; i++) { - - // Now we test, as we iterate z = z^2 + cm does z tend towards infinity? - float a = x; - float b = y; - int n = 0; - while (n < maxiterations) { - float aa = a * a; - float bb = b * b; - float twoab = 2.0f * a * b; - a = aa - bb + x; - b = twoab + y; - // Infinty in our finite world is simple, let's just consider it 16 - if(aa + bb > 16.0f) { - break; // Bail - } - n++; - } - - // We color each pixel based on how long it takes to get to infinity - // If we never got there, let's pick the color black - if (n == maxiterations) { - pixels[i+j*width] = 0; - } else { - // Gosh, we could make fancy colors here if we wanted - pixels[i+j*width] = color(n*16 % 255); - } - x += dx; - } - y += dy; - } - updatePixels(); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Mandelbrot" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.pde b/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.pde deleted file mode 100644 index f38307cac..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/Mandelbrot.pde +++ /dev/null @@ -1,75 +0,0 @@ -/** - * The Mandelbrot Set - * by Daniel Shiffman. - * - * Simple rendering of the Mandelbrot set. - */ - -// Establish a range of values on the complex plane -// A different range will allow us to "zoom" in or out on the fractal -// float xmin = -1.5; float ymin = -.1; float wh = 0.15; -float xmin = -2.5; -float ymin = -2; -float wh = 4; - -void setup() { - size(200, 200); - noLoop(); - background(0); -} - -void draw() { - - loadPixels(); - - // Maximum number of iterations for each point on the complex plane - int maxiterations = 200; - - // x goes from xmin to xmax - float xmax = xmin + wh; - // y goes from ymin to ymax - float ymax = ymin + wh; - - // Calculate amount we increment x,y for each pixel - float dx = (xmax - xmin) / (width); - float dy = (ymax - ymin) / (height); - - // Start y - float y = ymin; - for(int j = 0; j < height; j++) { - // Start x - float x = xmin; - for(int i = 0; i < width; i++) { - - // Now we test, as we iterate z = z^2 + cm does z tend towards infinity? - float a = x; - float b = y; - int n = 0; - while (n < maxiterations) { - float aa = a * a; - float bb = b * b; - float twoab = 2.0 * a * b; - a = aa - bb + x; - b = twoab + y; - // Infinty in our finite world is simple, let's just consider it 16 - if(aa + bb > 16.0) { - break; // Bail - } - n++; - } - - // We color each pixel based on how long it takes to get to infinity - // If we never got there, let's pick the color black - if (n == maxiterations) { - pixels[i+j*width] = 0; - } else { - // Gosh, we could make fancy colors here if we wanted - pixels[i+j*width] = color(n*16 % 255); - } - x += dx; - } - y += dy; - } - updatePixels(); -} - diff --git a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/Mandelbrot/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/LSystem.pde b/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/LSystem.pde deleted file mode 100644 index 10e694d12..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/LSystem.pde +++ /dev/null @@ -1,76 +0,0 @@ -class LSystem -{ - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - axiom = "F"; - rule = "F+F-F"; - startLength = 90.0; - theta = radians(120.0); - reset(); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} - - diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.java b/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.java deleted file mode 100644 index 1e12287ba..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.java +++ /dev/null @@ -1,220 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class PenroseSnowflake extends PApplet { - -/** - * Penrose Snowflake L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - -PenroseSnowflakeLSystem ps; - -public void setup() { - size(640, 360); - stroke(255); - noFill(); - smooth(); - ps = new PenroseSnowflakeLSystem(); - ps.simulate(4); -} - -public void draw() { - background(0); - ps.render(); -} - - -class LSystem -{ - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - axiom = "F"; - rule = "F+F-F"; - startLength = 90.0f; - theta = radians(120.0f); - reset(); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - public void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - public String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6f; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} - - -class PenroseSnowflakeLSystem extends LSystem { - - String ruleF; - - PenroseSnowflakeLSystem() { - axiom = "F3-F3-F3-F3-F"; - ruleF = "F3-F3-F45-F++F3-F"; - startLength = 450.0f; - theta = radians(18); - reset(); - } - - public void useRule(String r_) { - rule = r_; - } - - public void useAxiom(String a_) { - axiom = a_; - } - - public void useLength(float l_) { - startLength = l_; - } - - public void useTheta(float t_) { - theta = radians(t_); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width, height); - int repeats = 1; - - steps += 3; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - for (int j = 0; j < repeats; j++) { - line(0,0,0, -drawLength); - translate(0, -drawLength); - } - repeats = 1; - } - else if (step == '+') { - for (int j = 0; j < repeats; j++) { - rotate(theta); - } - repeats = 1; - } - else if (step == '-') { - for (int j =0; j < repeats; j++) { - rotate(-theta); - } - repeats = 1; - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - else if ( (step >= 48) && (step <= 57) ) { - repeats += step - 48; - } - } - } - - - public String iterate(String prod_, String rule_) { - String newProduction = ""; - for (int i = 0; i < prod_.length(); i++) { - char step = production.charAt(i); - if (step == 'F') { - newProduction = newProduction + ruleF; - } - else { - if (step != 'F') { - newProduction = newProduction + step; - } - } - } - drawLength = drawLength * 0.4f; - generations++; - return newProduction; - } - -} - - static public void main(String args[]) { - PApplet.main(new String[] { "PenroseSnowflake" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.pde b/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.pde deleted file mode 100644 index 8fe1c9393..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflake.pde +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Penrose Snowflake L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - -PenroseSnowflakeLSystem ps; - -void setup() { - size(640, 360); - stroke(255); - noFill(); - smooth(); - ps = new PenroseSnowflakeLSystem(); - ps.simulate(4); -} - -void draw() { - background(0); - ps.render(); -} - - diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflakeLSystem.pde b/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflakeLSystem.pde deleted file mode 100644 index df1f775b0..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/PenroseSnowflakeLSystem.pde +++ /dev/null @@ -1,100 +0,0 @@ -class PenroseSnowflakeLSystem extends LSystem { - - String ruleF; - - PenroseSnowflakeLSystem() { - axiom = "F3-F3-F3-F3-F"; - ruleF = "F3-F3-F45-F++F3-F"; - startLength = 450.0; - theta = radians(18); - reset(); - } - - void useRule(String r_) { - rule = r_; - } - - void useAxiom(String a_) { - axiom = a_; - } - - void useLength(float l_) { - startLength = l_; - } - - void useTheta(float t_) { - theta = radians(t_); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width, height); - int repeats = 1; - - steps += 3; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - for (int j = 0; j < repeats; j++) { - line(0,0,0, -drawLength); - translate(0, -drawLength); - } - repeats = 1; - } - else if (step == '+') { - for (int j = 0; j < repeats; j++) { - rotate(theta); - } - repeats = 1; - } - else if (step == '-') { - for (int j =0; j < repeats; j++) { - rotate(-theta); - } - repeats = 1; - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - else if ( (step >= 48) && (step <= 57) ) { - repeats += step - 48; - } - } - } - - - String iterate(String prod_, String rule_) { - String newProduction = ""; - for (int i = 0; i < prod_.length(); i++) { - char step = production.charAt(i); - if (step == 'F') { - newProduction = newProduction + ruleF; - } - else { - if (step != 'F') { - newProduction = newProduction + step; - } - } - } - drawLength = drawLength * 0.4; - generations++; - return newProduction; - } - -} diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/PenroseSnowflake/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/LSystem.pde b/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/LSystem.pde deleted file mode 100644 index 8f00ddaf5..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/LSystem.pde +++ /dev/null @@ -1,74 +0,0 @@ -class LSystem -{ - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - axiom = "F"; - rule = "F+F-F"; - startLength = 190.0; - theta = radians(120.0); - reset(); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseLSystem.pde b/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseLSystem.pde deleted file mode 100644 index 16a7f1c43..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseLSystem.pde +++ /dev/null @@ -1,128 +0,0 @@ -class PenroseLSystem extends LSystem { - - int steps = 0; - float somestep = 0.1; - String ruleW; - String ruleX; - String ruleY; - String ruleZ; - - PenroseLSystem() { - axiom = "[X]++[X]++[X]++[X]++[X]"; - ruleW = "YF++ZF4-XF[-YF4-WF]++"; - ruleX = "+YF--ZF[3-WF--XF]+"; - ruleY = "-WF++XF[+++YF++ZF]-"; - ruleZ = "--YF++++WF[+ZF++++XF]--XF"; - startLength = 460.0; - theta = radians(36); - reset(); - } - - void useRule(String r_) { - rule = r_; - } - - void useAxiom(String a_) { - axiom = a_; - } - - void useLength(float l_) { - startLength = l_; - } - - void useTheta(float t_) { - theta = radians(t_); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width/2, height/2); - int pushes = 0; - int repeats = 1; - steps += 12; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - stroke(255, 60); - for (int j = 0; j < repeats; j++) { - line(0, 0, 0, -drawLength); - noFill(); - translate(0, -drawLength); - } - repeats = 1; - } - else if (step == '+') { - for (int j = 0; j < repeats; j++) { - rotate(theta); - } - repeats = 1; - } - else if (step == '-') { - for (int j =0; j < repeats; j++) { - rotate(-theta); - } - repeats = 1; - } - else if (step == '[') { - pushes++; - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - pushes--; - } - else if ( (step >= 48) && (step <= 57) ) { - repeats = (int)step - 48; - } - } - - // Unpush if we need too - while (pushes > 0) { - popMatrix(); - pushes--; - } - } - - String iterate(String prod_, String rule_) { - String newProduction = ""; - for (int i = 0; i < prod_.length(); i++) { - char step = production.charAt(i); - if (step == 'W') { - newProduction = newProduction + ruleW; - } - else if (step == 'X') { - newProduction = newProduction + ruleX; - } - else if (step == 'Y') { - newProduction = newProduction + ruleY; - } - else if (step == 'Z') { - newProduction = newProduction + ruleZ; - } - else { - if (step != 'F') { - newProduction = newProduction + step; - } - } - } - - drawLength = drawLength * 0.5; - generations++; - return newProduction; - } - -} - diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.java b/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.java deleted file mode 100644 index e52f3b6bc..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.java +++ /dev/null @@ -1,250 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class PenroseTile extends PApplet { - -/** - * Penrose Tile L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - -PenroseLSystem ds; - -public void setup() -{ - size(640, 360); - smooth(); - ds = new PenroseLSystem(); - ds.simulate(4); -} - -public void draw() -{ - background(0); - ds.render(); -} - - - - - - -class LSystem -{ - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - axiom = "F"; - rule = "F+F-F"; - startLength = 190.0f; - theta = radians(120.0f); - reset(); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - public void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - public String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6f; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} -class PenroseLSystem extends LSystem { - - int steps = 0; - float somestep = 0.1f; - String ruleW; - String ruleX; - String ruleY; - String ruleZ; - - PenroseLSystem() { - axiom = "[X]++[X]++[X]++[X]++[X]"; - ruleW = "YF++ZF4-XF[-YF4-WF]++"; - ruleX = "+YF--ZF[3-WF--XF]+"; - ruleY = "-WF++XF[+++YF++ZF]-"; - ruleZ = "--YF++++WF[+ZF++++XF]--XF"; - startLength = 460.0f; - theta = radians(36); - reset(); - } - - public void useRule(String r_) { - rule = r_; - } - - public void useAxiom(String a_) { - axiom = a_; - } - - public void useLength(float l_) { - startLength = l_; - } - - public void useTheta(float t_) { - theta = radians(t_); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width/2, height/2); - int pushes = 0; - int repeats = 1; - steps += 12; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - stroke(255, 60); - for (int j = 0; j < repeats; j++) { - line(0, 0, 0, -drawLength); - noFill(); - translate(0, -drawLength); - } - repeats = 1; - } - else if (step == '+') { - for (int j = 0; j < repeats; j++) { - rotate(theta); - } - repeats = 1; - } - else if (step == '-') { - for (int j =0; j < repeats; j++) { - rotate(-theta); - } - repeats = 1; - } - else if (step == '[') { - pushes++; - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - pushes--; - } - else if ( (step >= 48) && (step <= 57) ) { - repeats = (int)step - 48; - } - } - - // Unpush if we need too - while (pushes > 0) { - popMatrix(); - pushes--; - } - } - - public String iterate(String prod_, String rule_) { - String newProduction = ""; - for (int i = 0; i < prod_.length(); i++) { - char step = production.charAt(i); - if (step == 'W') { - newProduction = newProduction + ruleW; - } - else if (step == 'X') { - newProduction = newProduction + ruleX; - } - else if (step == 'Y') { - newProduction = newProduction + ruleY; - } - else if (step == 'Z') { - newProduction = newProduction + ruleZ; - } - else { - if (step != 'F') { - newProduction = newProduction + step; - } - } - } - - drawLength = drawLength * 0.5f; - generations++; - return newProduction; - } - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "PenroseTile" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.pde b/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.pde deleted file mode 100644 index 1cbeb439c..000000000 --- a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/PenroseTile.pde +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Penrose Tile L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - -PenroseLSystem ds; - -void setup() -{ - size(640, 360); - smooth(); - ds = new PenroseLSystem(); - ds.simulate(4); -} - -void draw() -{ - background(0); - ds.render(); -} - - - - - - diff --git a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/PenroseTile/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/LSystem.pde b/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/LSystem.pde deleted file mode 100644 index 2adcabcd5..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/LSystem.pde +++ /dev/null @@ -1,76 +0,0 @@ -class LSystem { - - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - - axiom = "F"; - rule = "F+F-F"; - startLength = 90.0; - theta = radians(120.0); - reset(); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} - diff --git a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.java b/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.java deleted file mode 100644 index 7a61a05cf..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.java +++ /dev/null @@ -1,190 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Pentigree extends PApplet { - -/** - * Pentigree L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - - -PentigreeLSystem ps; - -public void setup() { - size(640, 360); - smooth(); - ps = new PentigreeLSystem(); - ps.simulate(3); -} - -public void draw() { - background(0); - ps.render(); -} - - -class LSystem { - - int steps = 0; - - String axiom; - String rule; - String production; - - float startLength; - float drawLength; - float theta; - - int generations; - - LSystem() { - - axiom = "F"; - rule = "F+F-F"; - startLength = 90.0f; - theta = radians(120.0f); - reset(); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width/2, height/2); - steps += 5; - if (steps > production.length()) { - steps = production.length(); - } - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - rect(0, 0, -drawLength, -drawLength); - noFill(); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - - public void simulate(int gen) { - while (getAge() < gen) { - production = iterate(production, rule); - } - } - - public String iterate(String prod_, String rule_) { - drawLength = drawLength * 0.6f; - generations++; - String newProduction = prod_; - newProduction = newProduction.replaceAll("F", rule_); - return newProduction; - } -} - -class PentigreeLSystem extends LSystem { - - int steps = 0; - float somestep = 0.1f; - float xoff = 0.01f; - - PentigreeLSystem() { - axiom = "F-F-F-F-F"; - rule = "F-F++F+F-F-F"; - startLength = 60.0f; - theta = radians(72); - reset(); - } - - public void useRule(String r_) { - rule = r_; - } - - public void useAxiom(String a_) { - axiom = a_; - } - - public void useLength(float l_) { - startLength = l_; - } - - public void useTheta(float t_) { - theta = radians(t_); - } - - public void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - public int getAge() { - return generations; - } - - public void render() { - translate(width/4, height/2); - steps += 3; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - noFill(); - stroke(255); - line(0, 0, 0, -drawLength); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Pentigree" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.pde b/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.pde deleted file mode 100644 index be0d3fb77..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/Pentigree.pde +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Pentigree L-System - * by Geraldine Sarmiento (NYU ITP). - * - * This code was based on Patrick Dwyer's L-System class. - */ - - -PentigreeLSystem ps; - -void setup() { - size(640, 360); - smooth(); - ps = new PentigreeLSystem(); - ps.simulate(3); -} - -void draw() { - background(0); - ps.render(); -} - - diff --git a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/PentigreeLSystem.pde b/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/PentigreeLSystem.pde deleted file mode 100644 index a377c016d..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/PentigreeLSystem.pde +++ /dev/null @@ -1,71 +0,0 @@ -class PentigreeLSystem extends LSystem { - - int steps = 0; - float somestep = 0.1; - float xoff = 0.01; - - PentigreeLSystem() { - axiom = "F-F-F-F-F"; - rule = "F-F++F+F-F-F"; - startLength = 60.0; - theta = radians(72); - reset(); - } - - void useRule(String r_) { - rule = r_; - } - - void useAxiom(String a_) { - axiom = a_; - } - - void useLength(float l_) { - startLength = l_; - } - - void useTheta(float t_) { - theta = radians(t_); - } - - void reset() { - production = axiom; - drawLength = startLength; - generations = 0; - } - - int getAge() { - return generations; - } - - void render() { - translate(width/4, height/2); - steps += 3; - if (steps > production.length()) { - steps = production.length(); - } - - for (int i = 0; i < steps; i++) { - char step = production.charAt(i); - if (step == 'F') { - noFill(); - stroke(255); - line(0, 0, 0, -drawLength); - translate(0, -drawLength); - } - else if (step == '+') { - rotate(theta); - } - else if (step == '-') { - rotate(-theta); - } - else if (step == '[') { - pushMatrix(); - } - else if (step == ']') { - popMatrix(); - } - } - } - -} diff --git a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/Pentigree/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.java b/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.java deleted file mode 100644 index ce366e143..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.java +++ /dev/null @@ -1,79 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Tree extends PApplet { - -/** - * Recursive Tree - * by Daniel Shiffman. - * - * Renders a simple tree-like structure via recursion - * Branching angle calculated as a function of horizontal mouse location - */ - -float theta; - -public void setup() { - size(640, 360); - smooth(); -} - -public void draw() { - background(0); - frameRate(30); - stroke(255); - // Let's pick an angle 0 to 90 degrees based on the mouse position - float a = (mouseX / (float) width) * 90f; - // Convert it to radians - theta = radians(a); - // Start the tree from the bottom of the screen - translate(width/2,height); - // Draw a line 120 pixels - line(0,0,0,-120); - // Move to the end of that line - translate(0,-120); - // Start the recursive branching! - branch(120); - -} - -public void branch(float h) { - // Each branch will be 2/3rds the size of the previous one - h *= 0.66f; - - // All recursive functions must have an exit condition!!!! - // Here, ours is when the length of the branch is 2 pixels or less - if (h > 2) { - pushMatrix(); // Save the current state of transformation (i.e. where are we now) - rotate(theta); // Rotate by theta - line(0, 0, 0, -h); // Draw the branch - translate(0, -h); // Move to the end of the branch - branch(h); // Ok, now call myself to draw two new branches!! - popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state - - // Repeat the same thing, only branch off to the "left" this time! - pushMatrix(); - rotate(-theta); - line(0, 0, 0, -h); - translate(0, -h); - branch(h); - popMatrix(); - } -} - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Tree" }); - } -} diff --git a/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.pde b/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.pde deleted file mode 100644 index 5ee6440f9..000000000 --- a/android/examples/Topics/Fractals and L-Systems/Tree/applet/Tree.pde +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Recursive Tree - * by Daniel Shiffman. - * - * Renders a simple tree-like structure via recursion - * Branching angle calculated as a function of horizontal mouse location - */ - -float theta; - -void setup() { - size(640, 360); - smooth(); -} - -void draw() { - background(0); - frameRate(30); - stroke(255); - // Let's pick an angle 0 to 90 degrees based on the mouse position - float a = (mouseX / (float) width) * 90f; - // Convert it to radians - theta = radians(a); - // Start the tree from the bottom of the screen - translate(width/2,height); - // Draw a line 120 pixels - line(0,0,0,-120); - // Move to the end of that line - translate(0,-120); - // Start the recursive branching! - branch(120); - -} - -void branch(float h) { - // Each branch will be 2/3rds the size of the previous one - h *= 0.66; - - // All recursive functions must have an exit condition!!!! - // Here, ours is when the length of the branch is 2 pixels or less - if (h > 2) { - pushMatrix(); // Save the current state of transformation (i.e. where are we now) - rotate(theta); // Rotate by theta - line(0, 0, 0, -h); // Draw the branch - translate(0, -h); // Move to the end of the branch - branch(h); // Ok, now call myself to draw two new branches!! - popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state - - // Repeat the same thing, only branch off to the "left" this time! - pushMatrix(); - rotate(-theta); - line(0, 0, 0, -h); - translate(0, -h); - branch(h); - popMatrix(); - } -} - - diff --git a/android/examples/Topics/Fractals and L-Systems/Tree/applet/loading.gif b/android/examples/Topics/Fractals and L-Systems/Tree/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Fractals and L-Systems/Tree/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/Button/applet/Button.java b/android/examples/Topics/GUI/Button/applet/Button.java deleted file mode 100644 index 358745791..000000000 --- a/android/examples/Topics/GUI/Button/applet/Button.java +++ /dev/null @@ -1,120 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Button extends PApplet { - -/** - * Button. - * - * Click on one of the colored squares in the - * center of the image to change the color of - * the background. - */ - -int rectX, rectY; // Position of square button -int circleX, circleY; // Position of circle button -int rectSize = 50; // Diameter of rect -int circleSize = 53; // Diameter of circle -int rectColor, circleColor, baseColor; -int rectHighlight, circleHighlight; -int currentColor; -boolean rectOver = false; -boolean circleOver = false; - -public void setup() -{ - size(200, 200); - smooth(); - rectColor = color(0); - rectHighlight = color(51); - circleColor = color(255); - circleHighlight = color(204); - baseColor = color(102); - currentColor = baseColor; - circleX = width/2+circleSize/2+10; - circleY = height/2; - rectX = width/2-rectSize-10; - rectY = height/2-rectSize/2; - ellipseMode(CENTER); -} - -public void draw() -{ - update(mouseX, mouseY); - background(currentColor); - - if(rectOver) { - fill(rectHighlight); - } else { - fill(rectColor); - } - stroke(255); - rect(rectX, rectY, rectSize, rectSize); - - if(circleOver) { - fill(circleHighlight); - } else { - fill(circleColor); - } - stroke(0); - ellipse(circleX, circleY, circleSize, circleSize); -} - -public void update(int x, int y) -{ - if( overCircle(circleX, circleY, circleSize) ) { - circleOver = true; - rectOver = false; - } else if ( overRect(rectX, rectY, rectSize, rectSize) ) { - rectOver = true; - circleOver = false; - } else { - circleOver = rectOver = false; - } -} - -public void mousePressed() -{ - if(circleOver) { - currentColor = circleColor; - } - if(rectOver) { - currentColor = rectColor; - } -} - -public boolean overRect(int x, int y, int width, int height) -{ - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -public boolean overCircle(int x, int y, int diameter) -{ - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } else { - return false; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Button" }); - } -} diff --git a/android/examples/Topics/GUI/Button/applet/Button.pde b/android/examples/Topics/GUI/Button/applet/Button.pde deleted file mode 100644 index fe477b83f..000000000 --- a/android/examples/Topics/GUI/Button/applet/Button.pde +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Button. - * - * Click on one of the colored squares in the - * center of the image to change the color of - * the background. - */ - -int rectX, rectY; // Position of square button -int circleX, circleY; // Position of circle button -int rectSize = 50; // Diameter of rect -int circleSize = 53; // Diameter of circle -color rectColor, circleColor, baseColor; -color rectHighlight, circleHighlight; -color currentColor; -boolean rectOver = false; -boolean circleOver = false; - -void setup() -{ - size(200, 200); - smooth(); - rectColor = color(0); - rectHighlight = color(51); - circleColor = color(255); - circleHighlight = color(204); - baseColor = color(102); - currentColor = baseColor; - circleX = width/2+circleSize/2+10; - circleY = height/2; - rectX = width/2-rectSize-10; - rectY = height/2-rectSize/2; - ellipseMode(CENTER); -} - -void draw() -{ - update(mouseX, mouseY); - background(currentColor); - - if(rectOver) { - fill(rectHighlight); - } else { - fill(rectColor); - } - stroke(255); - rect(rectX, rectY, rectSize, rectSize); - - if(circleOver) { - fill(circleHighlight); - } else { - fill(circleColor); - } - stroke(0); - ellipse(circleX, circleY, circleSize, circleSize); -} - -void update(int x, int y) -{ - if( overCircle(circleX, circleY, circleSize) ) { - circleOver = true; - rectOver = false; - } else if ( overRect(rectX, rectY, rectSize, rectSize) ) { - rectOver = true; - circleOver = false; - } else { - circleOver = rectOver = false; - } -} - -void mousePressed() -{ - if(circleOver) { - currentColor = circleColor; - } - if(rectOver) { - currentColor = rectColor; - } -} - -boolean overRect(int x, int y, int width, int height) -{ - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -boolean overCircle(int x, int y, int diameter) -{ - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } else { - return false; - } -} diff --git a/android/examples/Topics/GUI/Button/applet/loading.gif b/android/examples/Topics/GUI/Button/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/Button/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/Buttons/applet/Buttons.java b/android/examples/Topics/GUI/Buttons/applet/Buttons.java deleted file mode 100644 index 04532f11e..000000000 --- a/android/examples/Topics/GUI/Buttons/applet/Buttons.java +++ /dev/null @@ -1,240 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Buttons extends PApplet { - -/** - * Buttons. - * - * Click on one of the shapes to change - * the background color. This example - * demonstates a class for buttons. - */ - -int currentcolor; - -CircleButton circle1, circle2, circle3; -RectButton rect1, rect2; - -boolean locked = false; - -public void setup() -{ - size(200, 200); - smooth(); - - int baseColor = color(102); - currentcolor = baseColor; - - // Define and create circle button - int buttoncolor = color(204); - int highlight = color(153); - ellipseMode(CENTER); - circle1 = new CircleButton(30, 100, 100, buttoncolor, highlight); - - // Define and create circle button - buttoncolor = color(204); - highlight = color(153); - circle2 = new CircleButton(130, 110, 24, buttoncolor, highlight); - - // Define and create circle button - buttoncolor = color(153); - highlight = color(102); - circle3 = new CircleButton(130, 140, 24, buttoncolor, highlight); - - // Define and create rectangle button - buttoncolor = color(102); - highlight = color(51); - rect1 = new RectButton(150, 20, 100, buttoncolor, highlight); - - // Define and create rectangle button - buttoncolor = color(51); - highlight = color(0); - rect2 = new RectButton(90, 20, 50, buttoncolor, highlight); -} - -public void draw() -{ - background(currentcolor); - stroke(255); - update(mouseX, mouseY); - circle1.display(); - circle2.display(); - circle3.display(); - rect1.display(); - rect2.display(); -} - -public void update(int x, int y) -{ - if(locked == false) { - circle1.update(); - circle2.update(); - circle3.update(); - rect1.update(); - rect2.update(); - } - else { - locked = false; - } - - if(mousePressed) { - if(circle1.pressed()) { - currentcolor = circle1.basecolor; - } - else if(circle2.pressed()) { - currentcolor = circle2.basecolor; - } - else if(circle3.pressed()) { - currentcolor = circle3.basecolor; - } - else if(rect1.pressed()) { - currentcolor = rect1.basecolor; - } - else if(rect2.pressed()) { - currentcolor = rect2.basecolor; - } - } -} - - -class Button -{ - int x, y; - int size; - int basecolor, highlightcolor; - int currentcolor; - boolean over = false; - boolean pressed = false; - - public void update() - { - if(over()) { - currentcolor = highlightcolor; - } - else { - currentcolor = basecolor; - } - } - - public boolean pressed() - { - if(over) { - locked = true; - return true; - } - else { - locked = false; - return false; - } - } - - public boolean over() - { - return true; - } - - public boolean overRect(int x, int y, int width, int height) - { - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } - else { - return false; - } - } - - public boolean overCircle(int x, int y, int diameter) - { - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } - else { - return false; - } - } - -} - -class CircleButton extends Button -{ - CircleButton(int ix, int iy, int isize, int icolor, int ihighlight) - { - x = ix; - y = iy; - size = isize; - basecolor = icolor; - highlightcolor = ihighlight; - currentcolor = basecolor; - } - - public boolean over() - { - if( overCircle(x, y, size) ) { - over = true; - return true; - } - else { - over = false; - return false; - } - } - - public void display() - { - stroke(255); - fill(currentcolor); - ellipse(x, y, size, size); - } -} - -class RectButton extends Button -{ - RectButton(int ix, int iy, int isize, int icolor, int ihighlight) - { - x = ix; - y = iy; - size = isize; - basecolor = icolor; - highlightcolor = ihighlight; - currentcolor = basecolor; - } - - public boolean over() - { - if( overRect(x, y, size, size) ) { - over = true; - return true; - } - else { - over = false; - return false; - } - } - - public void display() - { - stroke(255); - fill(currentcolor); - rect(x, y, size, size); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Buttons" }); - } -} diff --git a/android/examples/Topics/GUI/Buttons/applet/Buttons.pde b/android/examples/Topics/GUI/Buttons/applet/Buttons.pde deleted file mode 100644 index 11f8b0031..000000000 --- a/android/examples/Topics/GUI/Buttons/applet/Buttons.pde +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Buttons. - * - * Click on one of the shapes to change - * the background color. This example - * demonstates a class for buttons. - */ - -color currentcolor; - -CircleButton circle1, circle2, circle3; -RectButton rect1, rect2; - -boolean locked = false; - -void setup() -{ - size(200, 200); - smooth(); - - color baseColor = color(102); - currentcolor = baseColor; - - // Define and create circle button - color buttoncolor = color(204); - color highlight = color(153); - ellipseMode(CENTER); - circle1 = new CircleButton(30, 100, 100, buttoncolor, highlight); - - // Define and create circle button - buttoncolor = color(204); - highlight = color(153); - circle2 = new CircleButton(130, 110, 24, buttoncolor, highlight); - - // Define and create circle button - buttoncolor = color(153); - highlight = color(102); - circle3 = new CircleButton(130, 140, 24, buttoncolor, highlight); - - // Define and create rectangle button - buttoncolor = color(102); - highlight = color(51); - rect1 = new RectButton(150, 20, 100, buttoncolor, highlight); - - // Define and create rectangle button - buttoncolor = color(51); - highlight = color(0); - rect2 = new RectButton(90, 20, 50, buttoncolor, highlight); -} - -void draw() -{ - background(currentcolor); - stroke(255); - update(mouseX, mouseY); - circle1.display(); - circle2.display(); - circle3.display(); - rect1.display(); - rect2.display(); -} - -void update(int x, int y) -{ - if(locked == false) { - circle1.update(); - circle2.update(); - circle3.update(); - rect1.update(); - rect2.update(); - } - else { - locked = false; - } - - if(mousePressed) { - if(circle1.pressed()) { - currentcolor = circle1.basecolor; - } - else if(circle2.pressed()) { - currentcolor = circle2.basecolor; - } - else if(circle3.pressed()) { - currentcolor = circle3.basecolor; - } - else if(rect1.pressed()) { - currentcolor = rect1.basecolor; - } - else if(rect2.pressed()) { - currentcolor = rect2.basecolor; - } - } -} - - -class Button -{ - int x, y; - int size; - color basecolor, highlightcolor; - color currentcolor; - boolean over = false; - boolean pressed = false; - - void update() - { - if(over()) { - currentcolor = highlightcolor; - } - else { - currentcolor = basecolor; - } - } - - boolean pressed() - { - if(over) { - locked = true; - return true; - } - else { - locked = false; - return false; - } - } - - boolean over() - { - return true; - } - - boolean overRect(int x, int y, int width, int height) - { - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } - else { - return false; - } - } - - boolean overCircle(int x, int y, int diameter) - { - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } - else { - return false; - } - } - -} - -class CircleButton extends Button -{ - CircleButton(int ix, int iy, int isize, color icolor, color ihighlight) - { - x = ix; - y = iy; - size = isize; - basecolor = icolor; - highlightcolor = ihighlight; - currentcolor = basecolor; - } - - boolean over() - { - if( overCircle(x, y, size) ) { - over = true; - return true; - } - else { - over = false; - return false; - } - } - - void display() - { - stroke(255); - fill(currentcolor); - ellipse(x, y, size, size); - } -} - -class RectButton extends Button -{ - RectButton(int ix, int iy, int isize, color icolor, color ihighlight) - { - x = ix; - y = iy; - size = isize; - basecolor = icolor; - highlightcolor = ihighlight; - currentcolor = basecolor; - } - - boolean over() - { - if( overRect(x, y, size, size) ) { - over = true; - return true; - } - else { - over = false; - return false; - } - } - - void display() - { - stroke(255); - fill(currentcolor); - rect(x, y, size, size); - } -} - diff --git a/android/examples/Topics/GUI/Buttons/applet/loading.gif b/android/examples/Topics/GUI/Buttons/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/Buttons/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/Handles/applet/Handles.java b/android/examples/Topics/GUI/Handles/applet/Handles.java deleted file mode 100644 index 5aec7ac6f..000000000 --- a/android/examples/Topics/GUI/Handles/applet/Handles.java +++ /dev/null @@ -1,159 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Handles extends PApplet { - -/** - * Handles. - * - * Click and drag the white boxes to change their position. - */ - -Handle[] handles; -int num; - -public void setup() -{ - size(200, 200); - num = height/15; - handles = new Handle[num]; - int hsize = 10; - for(int i=0; i= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -public int lock(int val, int minv, int maxv) -{ - return min(max(val, minv), maxv); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Handles" }); - } -} diff --git a/android/examples/Topics/GUI/Handles/applet/Handles.pde b/android/examples/Topics/GUI/Handles/applet/Handles.pde deleted file mode 100644 index 7036f362a..000000000 --- a/android/examples/Topics/GUI/Handles/applet/Handles.pde +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Handles. - * - * Click and drag the white boxes to change their position. - */ - -Handle[] handles; -int num; - -void setup() -{ - size(200, 200); - num = height/15; - handles = new Handle[num]; - int hsize = 10; - for(int i=0; i= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -int lock(int val, int minv, int maxv) -{ - return min(max(val, minv), maxv); -} diff --git a/android/examples/Topics/GUI/Handles/applet/loading.gif b/android/examples/Topics/GUI/Handles/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/Handles/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/ImageButton/applet/ImageButton.java b/android/examples/Topics/GUI/ImageButton/applet/ImageButton.java deleted file mode 100644 index 70bbf4a35..000000000 --- a/android/examples/Topics/GUI/ImageButton/applet/ImageButton.java +++ /dev/null @@ -1,128 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class ImageButton extends PApplet { - -/** - * Image button. - * - * Loading images and using them to create a button. - */ - - -ImageButtons button; - -public void setup() -{ - size(200, 200); - background(102, 102, 102); - - // Define and create image button - PImage b = loadImage("base.gif"); - PImage r = loadImage("roll.gif"); - PImage d = loadImage("down.gif"); - int x = width/2 - b.width/2; - int y = height/2 - b.height/2; - int w = b.width; - int h = b.height; - button = new ImageButtons(x, y, w, h, b, r, d); -} - -public void draw() -{ - button.update(); - button.display(); -} - -class Button -{ - int x, y; - int w, h; - int basecolor, highlightcolor; - int currentcolor; - boolean over = false; - boolean pressed = false; - - public void pressed() { - if(over && mousePressed) { - pressed = true; - } else { - pressed = false; - } - } - - public boolean overRect(int x, int y, int width, int height) { - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} -} - -class ImageButtons extends Button -{ - PImage base; - PImage roll; - PImage down; - PImage currentimage; - - ImageButtons(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown) - { - x = ix; - y = iy; - w = iw; - h = ih; - base = ibase; - roll = iroll; - down = idown; - currentimage = base; - } - - public void update() - { - over(); - pressed(); - if(pressed) { - currentimage = down; - } else if (over){ - currentimage = roll; - } else { - currentimage = base; - } - } - - public void over() - { - if( overRect(x, y, w, h) ) { - over = true; - } else { - over = false; - } - } - - public void display() - { - image(currentimage, x, y); - } -} - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "ImageButton" }); - } -} diff --git a/android/examples/Topics/GUI/ImageButton/applet/ImageButton.pde b/android/examples/Topics/GUI/ImageButton/applet/ImageButton.pde deleted file mode 100644 index 338cb3d1e..000000000 --- a/android/examples/Topics/GUI/ImageButton/applet/ImageButton.pde +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Image button. - * - * Loading images and using them to create a button. - */ - - -ImageButtons button; - -void setup() -{ - size(200, 200); - background(102, 102, 102); - - // Define and create image button - PImage b = loadImage("base.gif"); - PImage r = loadImage("roll.gif"); - PImage d = loadImage("down.gif"); - int x = width/2 - b.width/2; - int y = height/2 - b.height/2; - int w = b.width; - int h = b.height; - button = new ImageButtons(x, y, w, h, b, r, d); -} - -void draw() -{ - button.update(); - button.display(); -} - -class Button -{ - int x, y; - int w, h; - color basecolor, highlightcolor; - color currentcolor; - boolean over = false; - boolean pressed = false; - - void pressed() { - if(over && mousePressed) { - pressed = true; - } else { - pressed = false; - } - } - - boolean overRect(int x, int y, int width, int height) { - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} -} - -class ImageButtons extends Button -{ - PImage base; - PImage roll; - PImage down; - PImage currentimage; - - ImageButtons(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown) - { - x = ix; - y = iy; - w = iw; - h = ih; - base = ibase; - roll = iroll; - down = idown; - currentimage = base; - } - - void update() - { - over(); - pressed(); - if(pressed) { - currentimage = down; - } else if (over){ - currentimage = roll; - } else { - currentimage = base; - } - } - - void over() - { - if( overRect(x, y, w, h) ) { - over = true; - } else { - over = false; - } - } - - void display() - { - image(currentimage, x, y); - } -} - - - - diff --git a/android/examples/Topics/GUI/ImageButton/applet/loading.gif b/android/examples/Topics/GUI/ImageButton/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/ImageButton/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/Rollover/applet/Rollover.java b/android/examples/Topics/GUI/Rollover/applet/Rollover.java deleted file mode 100644 index 0880b601e..000000000 --- a/android/examples/Topics/GUI/Rollover/applet/Rollover.java +++ /dev/null @@ -1,108 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Rollover extends PApplet { - -/** - * Rollover. - * - * Roll over the colored squares in the center of the image - * to change the color of the outside rectangle. - */ - - -int rectX, rectY; // Position of square button -int circleX, circleY; // Position of circle button -int rectSize = 50; // Diameter of rect -int circleSize = 53; // Diameter of circle - -int rectColor; -int circleColor; -int baseColor; - -boolean rectOver = false; -boolean circleOver = false; - -public void setup() -{ - size(200, 200); - smooth(); - rectColor = color(0); - circleColor = color(255); - baseColor = color(102); - circleX = width/2+circleSize/2+10; - circleY = height/2; - rectX = width/2-rectSize-10; - rectY = height/2-rectSize/2; - ellipseMode(CENTER); -} - -public void draw() -{ - update(mouseX, mouseY); - - noStroke(); - if (rectOver) { - background(rectColor); - } else if (circleOver) { - background(circleColor); - } else { - background(baseColor); - } - - stroke(255); - fill(rectColor); - rect(rectX, rectY, rectSize, rectSize); - stroke(0); - fill(circleColor); - ellipse(circleX, circleY, circleSize, circleSize); -} - -public void update(int x, int y) -{ - if( overCircle(circleX, circleY, circleSize) ) { - circleOver = true; - rectOver = false; - } else if ( overRect(rectX, rectY, rectSize, rectSize) ) { - rectOver = true; - circleOver = false; - } else { - circleOver = rectOver = false; - } -} - -public boolean overRect(int x, int y, int width, int height) -{ - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -public boolean overCircle(int x, int y, int diameter) -{ - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } else { - return false; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Rollover" }); - } -} diff --git a/android/examples/Topics/GUI/Rollover/applet/Rollover.pde b/android/examples/Topics/GUI/Rollover/applet/Rollover.pde deleted file mode 100644 index 4785ec9ac..000000000 --- a/android/examples/Topics/GUI/Rollover/applet/Rollover.pde +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Rollover. - * - * Roll over the colored squares in the center of the image - * to change the color of the outside rectangle. - */ - - -int rectX, rectY; // Position of square button -int circleX, circleY; // Position of circle button -int rectSize = 50; // Diameter of rect -int circleSize = 53; // Diameter of circle - -color rectColor; -color circleColor; -color baseColor; - -boolean rectOver = false; -boolean circleOver = false; - -void setup() -{ - size(200, 200); - smooth(); - rectColor = color(0); - circleColor = color(255); - baseColor = color(102); - circleX = width/2+circleSize/2+10; - circleY = height/2; - rectX = width/2-rectSize-10; - rectY = height/2-rectSize/2; - ellipseMode(CENTER); -} - -void draw() -{ - update(mouseX, mouseY); - - noStroke(); - if (rectOver) { - background(rectColor); - } else if (circleOver) { - background(circleColor); - } else { - background(baseColor); - } - - stroke(255); - fill(rectColor); - rect(rectX, rectY, rectSize, rectSize); - stroke(0); - fill(circleColor); - ellipse(circleX, circleY, circleSize, circleSize); -} - -void update(int x, int y) -{ - if( overCircle(circleX, circleY, circleSize) ) { - circleOver = true; - rectOver = false; - } else if ( overRect(rectX, rectY, rectSize, rectSize) ) { - rectOver = true; - circleOver = false; - } else { - circleOver = rectOver = false; - } -} - -boolean overRect(int x, int y, int width, int height) -{ - if (mouseX >= x && mouseX <= x+width && - mouseY >= y && mouseY <= y+height) { - return true; - } else { - return false; - } -} - -boolean overCircle(int x, int y, int diameter) -{ - float disX = x - mouseX; - float disY = y - mouseY; - if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { - return true; - } else { - return false; - } -} diff --git a/android/examples/Topics/GUI/Rollover/applet/loading.gif b/android/examples/Topics/GUI/Rollover/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/Rollover/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.java b/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.java deleted file mode 100644 index 31b7323c9..000000000 --- a/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.java +++ /dev/null @@ -1,142 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Scrollbar extends PApplet { - -/** - * Scrollbar. - * - * Move the scrollbars left and right to change the positions of the images. - */ - -HScrollbar hs1, hs2; - -PImage top, bottom; // Two image to load -int topWidth, bottomWidth; // The width of the top and bottom images - - -public void setup() -{ - size(200, 200); - noStroke(); - hs1 = new HScrollbar(0, 20, width, 10, 3*5+1); - hs2 = new HScrollbar(0, height-20, width, 10, 3*5+1); - top = loadImage("seedTop.jpg"); - topWidth = top.width; - bottom = loadImage("seedBottom.jpg"); - bottomWidth = bottom.width; -} - -public void draw() -{ - background(255); - - // Get the position of the top scrollbar - // and convert to a value to display the top image - float topPos = hs1.getPos()-width/2; - fill(255); - image(top, width/2-topWidth/2 + topPos*2, 0); - - // Get the position of the bottom scrollbar - // and convert to a value to display the bottom image - float bottomPos = hs2.getPos()-width/2; - fill(255); - image(bottom, width/2-bottomWidth/2 + bottomPos*2, height/2); - - hs1.update(); - hs2.update(); - hs1.display(); - hs2.display(); -} - - -class HScrollbar -{ - int swidth, sheight; // width and height of bar - int xpos, ypos; // x and y position of bar - float spos, newspos; // x position of slider - int sposMin, sposMax; // max and min values of slider - int loose; // how loose/heavy - boolean over; // is the mouse over the slider? - boolean locked; - float ratio; - - HScrollbar (int xp, int yp, int sw, int sh, int l) { - swidth = sw; - sheight = sh; - int widthtoheight = sw - sh; - ratio = (float)sw / (float)widthtoheight; - xpos = xp; - ypos = yp-sheight/2; - spos = xpos + swidth/2 - sheight/2; - newspos = spos; - sposMin = xpos; - sposMax = xpos + swidth - sheight; - loose = l; - } - - public void update() { - if(over()) { - over = true; - } else { - over = false; - } - if(mousePressed && over) { - locked = true; - } - if(!mousePressed) { - locked = false; - } - if(locked) { - newspos = constrain(mouseX-sheight/2, sposMin, sposMax); - } - if(abs(newspos - spos) > 1) { - spos = spos + (newspos-spos)/loose; - } - } - - public int constrain(int val, int minv, int maxv) { - return min(max(val, minv), maxv); - } - - public boolean over() { - if(mouseX > xpos && mouseX < xpos+swidth && - mouseY > ypos && mouseY < ypos+sheight) { - return true; - } else { - return false; - } - } - - public void display() { - fill(255); - rect(xpos, ypos, swidth, sheight); - if(over || locked) { - fill(153, 102, 0); - } else { - fill(102, 102, 102); - } - rect(spos, ypos, sheight, sheight); - } - - public float getPos() { - // Convert spos to be values between - // 0 and the total width of the scrollbar - return spos * ratio; - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Scrollbar" }); - } -} diff --git a/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.pde b/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.pde deleted file mode 100644 index 4647b6095..000000000 --- a/android/examples/Topics/GUI/Scrollbar/applet/Scrollbar.pde +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Scrollbar. - * - * Move the scrollbars left and right to change the positions of the images. - */ - -HScrollbar hs1, hs2; - -PImage top, bottom; // Two image to load -int topWidth, bottomWidth; // The width of the top and bottom images - - -void setup() -{ - size(200, 200); - noStroke(); - hs1 = new HScrollbar(0, 20, width, 10, 3*5+1); - hs2 = new HScrollbar(0, height-20, width, 10, 3*5+1); - top = loadImage("seedTop.jpg"); - topWidth = top.width; - bottom = loadImage("seedBottom.jpg"); - bottomWidth = bottom.width; -} - -void draw() -{ - background(255); - - // Get the position of the top scrollbar - // and convert to a value to display the top image - float topPos = hs1.getPos()-width/2; - fill(255); - image(top, width/2-topWidth/2 + topPos*2, 0); - - // Get the position of the bottom scrollbar - // and convert to a value to display the bottom image - float bottomPos = hs2.getPos()-width/2; - fill(255); - image(bottom, width/2-bottomWidth/2 + bottomPos*2, height/2); - - hs1.update(); - hs2.update(); - hs1.display(); - hs2.display(); -} - - -class HScrollbar -{ - int swidth, sheight; // width and height of bar - int xpos, ypos; // x and y position of bar - float spos, newspos; // x position of slider - int sposMin, sposMax; // max and min values of slider - int loose; // how loose/heavy - boolean over; // is the mouse over the slider? - boolean locked; - float ratio; - - HScrollbar (int xp, int yp, int sw, int sh, int l) { - swidth = sw; - sheight = sh; - int widthtoheight = sw - sh; - ratio = (float)sw / (float)widthtoheight; - xpos = xp; - ypos = yp-sheight/2; - spos = xpos + swidth/2 - sheight/2; - newspos = spos; - sposMin = xpos; - sposMax = xpos + swidth - sheight; - loose = l; - } - - void update() { - if(over()) { - over = true; - } else { - over = false; - } - if(mousePressed && over) { - locked = true; - } - if(!mousePressed) { - locked = false; - } - if(locked) { - newspos = constrain(mouseX-sheight/2, sposMin, sposMax); - } - if(abs(newspos - spos) > 1) { - spos = spos + (newspos-spos)/loose; - } - } - - int constrain(int val, int minv, int maxv) { - return min(max(val, minv), maxv); - } - - boolean over() { - if(mouseX > xpos && mouseX < xpos+swidth && - mouseY > ypos && mouseY < ypos+sheight) { - return true; - } else { - return false; - } - } - - void display() { - fill(255); - rect(xpos, ypos, swidth, sheight); - if(over || locked) { - fill(153, 102, 0); - } else { - fill(102, 102, 102); - } - rect(spos, ypos, sheight, sheight); - } - - float getPos() { - // Convert spos to be values between - // 0 and the total width of the scrollbar - return spos * ratio; - } -} diff --git a/android/examples/Topics/GUI/Scrollbar/applet/loading.gif b/android/examples/Topics/GUI/Scrollbar/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/GUI/Scrollbar/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Image Processing/Blur/applet/Blur.java b/android/examples/Topics/Image Processing/Blur/applet/Blur.java deleted file mode 100644 index 3af44939b..000000000 --- a/android/examples/Topics/Image Processing/Blur/applet/Blur.java +++ /dev/null @@ -1,65 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Blur extends PApplet { - public void setup() {/** - * Blur. - * - * Bluring half of an image by processing it through a - * low-pass filter. - */ - -size(200, 200); -PImage a; // Declare variable "a" of type PImage -a = loadImage("trees.jpg"); // Load the images into the program - -float v = 1.0f/9.0f; -float[][] kernel = { { v, v, v }, - { v, v, v }, - { v, v, v } }; - -size(200, 200); -PImage img = loadImage("trees.jpg"); // Load the original image -image(a, 0, 0); // Displays the image from point (0,0) -img.loadPixels(); -// Create an opaque image of the same size as the original -PImage edgeImg = createImage(img.width, img.height, RGB); -// Loop through every pixel in the image. -for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges - for (int x = 1; x < img.width-1; x++) { // Skip left and right edges - float sum = 0; // Kernel sum for this pixel - for (int ky = -1; ky <= 1; ky++) { - for (int kx = -1; kx <= 1; kx++) { - // Calculate the adjacent pixel for this kernel point - int pos = (y + ky)*width + (x + kx); - // Image is grayscale, red/green/blue are identical - float val = red(img.pixels[pos]); - // Multiply adjacent pixels based on the kernel values - sum += kernel[ky+1][kx+1] * val; - } - } - // For this pixel in the new image, set the gray value - // based on the sum from the kernel - edgeImg.pixels[y*img.width + x] = color(sum); - } -} -// State that there are changes to edgeImg.pixels[] -edgeImg.updatePixels(); -image(edgeImg, 100, 0); // Draw the new image - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "Blur" }); - } -} diff --git a/android/examples/Topics/Image Processing/Blur/applet/Blur.pde b/android/examples/Topics/Image Processing/Blur/applet/Blur.pde deleted file mode 100644 index 0da1288a5..000000000 --- a/android/examples/Topics/Image Processing/Blur/applet/Blur.pde +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Blur. - * - * Bluring half of an image by processing it through a - * low-pass filter. - */ - -size(200, 200); -PImage a; // Declare variable "a" of type PImage -a = loadImage("trees.jpg"); // Load the images into the program - -float v = 1.0/9.0; -float[][] kernel = { { v, v, v }, - { v, v, v }, - { v, v, v } }; - -size(200, 200); -PImage img = loadImage("trees.jpg"); // Load the original image -image(a, 0, 0); // Displays the image from point (0,0) -img.loadPixels(); -// Create an opaque image of the same size as the original -PImage edgeImg = createImage(img.width, img.height, RGB); -// Loop through every pixel in the image. -for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges - for (int x = 1; x < img.width-1; x++) { // Skip left and right edges - float sum = 0; // Kernel sum for this pixel - for (int ky = -1; ky <= 1; ky++) { - for (int kx = -1; kx <= 1; kx++) { - // Calculate the adjacent pixel for this kernel point - int pos = (y + ky)*width + (x + kx); - // Image is grayscale, red/green/blue are identical - float val = red(img.pixels[pos]); - // Multiply adjacent pixels based on the kernel values - sum += kernel[ky+1][kx+1] * val; - } - } - // For this pixel in the new image, set the gray value - // based on the sum from the kernel - edgeImg.pixels[y*img.width + x] = color(sum); - } -} -// State that there are changes to edgeImg.pixels[] -edgeImg.updatePixels(); -image(edgeImg, 100, 0); // Draw the new image diff --git a/android/examples/Topics/Image Processing/Blur/applet/loading.gif b/android/examples/Topics/Image Processing/Blur/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Image Processing/Blur/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Image Processing/Brightness/applet/Brightness.java b/android/examples/Topics/Image Processing/Brightness/applet/Brightness.java deleted file mode 100644 index 373746d0f..000000000 --- a/android/examples/Topics/Image Processing/Brightness/applet/Brightness.java +++ /dev/null @@ -1,66 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Brightness extends PApplet { - -/** - * Brightness - * by Daniel Shiffman. - * - * Adjusts the brightness of part of the image - * Pixels closer to the mouse will appear brighter. - */ - -PImage img; - -public void setup() { - size(200, 200); - frameRate(30); - img = loadImage("wires.jpg"); -} - -public void draw() { - loadPixels(); - for (int x = 0; x < img.width; x++) { - for (int y = 0; y < img.height; y++ ) { - // Calculate the 1D location from a 2D grid - int loc = x + y*img.width; - // Get the R,G,B values from image - float r,g,b; - r = red (img.pixels[loc]); - //g = green (img.pixels[loc]); - //b = blue (img.pixels[loc]); - // Calculate an amount to change brightness based on proximity to the mouse - float maxdist = 50;//dist(0,0,width,height); - float d = dist(x,y,mouseX,mouseY); - float adjustbrightness = 255*(maxdist-d)/maxdist; - r += adjustbrightness; - //g += adjustbrightness; - //b += adjustbrightness; - // Constrain RGB to make sure they are within 0-255 color range - r = constrain(r,0,255); - //g = constrain(g,0,255); - //b = constrain(b,0,255); - // Make a new color and set pixel in the window - //color c = color(r,g,b); - int c = color(r); - pixels[loc] = c; - } - } - updatePixels(); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Brightness" }); - } -} diff --git a/android/examples/Topics/Image Processing/Brightness/applet/Brightness.pde b/android/examples/Topics/Image Processing/Brightness/applet/Brightness.pde deleted file mode 100644 index a046b565d..000000000 --- a/android/examples/Topics/Image Processing/Brightness/applet/Brightness.pde +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Brightness - * by Daniel Shiffman. - * - * Adjusts the brightness of part of the image - * Pixels closer to the mouse will appear brighter. - */ - -PImage img; - -void setup() { - size(200, 200); - frameRate(30); - img = loadImage("wires.jpg"); -} - -void draw() { - loadPixels(); - for (int x = 0; x < img.width; x++) { - for (int y = 0; y < img.height; y++ ) { - // Calculate the 1D location from a 2D grid - int loc = x + y*img.width; - // Get the R,G,B values from image - float r,g,b; - r = red (img.pixels[loc]); - //g = green (img.pixels[loc]); - //b = blue (img.pixels[loc]); - // Calculate an amount to change brightness based on proximity to the mouse - float maxdist = 50;//dist(0,0,width,height); - float d = dist(x,y,mouseX,mouseY); - float adjustbrightness = 255*(maxdist-d)/maxdist; - r += adjustbrightness; - //g += adjustbrightness; - //b += adjustbrightness; - // Constrain RGB to make sure they are within 0-255 color range - r = constrain(r,0,255); - //g = constrain(g,0,255); - //b = constrain(b,0,255); - // Make a new color and set pixel in the window - //color c = color(r,g,b); - color c = color(r); - pixels[loc] = c; - } - } - updatePixels(); -} diff --git a/android/examples/Topics/Image Processing/Brightness/applet/loading.gif b/android/examples/Topics/Image Processing/Brightness/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Image Processing/Brightness/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Image Processing/Convolution/applet/Convolution.java b/android/examples/Topics/Image Processing/Convolution/applet/Convolution.java deleted file mode 100644 index 207fa8149..000000000 --- a/android/examples/Topics/Image Processing/Convolution/applet/Convolution.java +++ /dev/null @@ -1,94 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Convolution extends PApplet { - -/** - * Convolution - * by Daniel Shiffman. - * - * Applies a convolution matrix to a portion of the index. - * Move mouse to apply filter to different parts of the image. - */ - -PImage img; -int w = 80; - -// It's possible to convolve the image with -// many different matrices - - float[][] matrix = { { -1, -1, -1 }, - { -1, 9, -1 }, - { -1, -1, -1 } }; - -public void setup() { - size(200, 200); - frameRate(30); - img = loadImage("end.jpg"); -} - -public void draw() { - // We're only going to process a portion of the image - // so let's set the whole image as the background first - image(img,0,0); - // Where is the small rectangle we will process - int xstart = constrain(mouseX-w/2,0,img.width); - int ystart = constrain(mouseY-w/2,0,img.height); - int xend = constrain(mouseX+w/2,0,img.width); - int yend = constrain(mouseY+w/2,0,img.height); - int matrixsize = 3; - loadPixels(); - // Begin our loop for every pixel - for (int x = xstart; x < xend; x++) { - for (int y = ystart; y < yend; y++ ) { - int c = convolution(x,y,matrix,matrixsize,img); - int loc = x + y*img.width; - pixels[loc] = c; - } - } - updatePixels(); -} - -public int convolution(int x, int y, float[][] matrix,int matrixsize, PImage img) -{ - float rtotal = 0.0f; - float gtotal = 0.0f; - float btotal = 0.0f; - int offset = matrixsize / 2; - for (int i = 0; i < matrixsize; i++){ - for (int j= 0; j < matrixsize; j++){ - // What pixel are we testing - int xloc = x+i-offset; - int yloc = y+j-offset; - int loc = xloc + img.width*yloc; - // Make sure we haven't walked off our image, we could do better here - loc = constrain(loc,0,img.pixels.length-1); - // Calculate the convolution - rtotal += (red(img.pixels[loc]) * matrix[i][j]); - gtotal += (green(img.pixels[loc]) * matrix[i][j]); - btotal += (blue(img.pixels[loc]) * matrix[i][j]); - } - } - // Make sure RGB is within range - rtotal = constrain(rtotal,0,255); - gtotal = constrain(gtotal,0,255); - btotal = constrain(btotal,0,255); - // Return the resulting color - return color(rtotal,gtotal,btotal); -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Convolution" }); - } -} diff --git a/android/examples/Topics/Image Processing/Convolution/applet/Convolution.pde b/android/examples/Topics/Image Processing/Convolution/applet/Convolution.pde deleted file mode 100644 index bb3f7eda5..000000000 --- a/android/examples/Topics/Image Processing/Convolution/applet/Convolution.pde +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Convolution - * by Daniel Shiffman. - * - * Applies a convolution matrix to a portion of the index. - * Move mouse to apply filter to different parts of the image. - */ - -PImage img; -int w = 80; - -// It's possible to convolve the image with -// many different matrices - - float[][] matrix = { { -1, -1, -1 }, - { -1, 9, -1 }, - { -1, -1, -1 } }; - -void setup() { - size(200, 200); - frameRate(30); - img = loadImage("end.jpg"); -} - -void draw() { - // We're only going to process a portion of the image - // so let's set the whole image as the background first - image(img,0,0); - // Where is the small rectangle we will process - int xstart = constrain(mouseX-w/2,0,img.width); - int ystart = constrain(mouseY-w/2,0,img.height); - int xend = constrain(mouseX+w/2,0,img.width); - int yend = constrain(mouseY+w/2,0,img.height); - int matrixsize = 3; - loadPixels(); - // Begin our loop for every pixel - for (int x = xstart; x < xend; x++) { - for (int y = ystart; y < yend; y++ ) { - color c = convolution(x,y,matrix,matrixsize,img); - int loc = x + y*img.width; - pixels[loc] = c; - } - } - updatePixels(); -} - -color convolution(int x, int y, float[][] matrix,int matrixsize, PImage img) -{ - float rtotal = 0.0; - float gtotal = 0.0; - float btotal = 0.0; - int offset = matrixsize / 2; - for (int i = 0; i < matrixsize; i++){ - for (int j= 0; j < matrixsize; j++){ - // What pixel are we testing - int xloc = x+i-offset; - int yloc = y+j-offset; - int loc = xloc + img.width*yloc; - // Make sure we haven't walked off our image, we could do better here - loc = constrain(loc,0,img.pixels.length-1); - // Calculate the convolution - rtotal += (red(img.pixels[loc]) * matrix[i][j]); - gtotal += (green(img.pixels[loc]) * matrix[i][j]); - btotal += (blue(img.pixels[loc]) * matrix[i][j]); - } - } - // Make sure RGB is within range - rtotal = constrain(rtotal,0,255); - gtotal = constrain(gtotal,0,255); - btotal = constrain(btotal,0,255); - // Return the resulting color - return color(rtotal,gtotal,btotal); -} - diff --git a/android/examples/Topics/Image Processing/Convolution/applet/loading.gif b/android/examples/Topics/Image Processing/Convolution/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Image Processing/Convolution/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.java b/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.java deleted file mode 100644 index c0fb22967..000000000 --- a/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.java +++ /dev/null @@ -1,60 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class EdgeDetection extends PApplet { - public void setup() {/** - * Edge Detection. - * - * Exposing areas of contrast within an image - * by processing it through a high-pass filter. - */ - -float[][] kernel = { { -1, -1, -1 }, - { -1, 9, -1 }, - { -1, -1, -1 } }; - -size(200, 200); -PImage img = loadImage("house.jpg"); // Load the original image -image(img, 0, 0); // Displays the image from point (0,0) -img.loadPixels(); -// Create an opaque image of the same size as the original -PImage edgeImg = createImage(img.width, img.height, RGB); -// Loop through every pixel in the image. -for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges - for (int x = 1; x < img.width-1; x++) { // Skip left and right edges - float sum = 0; // Kernel sum for this pixel - for (int ky = -1; ky <= 1; ky++) { - for (int kx = -1; kx <= 1; kx++) { - // Calculate the adjacent pixel for this kernel point - int pos = (y + ky)*width + (x + kx); - // Image is grayscale, red/green/blue are identical - float val = red(img.pixels[pos]); - // Multiply adjacent pixels based on the kernel values - sum += kernel[ky+1][kx+1] * val; - } - } - // For this pixel in the new image, set the gray value - // based on the sum from the kernel - edgeImg.pixels[y*img.width + x] = color(sum); - } -} -// State that there are changes to edgeImg.pixels[] -edgeImg.updatePixels(); -image(edgeImg, 100, 0); // Draw the new image - - noLoop(); -} - static public void main(String args[]) { - PApplet.main(new String[] { "EdgeDetection" }); - } -} diff --git a/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.pde b/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.pde deleted file mode 100644 index 65f2aab3c..000000000 --- a/android/examples/Topics/Image Processing/EdgeDetection/applet/EdgeDetection.pde +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Edge Detection. - * - * Exposing areas of contrast within an image - * by processing it through a high-pass filter. - */ - -float[][] kernel = { { -1, -1, -1 }, - { -1, 9, -1 }, - { -1, -1, -1 } }; - -size(200, 200); -PImage img = loadImage("house.jpg"); // Load the original image -image(img, 0, 0); // Displays the image from point (0,0) -img.loadPixels(); -// Create an opaque image of the same size as the original -PImage edgeImg = createImage(img.width, img.height, RGB); -// Loop through every pixel in the image. -for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges - for (int x = 1; x < img.width-1; x++) { // Skip left and right edges - float sum = 0; // Kernel sum for this pixel - for (int ky = -1; ky <= 1; ky++) { - for (int kx = -1; kx <= 1; kx++) { - // Calculate the adjacent pixel for this kernel point - int pos = (y + ky)*width + (x + kx); - // Image is grayscale, red/green/blue are identical - float val = red(img.pixels[pos]); - // Multiply adjacent pixels based on the kernel values - sum += kernel[ky+1][kx+1] * val; - } - } - // For this pixel in the new image, set the gray value - // based on the sum from the kernel - edgeImg.pixels[y*img.width + x] = color(sum); - } -} -// State that there are changes to edgeImg.pixels[] -edgeImg.updatePixels(); -image(edgeImg, 100, 0); // Draw the new image diff --git a/android/examples/Topics/Image Processing/EdgeDetection/applet/loading.gif b/android/examples/Topics/Image Processing/EdgeDetection/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Image Processing/EdgeDetection/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Image Processing/Histogram/applet/Histogram.java b/android/examples/Topics/Image Processing/Histogram/applet/Histogram.java deleted file mode 100644 index f82e93409..000000000 --- a/android/examples/Topics/Image Processing/Histogram/applet/Histogram.java +++ /dev/null @@ -1,67 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Histogram extends PApplet { - public void setup() {/** - * Histogram. - * - * Calculates the histogram of an image. - * A histogram is the frequency distribution - * of the gray levels with the number of pure black values - * displayed on the left and number of pure white values on the right. - */ - -size(200, 200); -colorMode(RGB, width); - -int[] hist = new int[width]; - -// Load an image from the data directory -// Load a different image by modifying the comments -PImage a; -a = loadImage("cdi01_g.jpg"); -image(a, 0, 0); - -// Calculate the histogram -for (int i=0; i maxval) { - maxval = hist[i]; - } -} - -// Normalize the histogram to values between 0 and "height" -for (int i=0; i maxval) { - maxval = hist[i]; - } -} - -// Normalize the histogram to values between 0 and "height" -for (int i=0; i width-1 || signal < 0) { - direction = direction * -1; - } - - if(mousePressed) { - signal = abs(mouseY%height); - } else { - signal += (0.3f*direction); - } - - - if(keyPressed) { - loadPixels(); - for (int i=0; i width-1 || signal < 0) { - direction = direction * -1; - } - - if(mousePressed) { - signal = abs(mouseY%height); - } else { - signal += (0.3*direction); - } - - - if(keyPressed) { - loadPixels(); - for (int i=0; i width*height-1 || signal < 0) { - direction = direction * -1; - } - - if(mousePressed) { - if(mouseY > height-1) { mouseY = height-1; } - if(mouseY < 0) { mouseY = 0; } - signal = mouseY*width+mouseX; - } else { - signal += (0.33f*direction); - } - - if(keyPressed) { - loadPixels(); - for (int i=0; i width*height-1 || signal < 0) { - direction = direction * -1; - } - - if(mousePressed) { - if(mouseY > height-1) { mouseY = height-1; } - if(mouseY < 0) { mouseY = 0; } - signal = mouseY*width+mouseX; - } else { - signal += (0.33*direction); - } - - if(keyPressed) { - loadPixels(); - for (int i=0; i=1; i--) { - positionSegment(i, i-1); - } - for(int i=0; i=1; i--) { - positionSegment(i, i-1); - } - for(int i=0; i width-25 || ballX < 25) { - ballXDirection *= -1; - } - if(ballY > height-25 || ballY < 25) { - ballYDirection *= -1; - } - ellipse(ballX, ballY, 30, 30); - - reachSegment(0, ballX, ballY); - for(int i=1; i=1; i--) { - positionSegment(i, i-1); - } - for(int i=0; i width-25 || ballX < 25) { - ballXDirection *= -1; - } - if(ballY > height-25 || ballY < 25) { - ballYDirection *= -1; - } - ellipse(ballX, ballY, 30, 30); - - reachSegment(0, ballX, ballY); - for(int i=1; i=1; i--) { - positionSegment(i, i-1); - } - for(int i=0; i= x) && (mouseX <= x+55) && - (mouseY >= y-24) && (mouseY <= y)) { - x += random(-5, 5); - y += random(-5, 5); - } - text("tickle", x, y); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Tickle" }); - } -} diff --git a/android/examples/Topics/Interaction/Tickle/applet/Tickle.pde b/android/examples/Topics/Interaction/Tickle/applet/Tickle.pde deleted file mode 100644 index 27a33c1e7..000000000 --- a/android/examples/Topics/Interaction/Tickle/applet/Tickle.pde +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Tickle. - * - * The word "tickle" jitters when the cursor hovers over. - * Sometimes, it can be tickled off the screen. - */ - -PFont font; -float x = 33; // X-coordinate of text -float y = 60; // Y-coordinate of text - -void setup() -{ - size(200, 200); - font = loadFont("AmericanTypewriter-24.vlw"); - textFont(font); - noStroke(); -} - -void draw() -{ - fill(204, 120); - rect(0, 0, width, height); - fill(0); - // If the cursor is over the text, change the position - if ((mouseX >= x) && (mouseX <= x+55) && - (mouseY >= y-24) && (mouseY <= y)) { - x += random(-5, 5); - y += random(-5, 5); - } - text("tickle", x, y); -} diff --git a/android/examples/Topics/Interaction/Tickle/applet/loading.gif b/android/examples/Topics/Interaction/Tickle/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Interaction/Tickle/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Bounce/applet/Bounce.java b/android/examples/Topics/Motion/Bounce/applet/Bounce.java deleted file mode 100644 index 52f6f156c..000000000 --- a/android/examples/Topics/Motion/Bounce/applet/Bounce.java +++ /dev/null @@ -1,67 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Bounce extends PApplet { - -/** - * Bounce. - * - * When the shape hits the edge of the window, it reverses its direction. - */ - -int size = 60; // Width of the shape -float xpos, ypos; // Starting position of shape - -float xspeed = 2.8f; // Speed of the shape -float yspeed = 2.2f; // Speed of the shape - -int xdirection = 1; // Left or Right -int ydirection = 1; // Top to Bottom - - -public void setup() -{ - size(640, 200); - noStroke(); - frameRate(30); - smooth(); - // Set the starting position of the shape - xpos = width/2; - ypos = height/2; -} - -public void draw() -{ - background(102); - - // Update the position of the shape - xpos = xpos + ( xspeed * xdirection ); - ypos = ypos + ( yspeed * ydirection ); - - // Test to see if the shape exceeds the boundaries of the screen - // If it does, reverse its direction by multiplying by -1 - if (xpos > width-size || xpos < 0) { - xdirection *= -1; - } - if (ypos > height-size || ypos < 0) { - ydirection *= -1; - } - - // Draw the shape - ellipse(xpos+size/2, ypos+size/2, size, size); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Bounce" }); - } -} diff --git a/android/examples/Topics/Motion/Bounce/applet/Bounce.pde b/android/examples/Topics/Motion/Bounce/applet/Bounce.pde deleted file mode 100644 index b6b7df531..000000000 --- a/android/examples/Topics/Motion/Bounce/applet/Bounce.pde +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Bounce. - * - * When the shape hits the edge of the window, it reverses its direction. - */ - -int size = 60; // Width of the shape -float xpos, ypos; // Starting position of shape - -float xspeed = 2.8; // Speed of the shape -float yspeed = 2.2; // Speed of the shape - -int xdirection = 1; // Left or Right -int ydirection = 1; // Top to Bottom - - -void setup() -{ - size(640, 200); - noStroke(); - frameRate(30); - smooth(); - // Set the starting position of the shape - xpos = width/2; - ypos = height/2; -} - -void draw() -{ - background(102); - - // Update the position of the shape - xpos = xpos + ( xspeed * xdirection ); - ypos = ypos + ( yspeed * ydirection ); - - // Test to see if the shape exceeds the boundaries of the screen - // If it does, reverse its direction by multiplying by -1 - if (xpos > width-size || xpos < 0) { - xdirection *= -1; - } - if (ypos > height-size || ypos < 0) { - ydirection *= -1; - } - - // Draw the shape - ellipse(xpos+size/2, ypos+size/2, size, size); -} diff --git a/android/examples/Topics/Motion/Bounce/applet/loading.gif b/android/examples/Topics/Motion/Bounce/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Bounce/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.java b/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.java deleted file mode 100644 index 857368dd2..000000000 --- a/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.java +++ /dev/null @@ -1,118 +0,0 @@ -import processing.core.*; -import processing.xml.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class BouncyBubbles extends PApplet { - -/** - * Bouncy Bubbles. - * Based on code from Keith Peters (www.bit-101.com). - * - * Multiple-object collision. - */ - - -int numBalls = 12; -float spring = 0.05f; -float gravity = 0.03f; -float friction = -0.9f; -Ball[] balls = new Ball[numBalls]; - -public void setup() -{ - size(640, 200); - noStroke(); - smooth(); - for (int i = 0; i < numBalls; i++) { - balls[i] = new Ball(random(width), random(height), random(20, 40), i, balls); - } -} - -public void draw() -{ - background(0); - for (int i = 0; i < numBalls; i++) { - balls[i].collide(); - balls[i].move(); - balls[i].display(); - } -} - -class Ball { - float x, y; - float diameter; - float vx = 0; - float vy = 0; - int id; - Ball[] others; - - Ball(float xin, float yin, float din, int idin, Ball[] oin) { - x = xin; - y = yin; - diameter = din; - id = idin; - others = oin; - } - - public void collide() { - for (int i = id + 1; i < numBalls; i++) { - float dx = others[i].x - x; - float dy = others[i].y - y; - float distance = sqrt(dx*dx + dy*dy); - float minDist = others[i].diameter/2 + diameter/2; - if (distance < minDist) { - float angle = atan2(dy, dx); - float targetX = x + cos(angle) * minDist; - float targetY = y + sin(angle) * minDist; - float ax = (targetX - others[i].x) * spring; - float ay = (targetY - others[i].y) * spring; - vx -= ax; - vy -= ay; - others[i].vx += ax; - others[i].vy += ay; - } - } - } - - public void move() { - vy += gravity; - x += vx; - y += vy; - if (x + diameter/2 > width) { - x = width - diameter/2; - vx *= friction; - } - else if (x - diameter/2 < 0) { - x = diameter/2; - vx *= friction; - } - if (y + diameter/2 > height) { - y = height - diameter/2; - vy *= friction; - } - else if (y - diameter/2 < 0) { - y = diameter/2; - vy *= friction; - } - } - - public void display() { - fill(255, 204); - ellipse(x, y, diameter, diameter); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "BouncyBubbles" }); - } -} diff --git a/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.pde b/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.pde deleted file mode 100644 index e9dc24f28..000000000 --- a/android/examples/Topics/Motion/BouncyBubbles/applet/BouncyBubbles.pde +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Bouncy Bubbles. - * Based on code from Keith Peters (www.bit-101.com). - * - * Multiple-object collision. - */ - - -int numBalls = 12; -float spring = 0.05; -float gravity = 0.03; -float friction = -0.9; -Ball[] balls = new Ball[numBalls]; - -void setup() -{ - size(640, 200); - noStroke(); - smooth(); - for (int i = 0; i < numBalls; i++) { - balls[i] = new Ball(random(width), random(height), random(20, 40), i, balls); - } -} - -void draw() -{ - background(0); - for (int i = 0; i < numBalls; i++) { - balls[i].collide(); - balls[i].move(); - balls[i].display(); - } -} - -class Ball { - float x, y; - float diameter; - float vx = 0; - float vy = 0; - int id; - Ball[] others; - - Ball(float xin, float yin, float din, int idin, Ball[] oin) { - x = xin; - y = yin; - diameter = din; - id = idin; - others = oin; - } - - void collide() { - for (int i = id + 1; i < numBalls; i++) { - float dx = others[i].x - x; - float dy = others[i].y - y; - float distance = sqrt(dx*dx + dy*dy); - float minDist = others[i].diameter/2 + diameter/2; - if (distance < minDist) { - float angle = atan2(dy, dx); - float targetX = x + cos(angle) * minDist; - float targetY = y + sin(angle) * minDist; - float ax = (targetX - others[i].x) * spring; - float ay = (targetY - others[i].y) * spring; - vx -= ax; - vy -= ay; - others[i].vx += ax; - others[i].vy += ay; - } - } - } - - void move() { - vy += gravity; - x += vx; - y += vy; - if (x + diameter/2 > width) { - x = width - diameter/2; - vx *= friction; - } - else if (x - diameter/2 < 0) { - x = diameter/2; - vx *= friction; - } - if (y + diameter/2 > height) { - y = height - diameter/2; - vy *= friction; - } - else if (y - diameter/2 < 0) { - y = diameter/2; - vy *= friction; - } - } - - void display() { - fill(255, 204); - ellipse(x, y, diameter, diameter); - } -} diff --git a/android/examples/Topics/Motion/BouncyBubbles/applet/loading.gif b/android/examples/Topics/Motion/BouncyBubbles/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/BouncyBubbles/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Brownian/applet/Brownian.java b/android/examples/Topics/Motion/Brownian/applet/Brownian.java deleted file mode 100644 index b26e75d22..000000000 --- a/android/examples/Topics/Motion/Brownian/applet/Brownian.java +++ /dev/null @@ -1,68 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Brownian extends PApplet { - -/** - * Brownian motion. - * - * Recording random movement as a continuous line. - */ - -int num = 2000; -int range = 6; - -float[] ax = new float[num]; -float[] ay = new float[num]; - - -public void setup() -{ - size(640, 360); - for(int i = 0; i < num; i++) { - ax[i] = width/2; - ay[i] = height/2; - } - frameRate(30); -} - -public void draw() -{ - background(51); - - // Shift all elements 1 place to the left - for(int i = 1; i < num; i++) { - ax[i-1] = ax[i]; - ay[i-1] = ay[i]; - } - - // Put a new value at the end of the array - ax[num-1] += random(-range, range); - ay[num-1] += random(-range, range); - - // Constrain all points to the screen - ax[num-1] = constrain(ax[num-1], 0, width); - ay[num-1] = constrain(ay[num-1], 0, height); - - // Draw a line connecting the points - for(int i=1; i width-ball.r) { - ball.x = width-ball.r; - vel.x *= -1; - } - else if (ball.x < ball.r) { - ball.x = ball.r; - vel.x *= -1; - } - else if (ball.y > height-ball.r) { - ball.y = height-ball.r; - vel.y *= -1; - } - else if (ball.y < ball.r) { - ball.y = ball.r; - vel.y *= -1; - } -} - -class Ball{ - float x, y, r, m; - - // default constructor - Ball() { - } - - Ball(float x, float y, float r) { - this.x = x; - this.y = y; - this.r = r; - m = r*.1f; - } -} - - - - static public void main(String args[]) { - PApplet.main(new String[] { "CircleCollision" }); - } -} diff --git a/android/examples/Topics/Motion/CircleCollision/applet/CircleCollision.pde b/android/examples/Topics/Motion/CircleCollision/applet/CircleCollision.pde deleted file mode 100644 index f739dc64a..000000000 --- a/android/examples/Topics/Motion/CircleCollision/applet/CircleCollision.pde +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Circle Collision with Swapping Velocities - * by Ira Greenberg. - * - * Based on Keith Peter's Solution in - * Foundation Actionscript Animation: Making Things Move! - */ - -Ball[] balls = { - new Ball(100, 400, 20), - new Ball(700, 400, 80) -}; - -PVector[] vels = { - new PVector(2.15, -1.35), - new PVector(-1.65, .42) -}; - -void setup() { - size(640, 360); - smooth(); - noStroke(); -} - -void draw() { - background(51); - fill(204); - for (int i=0; i< 2; i++){ - balls[i].x += vels[i].x; - balls[i].y += vels[i].y; - ellipse(balls[i].x, balls[i].y, balls[i].r*2, balls[i].r*2); - checkBoundaryCollision(balls[i], vels[i]); - } - checkObjectCollision(balls, vels); -} - -void checkObjectCollision(Ball[] b, PVector[] v){ - - // get distances between the balls components - PVector bVect = new PVector(); - bVect.x = b[1].x - b[0].x; - bVect.y = b[1].y - b[0].y; - - // calculate magnitude of the vector separating the balls - float bVectMag = sqrt(bVect.x * bVect.x + bVect.y * bVect.y); - if (bVectMag < b[0].r + b[1].r){ - // get angle of bVect - float theta = atan2(bVect.y, bVect.x); - // precalculate trig values - float sine = sin(theta); - float cosine = cos(theta); - - /* bTemp will hold rotated ball positions. You - just need to worry about bTemp[1] position*/ - Ball[] bTemp = { - new Ball(), new Ball() }; - - /* b[1]'s position is relative to b[0]'s - so you can use the vector between them (bVect) as the - reference point in the rotation expressions. - bTemp[0].x and bTemp[0].y will initialize - automatically to 0.0, which is what you want - since b[1] will rotate around b[0] */ - bTemp[1].x = cosine * bVect.x + sine * bVect.y; - bTemp[1].y = cosine * bVect.y - sine * bVect.x; - - // rotate Temporary velocities - PVector[] vTemp = { - new PVector(), new PVector() }; - vTemp[0].x = cosine * v[0].x + sine * v[0].y; - vTemp[0].y = cosine * v[0].y - sine * v[0].x; - vTemp[1].x = cosine * v[1].x + sine * v[1].y; - vTemp[1].y = cosine * v[1].y - sine * v[1].x; - - /* Now that velocities are rotated, you can use 1D - conservation of momentum equations to calculate - the final velocity along the x-axis. */ - PVector[] vFinal = { - new PVector(), new PVector() }; - // final rotated velocity for b[0] - vFinal[0].x = ((b[0].m - b[1].m) * vTemp[0].x + 2 * b[1].m * - vTemp[1].x) / (b[0].m + b[1].m); - vFinal[0].y = vTemp[0].y; - // final rotated velocity for b[0] - vFinal[1].x = ((b[1].m - b[0].m) * vTemp[1].x + 2 * b[0].m * - vTemp[0].x) / (b[0].m + b[1].m); - vFinal[1].y = vTemp[1].y; - - // hack to avoid clumping - bTemp[0].x += vFinal[0].x; - bTemp[1].x += vFinal[1].x; - - /* Rotate ball positions and velocities back - Reverse signs in trig expressions to rotate - in the opposite direction */ - // rotate balls - Ball[] bFinal = { - new Ball(), new Ball() }; - bFinal[0].x = cosine * bTemp[0].x - sine * bTemp[0].y; - bFinal[0].y = cosine * bTemp[0].y + sine * bTemp[0].x; - bFinal[1].x = cosine * bTemp[1].x - sine * bTemp[1].y; - bFinal[1].y = cosine * bTemp[1].y + sine * bTemp[1].x; - - // update balls to screen position - b[1].x = b[0].x + bFinal[1].x; - b[1].y = b[0].y + bFinal[1].y; - b[0].x = b[0].x + bFinal[0].x; - b[0].y = b[0].y + bFinal[0].y; - - // update velocities - v[0].x = cosine * vFinal[0].x - sine * vFinal[0].y; - v[0].y = cosine * vFinal[0].y + sine * vFinal[0].x; - v[1].x = cosine * vFinal[1].x - sine * vFinal[1].y; - v[1].y = cosine * vFinal[1].y + sine * vFinal[1].x; - } -} - -void checkBoundaryCollision(Ball ball, PVector vel) { - if (ball.x > width-ball.r) { - ball.x = width-ball.r; - vel.x *= -1; - } - else if (ball.x < ball.r) { - ball.x = ball.r; - vel.x *= -1; - } - else if (ball.y > height-ball.r) { - ball.y = height-ball.r; - vel.y *= -1; - } - else if (ball.y < ball.r) { - ball.y = ball.r; - vel.y *= -1; - } -} - diff --git a/android/examples/Topics/Motion/CircleCollision/applet/loading.gif b/android/examples/Topics/Motion/CircleCollision/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/CircleCollision/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Collision/applet/Collision.java b/android/examples/Topics/Motion/Collision/applet/Collision.java deleted file mode 100644 index 0ccaf12cf..000000000 --- a/android/examples/Topics/Motion/Collision/applet/Collision.java +++ /dev/null @@ -1,105 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Collision extends PApplet { - -/** - * Collision (Pong). - * - * Move the mouse up and down to move the paddle. - */ - -// Global variables for the ball -float ball_x; -float ball_y; -float ball_dir = 1; -float ball_size = 15; // Radius -float dy = 0; // Direction - -// Global variables for the paddle -int paddle_width = 10; -int paddle_height = 60; - -int dist_wall = 15; - -public void setup() -{ - size(640, 360); - rectMode(RADIUS); - ellipseMode(RADIUS); - noStroke(); - smooth(); - ball_y = height/2; - ball_x = 1; -} - -public void draw() -{ - background(51); - - ball_x += ball_dir * 1.0f; - ball_y += dy; - if(ball_x > width+ball_size) { - ball_x = -width/2 - ball_size; - ball_y = random(0, height); - dy = 0; - } - - // Constrain paddle to screen - float paddle_y = constrain(mouseY, paddle_height, height-paddle_height); - - // Test to see if the ball is touching the paddle - float py = width-dist_wall-paddle_width-ball_size; - if(ball_x == py - && ball_y > paddle_y - paddle_height - ball_size - && ball_y < paddle_y + paddle_height + ball_size) { - ball_dir *= -1; - if(mouseY != pmouseY) { - dy = (mouseY-pmouseY)/2.0f; - if(dy > 5) { dy = 5; } - if(dy < -5) { dy = -5; } - } - } - - // If ball hits paddle or back wall, reverse direction - if(ball_x < ball_size && ball_dir == -1) { - ball_dir *= -1; - } - - // If the ball is touching top or bottom edge, reverse direction - if(ball_y > height-ball_size) { - dy = dy * -1; - } - if(ball_y < ball_size) { - dy = dy * -1; - } - - // Draw ball - fill(255); - ellipse(ball_x, ball_y, ball_size, ball_size); - - // Draw the paddle - fill(153); - rect(width-dist_wall, paddle_y, paddle_width, paddle_height); -} - - - - - - - - static public void main(String args[]) { - PApplet.main(new String[] { "Collision" }); - } -} diff --git a/android/examples/Topics/Motion/Collision/applet/Collision.pde b/android/examples/Topics/Motion/Collision/applet/Collision.pde deleted file mode 100644 index 7d5b88c2b..000000000 --- a/android/examples/Topics/Motion/Collision/applet/Collision.pde +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Collision (Pong). - * - * Move the mouse up and down to move the paddle. - */ - -// Global variables for the ball -float ball_x; -float ball_y; -float ball_dir = 1; -float ball_size = 15; // Radius -float dy = 0; // Direction - -// Global variables for the paddle -int paddle_width = 10; -int paddle_height = 60; - -int dist_wall = 15; - -void setup() -{ - size(640, 360); - rectMode(RADIUS); - ellipseMode(RADIUS); - noStroke(); - smooth(); - ball_y = height/2; - ball_x = 1; -} - -void draw() -{ - background(51); - - ball_x += ball_dir * 1.0; - ball_y += dy; - if(ball_x > width+ball_size) { - ball_x = -width/2 - ball_size; - ball_y = random(0, height); - dy = 0; - } - - // Constrain paddle to screen - float paddle_y = constrain(mouseY, paddle_height, height-paddle_height); - - // Test to see if the ball is touching the paddle - float py = width-dist_wall-paddle_width-ball_size; - if(ball_x == py - && ball_y > paddle_y - paddle_height - ball_size - && ball_y < paddle_y + paddle_height + ball_size) { - ball_dir *= -1; - if(mouseY != pmouseY) { - dy = (mouseY-pmouseY)/2.0; - if(dy > 5) { dy = 5; } - if(dy < -5) { dy = -5; } - } - } - - // If ball hits paddle or back wall, reverse direction - if(ball_x < ball_size && ball_dir == -1) { - ball_dir *= -1; - } - - // If the ball is touching top or bottom edge, reverse direction - if(ball_y > height-ball_size) { - dy = dy * -1; - } - if(ball_y < ball_size) { - dy = dy * -1; - } - - // Draw ball - fill(255); - ellipse(ball_x, ball_y, ball_size, ball_size); - - // Draw the paddle - fill(153); - rect(width-dist_wall, paddle_y, paddle_width, paddle_height); -} - - - - - - diff --git a/android/examples/Topics/Motion/Collision/applet/loading.gif b/android/examples/Topics/Motion/Collision/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Collision/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Linear/applet/Linear.java b/android/examples/Topics/Motion/Linear/applet/Linear.java deleted file mode 100644 index 04208972f..000000000 --- a/android/examples/Topics/Motion/Linear/applet/Linear.java +++ /dev/null @@ -1,46 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Linear extends PApplet { - -/** - * Linear Motion. - * - * Changing a variable to create a moving line. - * When the line moves off the edge of the window, - * the variable is set to 0, which places the line - * back at the bottom of the screen. - */ - -float a = 100; - -public void setup() -{ - size(640, 200); - stroke(255); -} - -public void draw() -{ - background(51); - a = a - 0.5f; - if (a < 0) { - a = height; - } - line(0, a, width, a); -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Linear" }); - } -} diff --git a/android/examples/Topics/Motion/Linear/applet/Linear.pde b/android/examples/Topics/Motion/Linear/applet/Linear.pde deleted file mode 100644 index 246b9b05e..000000000 --- a/android/examples/Topics/Motion/Linear/applet/Linear.pde +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Linear Motion. - * - * Changing a variable to create a moving line. - * When the line moves off the edge of the window, - * the variable is set to 0, which places the line - * back at the bottom of the screen. - */ - -float a = 100; - -void setup() -{ - size(640, 200); - stroke(255); -} - -void draw() -{ - background(51); - a = a - 0.5; - if (a < 0) { - a = height; - } - line(0, a, width, a); -} diff --git a/android/examples/Topics/Motion/Linear/applet/loading.gif b/android/examples/Topics/Motion/Linear/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Linear/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.java b/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.java deleted file mode 100644 index 62ce132fe..000000000 --- a/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.java +++ /dev/null @@ -1,70 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class MovingOnCurves extends PApplet { - -/** - * Moving On Curves. - * - * In this example, the circles moves along the curve y = x^4. - * Click the mouse to have it move to a new position. - */ - -float beginX = 20.0f; // Initial x-coordinate -float beginY = 10.0f; // Initial y-coordinate -float endX = 570.0f; // Final x-coordinate -float endY = 320.0f; // Final y-coordinate -float distX; // X-axis distance to move -float distY; // Y-axis distance to move -float exponent = 4; // Determines the curve -float x = 0.0f; // Current x-coordinate -float y = 0.0f; // Current y-coordinate -float step = 0.01f; // Size of each step along the path -float pct = 0.0f; // Percentage traveled (0.0 to 1.0) - -public void setup() -{ - size(640, 360); - noStroke(); - smooth(); - distX = endX - beginX; - distY = endY - beginY; -} - -public void draw() -{ - fill(0, 2); - rect(0, 0, width, height); - pct += step; - if (pct < 1.0f) { - x = beginX + (pct * distX); - y = beginY + (pow(pct, exponent) * distY); - } - fill(255); - ellipse(x, y, 20, 20); -} - -public void mousePressed() { - pct = 0.0f; - beginX = x; - beginY = y; - endX = mouseX; - endY = mouseY; - distX = endX - beginX; - distY = endY - beginY; -} - - static public void main(String args[]) { - PApplet.main(new String[] { "MovingOnCurves" }); - } -} diff --git a/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.pde b/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.pde deleted file mode 100644 index 051d6ba48..000000000 --- a/android/examples/Topics/Motion/MovingOnCurves/applet/MovingOnCurves.pde +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Moving On Curves. - * - * In this example, the circles moves along the curve y = x^4. - * Click the mouse to have it move to a new position. - */ - -float beginX = 20.0; // Initial x-coordinate -float beginY = 10.0; // Initial y-coordinate -float endX = 570.0; // Final x-coordinate -float endY = 320.0; // Final y-coordinate -float distX; // X-axis distance to move -float distY; // Y-axis distance to move -float exponent = 4; // Determines the curve -float x = 0.0; // Current x-coordinate -float y = 0.0; // Current y-coordinate -float step = 0.01; // Size of each step along the path -float pct = 0.0; // Percentage traveled (0.0 to 1.0) - -void setup() -{ - size(640, 360); - noStroke(); - smooth(); - distX = endX - beginX; - distY = endY - beginY; -} - -void draw() -{ - fill(0, 2); - rect(0, 0, width, height); - pct += step; - if (pct < 1.0) { - x = beginX + (pct * distX); - y = beginY + (pow(pct, exponent) * distY); - } - fill(255); - ellipse(x, y, 20, 20); -} - -void mousePressed() { - pct = 0.0; - beginX = x; - beginY = y; - endX = mouseX; - endY = mouseY; - distX = endX - beginX; - distY = endY - beginY; -} diff --git a/android/examples/Topics/Motion/MovingOnCurves/applet/loading.gif b/android/examples/Topics/Motion/MovingOnCurves/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/MovingOnCurves/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Puff/applet/Puff.java b/android/examples/Topics/Motion/Puff/applet/Puff.java deleted file mode 100644 index 767b368a1..000000000 --- a/android/examples/Topics/Motion/Puff/applet/Puff.java +++ /dev/null @@ -1,111 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Puff extends PApplet { - -/** - * Puff - * by Ira Greenberg. - * - * Series of ellipses simulating a multi-segmented - * organism, utilizing a follow the leader algorithm. - * Collision detection occurs on the organism's head, - * controlling overall direction, and on the individual - * body segments, controlling body shape and jitter. - */ - -// for puff head -float headX; -float headY; -float speedX = .7f; -float speedY = .9f; - -// for puff body -int cells = 1000; -float[]px= new float[cells]; -float[]py= new float[cells]; -float[]radiiX = new float[cells]; -float[]radiiY = new float[cells]; -float[]angle = new float[cells]; -float[]frequency = new float[cells]; -float[]cellRadius = new float[cells]; - -public void setup(){ - - size(640, 360); - - // begin in the center - headX = width/2; - headY = height/2; - - //fill body arrays - for (int i=0; i< cells; i++){ - radiiX[i] = random(-7, 7); - radiiY[i] = random(-4, 4); - frequency[i]= random(-9, 9); - cellRadius[i] = random(16, 30); - } - frameRate(30); -} - -public void draw(){ - background(0); - noStroke(); - fill(255, 255, 255, 5); - - //follow the leader - for (int i =0; i< cells; i++){ - if (i==0){ - px[i] = headX+sin(radians(angle[i]))*radiiX[i]; - py[i] = headY+cos(radians(angle[i]))*radiiY[i]; - } - else{ - px[i] = px[i-1]+cos(radians(angle[i]))*radiiX[i]; - py[i] = py[i-1]+sin(radians(angle[i]))*radiiY[i]; - - //check collision of body - if (px[i] >= width-cellRadius[i]/2 || px[i] <= cellRadius[i]/2){ - radiiX[i]*=-1; - cellRadius[i] = random(1, 40); - frequency[i]= random(-13, 13); - } - if (py[i] >= height-cellRadius[i]/2 || py[i] <= cellRadius[i]/2){ - radiiY[i]*=-1; - cellRadius[i] = random(1, 40); - frequency[i]= random(-9, 9); - } - } - // draw puff - ellipse(px[i], py[i], cellRadius[i], cellRadius[i]); - // set speed of body - angle[i]+=frequency[i]; - } - - // set velocity of head - headX+=speedX; - headY+=speedY; - - //check boundary collision of head - if (headX >= width-cellRadius[0]/2 || headX <=cellRadius[0]/2){ - speedX*=-1; - } - if (headY >= height-cellRadius[0]/2 || headY <= cellRadius[0]/2){ - speedY*=-1; - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Puff" }); - } -} diff --git a/android/examples/Topics/Motion/Puff/applet/Puff.pde b/android/examples/Topics/Motion/Puff/applet/Puff.pde deleted file mode 100644 index ad2508587..000000000 --- a/android/examples/Topics/Motion/Puff/applet/Puff.pde +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Puff - * by Ira Greenberg. - * - * Series of ellipses simulating a multi-segmented - * organism, utilizing a follow the leader algorithm. - * Collision detection occurs on the organism's head, - * controlling overall direction, and on the individual - * body segments, controlling body shape and jitter. - */ - -// for puff head -float headX; -float headY; -float speedX = .7; -float speedY = .9; - -// for puff body -int cells = 1000; -float[]px= new float[cells]; -float[]py= new float[cells]; -float[]radiiX = new float[cells]; -float[]radiiY = new float[cells]; -float[]angle = new float[cells]; -float[]frequency = new float[cells]; -float[]cellRadius = new float[cells]; - -void setup(){ - - size(640, 360); - - // begin in the center - headX = width/2; - headY = height/2; - - //fill body arrays - for (int i=0; i< cells; i++){ - radiiX[i] = random(-7, 7); - radiiY[i] = random(-4, 4); - frequency[i]= random(-9, 9); - cellRadius[i] = random(16, 30); - } - frameRate(30); -} - -void draw(){ - background(0); - noStroke(); - fill(255, 255, 255, 5); - - //follow the leader - for (int i =0; i< cells; i++){ - if (i==0){ - px[i] = headX+sin(radians(angle[i]))*radiiX[i]; - py[i] = headY+cos(radians(angle[i]))*radiiY[i]; - } - else{ - px[i] = px[i-1]+cos(radians(angle[i]))*radiiX[i]; - py[i] = py[i-1]+sin(radians(angle[i]))*radiiY[i]; - - //check collision of body - if (px[i] >= width-cellRadius[i]/2 || px[i] <= cellRadius[i]/2){ - radiiX[i]*=-1; - cellRadius[i] = random(1, 40); - frequency[i]= random(-13, 13); - } - if (py[i] >= height-cellRadius[i]/2 || py[i] <= cellRadius[i]/2){ - radiiY[i]*=-1; - cellRadius[i] = random(1, 40); - frequency[i]= random(-9, 9); - } - } - // draw puff - ellipse(px[i], py[i], cellRadius[i], cellRadius[i]); - // set speed of body - angle[i]+=frequency[i]; - } - - // set velocity of head - headX+=speedX; - headY+=speedY; - - //check boundary collision of head - if (headX >= width-cellRadius[0]/2 || headX <=cellRadius[0]/2){ - speedX*=-1; - } - if (headY >= height-cellRadius[0]/2 || headY <= cellRadius[0]/2){ - speedY*=-1; - } -} - diff --git a/android/examples/Topics/Motion/Puff/applet/loading.gif b/android/examples/Topics/Motion/Puff/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Puff/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Reflection1/applet/Reflection1.java b/android/examples/Topics/Motion/Reflection1/applet/Reflection1.java deleted file mode 100644 index db453b558..000000000 --- a/android/examples/Topics/Motion/Reflection1/applet/Reflection1.java +++ /dev/null @@ -1,149 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Reflection1 extends PApplet { - - /** - * Non-orthogonal Reflection - * by Ira Greenberg. - * - * Based on the equation (R = 2N(N*L)-L) where R is the - * reflection vector, N is the normal, and L is the incident - * vector. - */ - -float baseX1, baseY1, baseX2, baseY2; -float baseLength; -float[] xCoords, yCoords; -float ellipseX, ellipseY, ellipseRadius = 6; -float directionX, directionY; -float ellipseSpeed = 3.5f; -float velocityX, velocityY; - -public void setup(){ - size(640, 240); - frameRate(30); - fill(128); - smooth(); - baseX1 = 0; - baseY1 = height-150; - baseX2 = width; - baseY2 = height; - - // start ellipse at middle top of screen - ellipseX = width/2; - - // calculate initial random direction - directionX = random(0.1f, 0.99f); - directionY = random(0.1f, 0.99f); - - // normalize direction vector - float directionVectLength = sqrt(directionX*directionX + - directionY*directionY); - directionX /= directionVectLength; - directionY /= directionVectLength; -} - -public void draw(){ - // draw background - fill(0, 12); - noStroke(); - rect(0, 0, width, height); - - // calculate length of base top - baseLength = dist(baseX1, baseY1, baseX2, baseY2); - xCoords = new float[ceil(baseLength)]; - yCoords = new float[ceil(baseLength)]; - - // fill base top coordinate array - for (int i=0; i width-ellipseRadius){ - ellipseX = width-ellipseRadius; - directionX *= -1; - } - // left - if (ellipseX < ellipseRadius){ - ellipseX = ellipseRadius; - directionX *= -1; - } - // top - if (ellipseY < ellipseRadius){ - ellipseY = ellipseRadius; - directionY *= -1; - // randomize base top - baseY1 = random(height-100, height); - baseY2 = random(height-100, height); - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Reflection1" }); - } -} diff --git a/android/examples/Topics/Motion/Reflection1/applet/Reflection1.pde b/android/examples/Topics/Motion/Reflection1/applet/Reflection1.pde deleted file mode 100644 index 9f8434c93..000000000 --- a/android/examples/Topics/Motion/Reflection1/applet/Reflection1.pde +++ /dev/null @@ -1,129 +0,0 @@ - /** - * Non-orthogonal Reflection - * by Ira Greenberg. - * - * Based on the equation (R = 2N(N*L)-L) where R is the - * reflection vector, N is the normal, and L is the incident - * vector. - */ - -float baseX1, baseY1, baseX2, baseY2; -float baseLength; -float[] xCoords, yCoords; -float ellipseX, ellipseY, ellipseRadius = 6; -float directionX, directionY; -float ellipseSpeed = 3.5; -float velocityX, velocityY; - -void setup(){ - size(640, 240); - frameRate(30); - fill(128); - smooth(); - baseX1 = 0; - baseY1 = height-150; - baseX2 = width; - baseY2 = height; - - // start ellipse at middle top of screen - ellipseX = width/2; - - // calculate initial random direction - directionX = random(0.1, 0.99); - directionY = random(0.1, 0.99); - - // normalize direction vector - float directionVectLength = sqrt(directionX*directionX + - directionY*directionY); - directionX /= directionVectLength; - directionY /= directionVectLength; -} - -void draw(){ - // draw background - fill(0, 12); - noStroke(); - rect(0, 0, width, height); - - // calculate length of base top - baseLength = dist(baseX1, baseY1, baseX2, baseY2); - xCoords = new float[ceil(baseLength)]; - yCoords = new float[ceil(baseLength)]; - - // fill base top coordinate array - for (int i=0; i width-ellipseRadius){ - ellipseX = width-ellipseRadius; - directionX *= -1; - } - // left - if (ellipseX < ellipseRadius){ - ellipseX = ellipseRadius; - directionX *= -1; - } - // top - if (ellipseY < ellipseRadius){ - ellipseY = ellipseRadius; - directionY *= -1; - // randomize base top - baseY1 = random(height-100, height); - baseY2 = random(height-100, height); - } -} - diff --git a/android/examples/Topics/Motion/Reflection1/applet/loading.gif b/android/examples/Topics/Motion/Reflection1/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Reflection1/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Motion/Reflection2/applet/Ground.pde b/android/examples/Topics/Motion/Reflection2/applet/Ground.pde deleted file mode 100644 index 55d8497e2..000000000 --- a/android/examples/Topics/Motion/Reflection2/applet/Ground.pde +++ /dev/null @@ -1,20 +0,0 @@ -class Ground { - float x1, y1, x2, y2; - float x, y, len, rot; - - // Default constructor - Ground(){ - } - - // Constructor - Ground(float x1, float y1, float x2, float y2) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - x = (x1+x2)/2; - y = (y1+y2)/2; - len = dist(x1, y1, x2, y2); - rot = atan2((y2-y1), (x2-x1)); - } -} diff --git a/android/examples/Topics/Motion/Reflection2/applet/Orb.pde b/android/examples/Topics/Motion/Reflection2/applet/Orb.pde deleted file mode 100644 index 7af7ed91b..000000000 --- a/android/examples/Topics/Motion/Reflection2/applet/Orb.pde +++ /dev/null @@ -1,14 +0,0 @@ -class Orb{ - float x, y, r; - - // Default constructor - Orb() { - } - - Orb(float x, float y, float r) { - this.x = x; - this.y = y; - this.r = r; - } -} - diff --git a/android/examples/Topics/Motion/Reflection2/applet/Reflection2.java b/android/examples/Topics/Motion/Reflection2/applet/Reflection2.java deleted file mode 100644 index 46360590b..000000000 --- a/android/examples/Topics/Motion/Reflection2/applet/Reflection2.java +++ /dev/null @@ -1,183 +0,0 @@ -import processing.core.*; -import processing.xml.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Reflection2 extends PApplet { - -/** - * Non-orthogonal Collision with Multiple Ground Segments - * by Ira Greenberg. - * - * Based on Keith Peter's Solution in - * Foundation Actionscript Animation: Making Things Move! - */ - -Orb orb; -PVector velocity; -float gravity = .05f, damping = 0.8f; -int segments = 40; -Ground[] ground = new Ground[segments]; -float[] peakHeights = new float[segments+1]; - -public void setup(){ - size(640, 200); - smooth(); - orb = new Orb(50, 50, 3); - velocity = new PVector(.5f, 0); - - // Calculate ground peak heights - for (int i=0; i width-orb.r){ - orb.x = width-orb.r; - velocity.x *= -1; - velocity.x *= damping; - } - else if (orb.x < orb.r){ - orb.x = orb.r; - velocity.x *= -1; - velocity.x *= damping; - } -} - - -public void checkGroundCollision(Ground groundSegment) { - - // Get difference between orb and ground - float deltaX = orb.x - groundSegment.x; - float deltaY = orb.y - groundSegment.y; - - // Precalculate trig values - float cosine = cos(groundSegment.rot); - float sine = sin(groundSegment.rot); - - /* Rotate ground and velocity to allow - orthogonal collision calculations */ - float groundXTemp = cosine * deltaX + sine * deltaY; - float groundYTemp = cosine * deltaY - sine * deltaX; - float velocityXTemp = cosine * velocity.x + sine * velocity.y; - float velocityYTemp = cosine * velocity.y - sine * velocity.x; - - /* Ground collision - check for surface - collision and also that orb is within - left/rights bounds of ground segment */ - if (groundYTemp > -orb.r && - orb.x > groundSegment.x1 && - orb.x < groundSegment.x2 ){ - // keep orb from going into ground - groundYTemp = -orb.r; - // bounce and slow down orb - velocityYTemp *= -1.0f; - velocityYTemp *= damping; - } - - // Reset ground, velocity and orb - deltaX = cosine * groundXTemp - sine * groundYTemp; - deltaY = cosine * groundYTemp + sine * groundXTemp; - velocity.x = cosine * velocityXTemp - sine * velocityYTemp; - velocity.y = cosine * velocityYTemp + sine * velocityXTemp; - orb.x = groundSegment.x + deltaX; - orb.y = groundSegment.y + deltaY; -} - - - - -class Ground { - float x1, y1, x2, y2; - float x, y, len, rot; - - // Default constructor - Ground(){ - } - - // Constructor - Ground(float x1, float y1, float x2, float y2) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - x = (x1+x2)/2; - y = (y1+y2)/2; - len = dist(x1, y1, x2, y2); - rot = atan2((y2-y1), (x2-x1)); - } -} -class Orb{ - float x, y, r; - - // Default constructor - Orb() { - } - - Orb(float x, float y, float r) { - this.x = x; - this.y = y; - this.r = r; - } -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "Reflection2" }); - } -} diff --git a/android/examples/Topics/Motion/Reflection2/applet/Reflection2.pde b/android/examples/Topics/Motion/Reflection2/applet/Reflection2.pde deleted file mode 100644 index 05f135b7f..000000000 --- a/android/examples/Topics/Motion/Reflection2/applet/Reflection2.pde +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Non-orthogonal Collision with Multiple Ground Segments - * by Ira Greenberg. - * - * Based on Keith Peter's Solution in - * Foundation Actionscript Animation: Making Things Move! - */ - -Orb orb; -PVector velocity; -float gravity = .05, damping = 0.8; -int segments = 40; -Ground[] ground = new Ground[segments]; -float[] peakHeights = new float[segments+1]; - -void setup(){ - size(640, 200); - smooth(); - orb = new Orb(50, 50, 3); - velocity = new PVector(.5, 0); - - // Calculate ground peak heights - for (int i=0; i width-orb.r){ - orb.x = width-orb.r; - velocity.x *= -1; - velocity.x *= damping; - } - else if (orb.x < orb.r){ - orb.x = orb.r; - velocity.x *= -1; - velocity.x *= damping; - } -} - - -void checkGroundCollision(Ground groundSegment) { - - // Get difference between orb and ground - float deltaX = orb.x - groundSegment.x; - float deltaY = orb.y - groundSegment.y; - - // Precalculate trig values - float cosine = cos(groundSegment.rot); - float sine = sin(groundSegment.rot); - - /* Rotate ground and velocity to allow - orthogonal collision calculations */ - float groundXTemp = cosine * deltaX + sine * deltaY; - float groundYTemp = cosine * deltaY - sine * deltaX; - float velocityXTemp = cosine * velocity.x + sine * velocity.y; - float velocityYTemp = cosine * velocity.y - sine * velocity.x; - - /* Ground collision - check for surface - collision and also that orb is within - left/rights bounds of ground segment */ - if (groundYTemp > -orb.r && - orb.x > groundSegment.x1 && - orb.x < groundSegment.x2 ){ - // keep orb from going into ground - groundYTemp = -orb.r; - // bounce and slow down orb - velocityYTemp *= -1.0; - velocityYTemp *= damping; - } - - // Reset ground, velocity and orb - deltaX = cosine * groundXTemp - sine * groundYTemp; - deltaY = cosine * groundYTemp + sine * groundXTemp; - velocity.x = cosine * velocityXTemp - sine * velocityYTemp; - velocity.y = cosine * velocityYTemp + sine * velocityXTemp; - orb.x = groundSegment.x + deltaX; - orb.y = groundSegment.y + deltaY; -} - - - - diff --git a/android/examples/Topics/Motion/Reflection2/applet/loading.gif b/android/examples/Topics/Motion/Reflection2/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Motion/Reflection2/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/Chain/applet/Chain.java b/android/examples/Topics/Simulate/Chain/applet/Chain.java deleted file mode 100644 index 33eb6ea59..000000000 --- a/android/examples/Topics/Simulate/Chain/applet/Chain.java +++ /dev/null @@ -1,88 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Chain extends PApplet { - -/** - * Chain. - * - * One mass is attached to the mouse position and the other - * is attached the position of the other mass. The gravity - * in the environment pulls down on both. - */ - - -Spring2D s1, s2; - -float gravity = 6.0f; -float mass = 2.0f; - -public void setup() -{ - size(200, 200); - smooth(); - fill(0); - // Inputs: x, y, mass, gravity - s1 = new Spring2D(0.0f, width/2, mass, gravity); - s2 = new Spring2D(0.0f, width/2, mass, gravity); -} - -public void draw() -{ - background(204); - s1.update(mouseX, mouseY); - s1.display(mouseX, mouseY); - s2.update(s1.x, s1.y); - s2.display(s1.x, s1.y); -} - -class Spring2D { - float vx, vy; // The x- and y-axis velocities - float x, y; // The x- and y-coordinates - float gravity; - float mass; - float radius = 20; - float stiffness = 0.2f; - float damping = 0.7f; - - Spring2D(float xpos, float ypos, float m, float g) { - x = xpos; - y = ypos; - mass = m; - gravity = g; - } - - public void update(float targetX, float targetY) { - float forceX = (targetX - x) * stiffness; - float ax = forceX / mass; - vx = damping * (vx + ax); - x += vx; - float forceY = (targetY - y) * stiffness; - forceY += gravity; - float ay = forceY / mass; - vy = damping * (vy + ay); - y += vy; - } - - public void display(float nx, float ny) { - noStroke(); - ellipse(x, y, radius*2, radius*2); - stroke(255); - line(x, y, nx, ny); - } -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Chain" }); - } -} diff --git a/android/examples/Topics/Simulate/Chain/applet/Chain.pde b/android/examples/Topics/Simulate/Chain/applet/Chain.pde deleted file mode 100644 index f2a53006f..000000000 --- a/android/examples/Topics/Simulate/Chain/applet/Chain.pde +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Chain. - * - * One mass is attached to the mouse position and the other - * is attached the position of the other mass. The gravity - * in the environment pulls down on both. - */ - - -Spring2D s1, s2; - -float gravity = 6.0; -float mass = 2.0; - -void setup() -{ - size(200, 200); - smooth(); - fill(0); - // Inputs: x, y, mass, gravity - s1 = new Spring2D(0.0, width/2, mass, gravity); - s2 = new Spring2D(0.0, width/2, mass, gravity); -} - -void draw() -{ - background(204); - s1.update(mouseX, mouseY); - s1.display(mouseX, mouseY); - s2.update(s1.x, s1.y); - s2.display(s1.x, s1.y); -} - -class Spring2D { - float vx, vy; // The x- and y-axis velocities - float x, y; // The x- and y-coordinates - float gravity; - float mass; - float radius = 20; - float stiffness = 0.2; - float damping = 0.7; - - Spring2D(float xpos, float ypos, float m, float g) { - x = xpos; - y = ypos; - mass = m; - gravity = g; - } - - void update(float targetX, float targetY) { - float forceX = (targetX - x) * stiffness; - float ax = forceX / mass; - vx = damping * (vx + ax); - x += vx; - float forceY = (targetY - y) * stiffness; - forceY += gravity; - float ay = forceY / mass; - vy = damping * (vy + ay); - y += vy; - } - - void display(float nx, float ny) { - noStroke(); - ellipse(x, y, radius*2, radius*2); - stroke(255); - line(x, y, nx, ny); - } -} diff --git a/android/examples/Topics/Simulate/Chain/applet/loading.gif b/android/examples/Topics/Simulate/Chain/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/Chain/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/Flocking/applet/Boid.pde b/android/examples/Topics/Simulate/Flocking/applet/Boid.pde deleted file mode 100644 index dcd1a994a..000000000 --- a/android/examples/Topics/Simulate/Flocking/applet/Boid.pde +++ /dev/null @@ -1,196 +0,0 @@ -// The Boid class - -class Boid { - - PVector loc; - PVector vel; - PVector acc; - float r; - float maxforce; // Maximum steering force - float maxspeed; // Maximum speed - - Boid(PVector l, float ms, float mf) { - acc = new PVector(0,0); - vel = new PVector(random(-1,1),random(-1,1)); - loc = l.get(); - r = 2.0; - maxspeed = ms; - maxforce = mf; - } - - void run(ArrayList boids) { - flock(boids); - update(); - borders(); - render(); - } - - // We accumulate a new acceleration each time based on three rules - void flock(ArrayList boids) { - PVector sep = separate(boids); // Separation - PVector ali = align(boids); // Alignment - PVector coh = cohesion(boids); // Cohesion - // Arbitrarily weight these forces - sep.mult(1.5); - ali.mult(1.0); - coh.mult(1.0); - // Add the force vectors to acceleration - acc.add(sep); - acc.add(ali); - acc.add(coh); - } - - // Method to update location - void update() { - // Update velocity - vel.add(acc); - // Limit speed - vel.limit(maxspeed); - loc.add(vel); - // Reset accelertion to 0 each cycle - acc.mult(0); - } - - void seek(PVector target) { - acc.add(steer(target,false)); - } - - void arrive(PVector target) { - acc.add(steer(target,true)); - } - - // A method that calculates a steering vector towards a target - // Takes a second argument, if true, it slows down as it approaches the target - PVector steer(PVector target, boolean slowdown) { - PVector steer; // The steering vector - PVector desired = target.sub(target,loc); // A vector pointing from the location to the target - float d = desired.mag(); // Distance from the target is the magnitude of the vector - // If the distance is greater than 0, calc steering (otherwise return zero vector) - if (d > 0) { - // Normalize desired - desired.normalize(); - // Two options for desired vector magnitude (1 -- based on distance, 2 -- maxspeed) - if ((slowdown) && (d < 100.0)) desired.mult(maxspeed*(d/100.0)); // This damping is somewhat arbitrary - else desired.mult(maxspeed); - // Steering = Desired minus Velocity - steer = target.sub(desired,vel); - steer.limit(maxforce); // Limit to maximum steering force - } - else { - steer = new PVector(0,0); - } - return steer; - } - - void render() { - // Draw a triangle rotated in the direction of velocity - float theta = vel.heading2D() + PI/2; - fill(200,100); - stroke(255); - pushMatrix(); - translate(loc.x,loc.y); - rotate(theta); - beginShape(TRIANGLES); - vertex(0, -r*2); - vertex(-r, r*2); - vertex(r, r*2); - endShape(); - popMatrix(); - } - - // Wraparound - void borders() { - if (loc.x < -r) loc.x = width+r; - if (loc.y < -r) loc.y = height+r; - if (loc.x > width+r) loc.x = -r; - if (loc.y > height+r) loc.y = -r; - } - - // Separation - // Method checks for nearby boids and steers away - PVector separate (ArrayList boids) { - float desiredseparation = 20.0; - PVector steer = new PVector(0,0,0); - int count = 0; - // For every boid in the system, check if it's too close - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = PVector.dist(loc,other.loc); - // If the distance is greater than 0 and less than an arbitrary amount (0 when you are yourself) - if ((d > 0) && (d < desiredseparation)) { - // Calculate vector pointing away from neighbor - PVector diff = PVector.sub(loc,other.loc); - diff.normalize(); - diff.div(d); // Weight by distance - steer.add(diff); - count++; // Keep track of how many - } - } - // Average -- divide by how many - if (count > 0) { - steer.div((float)count); - } - - // As long as the vector is greater than 0 - if (steer.mag() > 0) { - // Implement Reynolds: Steering = Desired - Velocity - steer.normalize(); - steer.mult(maxspeed); - steer.sub(vel); - steer.limit(maxforce); - } - return steer; - } - - // Alignment - // For every nearby boid in the system, calculate the average velocity - PVector align (ArrayList boids) { - float neighbordist = 25.0; - PVector steer = new PVector(0,0,0); - int count = 0; - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = PVector.dist(loc,other.loc); - if ((d > 0) && (d < neighbordist)) { - steer.add(other.vel); - count++; - } - } - if (count > 0) { - steer.div((float)count); - } - - // As long as the vector is greater than 0 - if (steer.mag() > 0) { - // Implement Reynolds: Steering = Desired - Velocity - steer.normalize(); - steer.mult(maxspeed); - steer.sub(vel); - steer.limit(maxforce); - } - return steer; - } - - // Cohesion - // For the average location (i.e. center) of all nearby boids, calculate steering vector towards that location - PVector cohesion (ArrayList boids) { - float neighbordist = 25.0; - PVector sum = new PVector(0,0); // Start with empty vector to accumulate all locations - int count = 0; - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = loc.dist(other.loc); - if ((d > 0) && (d < neighbordist)) { - sum.add(other.loc); // Add location - count++; - } - } - if (count > 0) { - sum.div((float)count); - return steer(sum,false); // Steer towards the location - } - return sum; - } -} - - diff --git a/android/examples/Topics/Simulate/Flocking/applet/Flock.pde b/android/examples/Topics/Simulate/Flocking/applet/Flock.pde deleted file mode 100644 index 9ec1001c7..000000000 --- a/android/examples/Topics/Simulate/Flocking/applet/Flock.pde +++ /dev/null @@ -1,22 +0,0 @@ -// The Flock (a list of Boid objects) - -class Flock { - ArrayList boids; // An arraylist for all the boids - - Flock() { - boids = new ArrayList(); // Initialize the arraylist - } - - void run() { - for (int i = 0; i < boids.size(); i++) { - Boid b = (Boid) boids.get(i); - b.run(boids); // Passing the entire list of boids to each boid individually - } - } - - void addBoid(Boid b) { - boids.add(b); - } - -} - diff --git a/android/examples/Topics/Simulate/Flocking/applet/Flocking.java b/android/examples/Topics/Simulate/Flocking/applet/Flocking.java deleted file mode 100644 index a9b700859..000000000 --- a/android/examples/Topics/Simulate/Flocking/applet/Flocking.java +++ /dev/null @@ -1,271 +0,0 @@ -import processing.core.*; -import processing.xml.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Flocking extends PApplet { - -/** - * Flocking - * by Daniel Shiffman. - * - * An implementation of Craig Reynold's Boids program to simulate - * the flocking behavior of birds. Each boid steers itself based on - * rules of avoidance, alignment, and coherence. - * - * Click the mouse to add a new boid. - */ - -Flock flock; - -public void setup() { - size(640, 360); - flock = new Flock(); - // Add an initial set of boids into the system - for (int i = 0; i < 150; i++) { - flock.addBoid(new Boid(new PVector(width/2,height/2), 3.0f, 0.05f)); - } - smooth(); -} - -public void draw() { - background(50); - flock.run(); -} - -// Add a new boid into the System -public void mousePressed() { - flock.addBoid(new Boid(new PVector(mouseX,mouseY),2.0f,0.05f)); -} -// The Boid class - -class Boid { - - PVector loc; - PVector vel; - PVector acc; - float r; - float maxforce; // Maximum steering force - float maxspeed; // Maximum speed - - Boid(PVector l, float ms, float mf) { - acc = new PVector(0,0); - vel = new PVector(random(-1,1),random(-1,1)); - loc = l.get(); - r = 2.0f; - maxspeed = ms; - maxforce = mf; - } - - public void run(ArrayList boids) { - flock(boids); - update(); - borders(); - render(); - } - - // We accumulate a new acceleration each time based on three rules - public void flock(ArrayList boids) { - PVector sep = separate(boids); // Separation - PVector ali = align(boids); // Alignment - PVector coh = cohesion(boids); // Cohesion - // Arbitrarily weight these forces - sep.mult(1.5f); - ali.mult(1.0f); - coh.mult(1.0f); - // Add the force vectors to acceleration - acc.add(sep); - acc.add(ali); - acc.add(coh); - } - - // Method to update location - public void update() { - // Update velocity - vel.add(acc); - // Limit speed - vel.limit(maxspeed); - loc.add(vel); - // Reset accelertion to 0 each cycle - acc.mult(0); - } - - public void seek(PVector target) { - acc.add(steer(target,false)); - } - - public void arrive(PVector target) { - acc.add(steer(target,true)); - } - - // A method that calculates a steering vector towards a target - // Takes a second argument, if true, it slows down as it approaches the target - public PVector steer(PVector target, boolean slowdown) { - PVector steer; // The steering vector - PVector desired = target.sub(target,loc); // A vector pointing from the location to the target - float d = desired.mag(); // Distance from the target is the magnitude of the vector - // If the distance is greater than 0, calc steering (otherwise return zero vector) - if (d > 0) { - // Normalize desired - desired.normalize(); - // Two options for desired vector magnitude (1 -- based on distance, 2 -- maxspeed) - if ((slowdown) && (d < 100.0f)) desired.mult(maxspeed*(d/100.0f)); // This damping is somewhat arbitrary - else desired.mult(maxspeed); - // Steering = Desired minus Velocity - steer = target.sub(desired,vel); - steer.limit(maxforce); // Limit to maximum steering force - } - else { - steer = new PVector(0,0); - } - return steer; - } - - public void render() { - // Draw a triangle rotated in the direction of velocity - float theta = vel.heading2D() + PI/2; - fill(200,100); - stroke(255); - pushMatrix(); - translate(loc.x,loc.y); - rotate(theta); - beginShape(TRIANGLES); - vertex(0, -r*2); - vertex(-r, r*2); - vertex(r, r*2); - endShape(); - popMatrix(); - } - - // Wraparound - public void borders() { - if (loc.x < -r) loc.x = width+r; - if (loc.y < -r) loc.y = height+r; - if (loc.x > width+r) loc.x = -r; - if (loc.y > height+r) loc.y = -r; - } - - // Separation - // Method checks for nearby boids and steers away - public PVector separate (ArrayList boids) { - float desiredseparation = 20.0f; - PVector steer = new PVector(0,0,0); - int count = 0; - // For every boid in the system, check if it's too close - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = PVector.dist(loc,other.loc); - // If the distance is greater than 0 and less than an arbitrary amount (0 when you are yourself) - if ((d > 0) && (d < desiredseparation)) { - // Calculate vector pointing away from neighbor - PVector diff = PVector.sub(loc,other.loc); - diff.normalize(); - diff.div(d); // Weight by distance - steer.add(diff); - count++; // Keep track of how many - } - } - // Average -- divide by how many - if (count > 0) { - steer.div((float)count); - } - - // As long as the vector is greater than 0 - if (steer.mag() > 0) { - // Implement Reynolds: Steering = Desired - Velocity - steer.normalize(); - steer.mult(maxspeed); - steer.sub(vel); - steer.limit(maxforce); - } - return steer; - } - - // Alignment - // For every nearby boid in the system, calculate the average velocity - public PVector align (ArrayList boids) { - float neighbordist = 25.0f; - PVector steer = new PVector(0,0,0); - int count = 0; - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = PVector.dist(loc,other.loc); - if ((d > 0) && (d < neighbordist)) { - steer.add(other.vel); - count++; - } - } - if (count > 0) { - steer.div((float)count); - } - - // As long as the vector is greater than 0 - if (steer.mag() > 0) { - // Implement Reynolds: Steering = Desired - Velocity - steer.normalize(); - steer.mult(maxspeed); - steer.sub(vel); - steer.limit(maxforce); - } - return steer; - } - - // Cohesion - // For the average location (i.e. center) of all nearby boids, calculate steering vector towards that location - public PVector cohesion (ArrayList boids) { - float neighbordist = 25.0f; - PVector sum = new PVector(0,0); // Start with empty vector to accumulate all locations - int count = 0; - for (int i = 0 ; i < boids.size(); i++) { - Boid other = (Boid) boids.get(i); - float d = loc.dist(other.loc); - if ((d > 0) && (d < neighbordist)) { - sum.add(other.loc); // Add location - count++; - } - } - if (count > 0) { - sum.div((float)count); - return steer(sum,false); // Steer towards the location - } - return sum; - } -} - - -// The Flock (a list of Boid objects) - -class Flock { - ArrayList boids; // An arraylist for all the boids - - Flock() { - boids = new ArrayList(); // Initialize the arraylist - } - - public void run() { - for (int i = 0; i < boids.size(); i++) { - Boid b = (Boid) boids.get(i); - b.run(boids); // Passing the entire list of boids to each boid individually - } - } - - public void addBoid(Boid b) { - boids.add(b); - } - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "--present", "--bgcolor=#666666", "--hide-stop", "Flocking" }); - } -} diff --git a/android/examples/Topics/Simulate/Flocking/applet/Flocking.pde b/android/examples/Topics/Simulate/Flocking/applet/Flocking.pde deleted file mode 100644 index ed0e7e60c..000000000 --- a/android/examples/Topics/Simulate/Flocking/applet/Flocking.pde +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Flocking - * by Daniel Shiffman. - * - * An implementation of Craig Reynold's Boids program to simulate - * the flocking behavior of birds. Each boid steers itself based on - * rules of avoidance, alignment, and coherence. - * - * Click the mouse to add a new boid. - */ - -Flock flock; - -void setup() { - size(640, 360); - flock = new Flock(); - // Add an initial set of boids into the system - for (int i = 0; i < 150; i++) { - flock.addBoid(new Boid(new PVector(width/2,height/2), 3.0, 0.05)); - } - smooth(); -} - -void draw() { - background(50); - flock.run(); -} - -// Add a new boid into the System -void mousePressed() { - flock.addBoid(new Boid(new PVector(mouseX,mouseY),2.0f,0.05f)); -} diff --git a/android/examples/Topics/Simulate/Flocking/applet/loading.gif b/android/examples/Topics/Simulate/Flocking/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/Flocking/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/Fluid/applet/Fluid.java b/android/examples/Topics/Simulate/Fluid/applet/Fluid.java deleted file mode 100644 index ebf6d8e2d..000000000 --- a/android/examples/Topics/Simulate/Fluid/applet/Fluid.java +++ /dev/null @@ -1,228 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Fluid extends PApplet { - -/** - * Fluid - * by Glen Murphy. - * - * Click and drag the mouse to move the simulated fluid. - * Adjust the "res" variable below to change resolution. - * Code has not been optimised, and will run fairly slowly. - */ - -int res = 2; -int penSize = 30; -int lwidth; -int lheight; -int pnum = 30000; -vsquare[][] v; -vbuffer[][] vbuf; -particle[] p = new particle[pnum]; -int pcount = 0; -int mouseXvel = 0; -int mouseYvel = 0; - -public void setup() -{ - size(200, 200); - noStroke(); - frameRate(30); - lwidth = width/res; - lheight = height/res; - v = new vsquare[lwidth+1][lheight+1]; - vbuf = new vbuffer[lwidth+1][lheight+1]; - for (int i = 0; i < pnum; i++) { - p[i] = new particle(random(res,width-res),random(res,height-res)); - } - for (int i = 0; i <= lwidth; i++) { - for (int u = 0; u <= lheight; u++) { - v[i][u] = new vsquare(i*res,u*res); - vbuf[i][u] = new vbuffer(i*res,u*res); - } - } -} - -public void draw() -{ - background(0xff666666); - - int axvel = mouseX-pmouseX; - int ayvel = mouseY-pmouseY; - - mouseXvel = (axvel != mouseXvel) ? axvel : 0; - mouseYvel = (ayvel != mouseYvel) ? ayvel : 0; - - for (int i = 0; i < lwidth; i++) { - for (int u = 0; u < lheight; u++) { - vbuf[i][u].updatebuf(i,u); - v[i][u].col = 32; - } - } - for (int i = 0; i < pnum-1; i++) { - p[i].updatepos(); - } - for (int i = 0; i < lwidth; i++) { - for (int u = 0; u < lheight; u++) { - v[i][u].addbuffer(i, u); - v[i][u].updatevels(mouseXvel, mouseYvel); - v[i][u].display(i, u); - } - } -} - -class particle { - float x; - float y; - float xvel; - float yvel; - int pos; - particle(float xIn, float yIn) { - x = xIn; - y = yIn; - } - - public void updatepos() { - float col1; - if (x > 0 && x < width && y > 0 && y < height) { - int vi = (int)(x/res); - int vu = (int)(y/res); - vsquare o = v[vi][vu]; - - float ax = (x%res)/res; - float ay = (y%res)/res; - - xvel += (1-ax)*v[vi][vu].xvel*0.05f; - yvel += (1-ay)*v[vi][vu].yvel*0.05f; - - xvel += ax*v[vi+1][vu].xvel*0.05f; - yvel += ax*v[vi+1][vu].yvel*0.05f; - - xvel += ay*v[vi][vu+1].xvel*0.05f; - yvel += ay*v[vi][vu+1].yvel*0.05f; - - o.col += 4; - - x += xvel; - y += yvel; - } - else { - x = random(0,width); - y = random(0,height); - xvel = 0; - yvel = 0; - } - - xvel *= 0.5f; - yvel *= 0.5f; - } -} - -class vbuffer { - int x; - int y; - float xvel; - float yvel; - float pressurex = 0; - float pressurey = 0; - float pressure = 0; - - vbuffer(int xIn,int yIn) { - x = xIn; - y = yIn; - pressurex = 0; - pressurey = 0; - } - - public void updatebuf(int i, int u) { - if (i>0 && i0 && u0 && i0 && u 255) col = 255; - if (i>0 && i0 && u 0 && x < width && y > 0 && y < height) { - int vi = (int)(x/res); - int vu = (int)(y/res); - vsquare o = v[vi][vu]; - - float ax = (x%res)/res; - float ay = (y%res)/res; - - xvel += (1-ax)*v[vi][vu].xvel*0.05; - yvel += (1-ay)*v[vi][vu].yvel*0.05; - - xvel += ax*v[vi+1][vu].xvel*0.05; - yvel += ax*v[vi+1][vu].yvel*0.05; - - xvel += ay*v[vi][vu+1].xvel*0.05; - yvel += ay*v[vi][vu+1].yvel*0.05; - - o.col += 4; - - x += xvel; - y += yvel; - } - else { - x = random(0,width); - y = random(0,height); - xvel = 0; - yvel = 0; - } - - xvel *= 0.5; - yvel *= 0.5; - } -} - -class vbuffer { - int x; - int y; - float xvel; - float yvel; - float pressurex = 0; - float pressurey = 0; - float pressure = 0; - - vbuffer(int xIn,int yIn) { - x = xIn; - y = yIn; - pressurex = 0; - pressurey = 0; - } - - void updatebuf(int i, int u) { - if (i>0 && i0 && u0 && i0 && u 255) col = 255; - if (i>0 && i0 && u= 0; i--) { - ParticleSystem psys = (ParticleSystem) psystems.get(i); - psys.run(); - if (psys.dead()) { - psystems.remove(i); - } - } - -} - -// When the mouse is pressed, add a new particle system -public void mousePressed() { - psystems.add(new ParticleSystem(PApplet.parseInt(random(5,25)),new Vector3D(mouseX,mouseY))); -} - - - - - - - - - - - -// A subclass of Particle - -class CrazyParticle extends Particle { - - // Just adding one new variable to a CrazyParticle - // It inherits all other fields from "Particle", and we don't have to retype them! - float theta; - - // The CrazyParticle constructor can call the parent class (super class) constructor - CrazyParticle(Vector3D l) { - // "super" means do everything from the constructor in Particle - super(l); - // One more line of code to deal with the new variable, theta - theta = 0.0f; - - } - - // Notice we don't have the method run() here; it is inherited from Particle - - // This update() method overrides the parent class update() method - public void update() { - super.update(); - // Increment rotation based on horizontal velocity - float theta_vel = (vel.x * vel.magnitude()) / 10.0f; - theta += theta_vel; - } - - // Override timer - public void timer() { - timer -= 0.5f; - } - - // Method to display - public void render() { - // Render the ellipse just like in a regular particle - super.render(); - - // Then add a rotating line - pushMatrix(); - translate(loc.x,loc.y); - rotate(theta); - stroke(255,timer); - line(0,0,25,0); - popMatrix(); - } -} - -// A simple Particle class - -class Particle { - Vector3D loc; - Vector3D vel; - Vector3D acc; - float r; - float timer; - - // One constructor - Particle(Vector3D a, Vector3D v, Vector3D l, float r_) { - acc = a.copy(); - vel = v.copy(); - loc = l.copy(); - r = r_; - timer = 100.0f; - } - - // Another constructor (the one we are using here) - Particle(Vector3D l) { - acc = new Vector3D(0,0.05f,0); - vel = new Vector3D(random(-1,1),random(-2,0),0); - loc = l.copy(); - r = 10.0f; - timer = 100.0f; - } - - - public void run() { - update(); - render(); - } - - // Method to update location - public void update() { - vel.add(acc); - loc.add(vel); - timer -= 1.0f; - } - - // Method to display - public void render() { - ellipseMode(CENTER); - stroke(255,timer); - fill(100,timer); - ellipse(loc.x,loc.y,r,r); - } - - // Is the particle still useful? - public boolean dead() { - if (timer <= 0.0f) { - return true; - } else { - return false; - } - } -} -// An ArrayList is used to manage the list of Particles - -class ParticleSystem { - - ArrayList particles; // An arraylist for all the particles - Vector3D origin; // An origin point for where particles are birthed - - ParticleSystem(int num, Vector3D v) { - particles = new ArrayList(); // Initialize the arraylist - origin = v.copy(); // Store the origin point - for (int i = 0; i < num; i++) { - // We have a 50% chance of adding each kind of particle - if (random(1) < 0.5f) { - particles.add(new CrazyParticle(origin)); - } else { - particles.add(new Particle(origin)); - } - } - } - - public void run() { - // Cycle through the ArrayList backwards b/c we are deleting - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - public void addParticle() { - particles.add(new Particle(origin)); - } - - public void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - public boolean dead() { - if (particles.isEmpty()) { - return true; - } - else { - return false; - } - } - -} - -// Simple Vector class - -class Vector3D { - float x; - float y; - float z; - - Vector3D(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - Vector3D(float x_, float y_) { - x = x_; - y = y_; - z = 0f; - } - - Vector3D() { - x = 0f; - y = 0f; - z = 0f; - } - - public void setX(float x_) { - x = x_; - } - - public void setY(float y_) { - y = y_; - } - - public void setZ(float z_) { - z = z_; - } - - public void setXY(float x_, float y_) { - x = x_; - y = y_; - } - - public void setXYZ(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - public void setXYZ(Vector3D v) { - x = v.x; - y = v.y; - z = v.z; - } - public float magnitude() { - return (float) Math.sqrt(x*x + y*y + z*z); - } - - public Vector3D copy() { - return new Vector3D(x,y,z); - } - - public Vector3D copy(Vector3D v) { - return new Vector3D(v.x, v.y,v.z); - } - - public void add(Vector3D v) { - x += v.x; - y += v.y; - z += v.z; - } - - public void sub(Vector3D v) { - x -= v.x; - y -= v.y; - z -= v.z; - } - - public void mult(float n) { - x *= n; - y *= n; - z *= n; - } - - public void div(float n) { - x /= n; - y /= n; - z /= n; - } - - /* float dot(Vector3D v) { - //implement DOT product - }*/ - - /* Vector3D cross(Vector3D v) { - //implement CROSS product - }*/ - - public void normalize() { - float m = magnitude(); - if (m > 0) { - div(m); - } - } - - public void limit(float max) { - if (magnitude() > max) { - normalize(); - mult(max); - } - } - - public float heading2D() { - float angle = (float) Math.atan2(-y, x); - return -1*angle; - } - - public Vector3D add(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z); - return v; - } - - public Vector3D sub(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x - v2.x,v1.y - v2.y,v1.z - v2.z); - return v; - } - - public Vector3D div(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x/n,v1.y/n,v1.z/n); - return v; - } - - public Vector3D mult(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x*n,v1.y*n,v1.z*n); - return v; - } - - public float distance (Vector3D v1, Vector3D v2) { - float dx = v1.x - v2.x; - float dy = v1.y - v2.y; - float dz = v1.z - v2.z; - return (float) Math.sqrt(dx*dx + dy*dy + dz*dz); - } - - public void display(float x, float y, float scayl) { - pushMatrix(); - float arrowsize = 4; - // Translate to location to render vector - translate(x,y); - stroke(255); - // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate - rotate(heading2D()); - // Calculate length of vector & scale it to be bigger or smaller if necessary - float len = magnitude()*scayl; - // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction) - line(0,0,len,0); - line(len,0,len-arrowsize,+arrowsize/2); - line(len,0,len-arrowsize,-arrowsize/2); - popMatrix(); - } - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "MultipleParticleSystems" }); - } -} diff --git a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/MultipleParticleSystems.pde b/android/examples/Topics/Simulate/MultipleParticleSystems/applet/MultipleParticleSystems.pde deleted file mode 100644 index 487cf2f21..000000000 --- a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/MultipleParticleSystems.pde +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Multiple Particle Systems - * by Daniel Shiffman. - * - * Click the mouse to generate a burst of particles - * at mouse location. - * - * Each burst is one instance of a particle system - * with Particles and CrazyParticles (a subclass of Particle) - * Note use of Inheritance and Polymorphism here. - */ - -ArrayList psystems; - -void setup() { - size(640, 360); - colorMode(RGB, 255, 255, 255, 100); - psystems = new ArrayList(); - smooth(); -} - -void draw() { - background(0); - - // Cycle through all particle systems, run them and delete old ones - for (int i = psystems.size()-1; i >= 0; i--) { - ParticleSystem psys = (ParticleSystem) psystems.get(i); - psys.run(); - if (psys.dead()) { - psystems.remove(i); - } - } - -} - -// When the mouse is pressed, add a new particle system -void mousePressed() { - psystems.add(new ParticleSystem(int(random(5,25)),new Vector3D(mouseX,mouseY))); -} - - - - - - - - - - - diff --git a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/Particle.pde b/android/examples/Topics/Simulate/MultipleParticleSystems/applet/Particle.pde deleted file mode 100644 index c91d1a547..000000000 --- a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/Particle.pde +++ /dev/null @@ -1,57 +0,0 @@ -// A simple Particle class - -class Particle { - Vector3D loc; - Vector3D vel; - Vector3D acc; - float r; - float timer; - - // One constructor - Particle(Vector3D a, Vector3D v, Vector3D l, float r_) { - acc = a.copy(); - vel = v.copy(); - loc = l.copy(); - r = r_; - timer = 100.0; - } - - // Another constructor (the one we are using here) - Particle(Vector3D l) { - acc = new Vector3D(0,0.05,0); - vel = new Vector3D(random(-1,1),random(-2,0),0); - loc = l.copy(); - r = 10.0; - timer = 100.0; - } - - - void run() { - update(); - render(); - } - - // Method to update location - void update() { - vel.add(acc); - loc.add(vel); - timer -= 1.0; - } - - // Method to display - void render() { - ellipseMode(CENTER); - stroke(255,timer); - fill(100,timer); - ellipse(loc.x,loc.y,r,r); - } - - // Is the particle still useful? - boolean dead() { - if (timer <= 0.0) { - return true; - } else { - return false; - } - } -} diff --git a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/ParticleSystem.pde b/android/examples/Topics/Simulate/MultipleParticleSystems/applet/ParticleSystem.pde deleted file mode 100644 index f4615c81c..000000000 --- a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/ParticleSystem.pde +++ /dev/null @@ -1,51 +0,0 @@ -// An ArrayList is used to manage the list of Particles - -class ParticleSystem { - - ArrayList particles; // An arraylist for all the particles - Vector3D origin; // An origin point for where particles are birthed - - ParticleSystem(int num, Vector3D v) { - particles = new ArrayList(); // Initialize the arraylist - origin = v.copy(); // Store the origin point - for (int i = 0; i < num; i++) { - // We have a 50% chance of adding each kind of particle - if (random(1) < 0.5) { - particles.add(new CrazyParticle(origin)); - } else { - particles.add(new Particle(origin)); - } - } - } - - void run() { - // Cycle through the ArrayList backwards b/c we are deleting - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - void addParticle() { - particles.add(new Particle(origin)); - } - - void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - boolean dead() { - if (particles.isEmpty()) { - return true; - } - else { - return false; - } - } - -} - diff --git a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/loading.gif b/android/examples/Topics/Simulate/MultipleParticleSystems/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/MultipleParticleSystems/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/Particle.pde b/android/examples/Topics/Simulate/SimpleParticleSystem/applet/Particle.pde deleted file mode 100644 index baba584c8..000000000 --- a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/Particle.pde +++ /dev/null @@ -1,49 +0,0 @@ -// A simple Particle class - -class Particle { - Vector3D loc; - Vector3D vel; - Vector3D acc; - float r; - float timer; - - // Another constructor (the one we are using here) - Particle(Vector3D l) { - acc = new Vector3D(0,0.05,0); - vel = new Vector3D(random(-1,1),random(-2,0),0); - loc = l.copy(); - r = 10.0; - timer = 100.0; - } - - void run() { - update(); - render(); - } - - // Method to update location - void update() { - vel.add(acc); - loc.add(vel); - timer -= 1.0; - } - - // Method to display - void render() { - ellipseMode(CENTER); - stroke(255,timer); - fill(100,timer); - ellipse(loc.x,loc.y,r,r); - vel.display(loc.x,loc.y,10); - } - - // Is the particle still useful? - boolean dead() { - if (timer <= 0.0) { - return true; - } else { - return false; - } - } -} - diff --git a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/ParticleSystem.pde b/android/examples/Topics/Simulate/SimpleParticleSystem/applet/ParticleSystem.pde deleted file mode 100644 index 29250c55d..000000000 --- a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/ParticleSystem.pde +++ /dev/null @@ -1,50 +0,0 @@ -// A class to describe a group of Particles -// An ArrayList is used to manage the list of Particles - -class ParticleSystem { - - ArrayList particles; // An arraylist for all the particles - Vector3D origin; // An origin point for where particles are born - - ParticleSystem(int num, Vector3D v) { - particles = new ArrayList(); // Initialize the arraylist - origin = v.copy(); // Store the origin point - for (int i = 0; i < num; i++) { - particles.add(new Particle(origin)); // Add "num" amount of particles to the arraylist - } - } - - void run() { - // Cycle through the ArrayList backwards b/c we are deleting - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - void addParticle() { - particles.add(new Particle(origin)); - } - - void addParticle(float x, float y) { - particles.add(new Particle(new Vector3D(x,y))); - } - - void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - boolean dead() { - if (particles.isEmpty()) { - return true; - } else { - return false; - } - } - -} - diff --git a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.java b/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.java deleted file mode 100644 index f1524a730..000000000 --- a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.java +++ /dev/null @@ -1,308 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class SimpleParticleSystem extends PApplet { - -/** - * Simple Particle System - * by Daniel Shiffman. - * - * Particles are generated each cycle through draw(), - * fall with gravity and fade out over time - * A ParticleSystem object manages a variable size (ArrayList) - * list of particles. - */ - -ParticleSystem ps; - -public void setup() { - size(640, 360); - colorMode(RGB, 255, 255, 255, 100); - ps = new ParticleSystem(1,new Vector3D(width/2,height/2,0)); - smooth(); -} - -public void draw() { - background(0); - ps.run(); - ps.addParticle(mouseX,mouseY); -} - - - -// A simple Particle class - -class Particle { - Vector3D loc; - Vector3D vel; - Vector3D acc; - float r; - float timer; - - // Another constructor (the one we are using here) - Particle(Vector3D l) { - acc = new Vector3D(0,0.05f,0); - vel = new Vector3D(random(-1,1),random(-2,0),0); - loc = l.copy(); - r = 10.0f; - timer = 100.0f; - } - - public void run() { - update(); - render(); - } - - // Method to update location - public void update() { - vel.add(acc); - loc.add(vel); - timer -= 1.0f; - } - - // Method to display - public void render() { - ellipseMode(CENTER); - stroke(255,timer); - fill(100,timer); - ellipse(loc.x,loc.y,r,r); - vel.display(loc.x,loc.y,10); - } - - // Is the particle still useful? - public boolean dead() { - if (timer <= 0.0f) { - return true; - } else { - return false; - } - } -} - -// A class to describe a group of Particles -// An ArrayList is used to manage the list of Particles - -class ParticleSystem { - - ArrayList particles; // An arraylist for all the particles - Vector3D origin; // An origin point for where particles are born - - ParticleSystem(int num, Vector3D v) { - particles = new ArrayList(); // Initialize the arraylist - origin = v.copy(); // Store the origin point - for (int i = 0; i < num; i++) { - particles.add(new Particle(origin)); // Add "num" amount of particles to the arraylist - } - } - - public void run() { - // Cycle through the ArrayList backwards b/c we are deleting - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - public void addParticle() { - particles.add(new Particle(origin)); - } - - public void addParticle(float x, float y) { - particles.add(new Particle(new Vector3D(x,y))); - } - - public void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - public boolean dead() { - if (particles.isEmpty()) { - return true; - } else { - return false; - } - } - -} - -// Simple Vector class - -class Vector3D { - float x; - float y; - float z; - - Vector3D(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - Vector3D(float x_, float y_) { - x = x_; - y = y_; - z = 0f; - } - - Vector3D() { - x = 0f; - y = 0f; - z = 0f; - } - - public void setX(float x_) { - x = x_; - } - - public void setY(float y_) { - y = y_; - } - - public void setZ(float z_) { - z = z_; - } - - public void setXY(float x_, float y_) { - x = x_; - y = y_; - } - - public void setXYZ(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - public void setXYZ(Vector3D v) { - x = v.x; - y = v.y; - z = v.z; - } - public float magnitude() { - return (float) Math.sqrt(x*x + y*y + z*z); - } - - public Vector3D copy() { - return new Vector3D(x,y,z); - } - - public Vector3D copy(Vector3D v) { - return new Vector3D(v.x, v.y,v.z); - } - - public void add(Vector3D v) { - x += v.x; - y += v.y; - z += v.z; - } - - public void sub(Vector3D v) { - x -= v.x; - y -= v.y; - z -= v.z; - } - - public void mult(float n) { - x *= n; - y *= n; - z *= n; - } - - public void div(float n) { - x /= n; - y /= n; - z /= n; - } - - /* float dot(Vector3D v) { - //implement DOT product - }*/ - - /* Vector3D cross(Vector3D v) { - //implement CROSS product - }*/ - - public void normalize() { - float m = magnitude(); - if (m > 0) { - div(m); - } - } - - public void limit(float max) { - if (magnitude() > max) { - normalize(); - mult(max); - } - } - - public float heading2D() { - float angle = (float) Math.atan2(-y, x); - return -1*angle; - } - - public Vector3D add(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z); - return v; - } - - public Vector3D sub(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x - v2.x,v1.y - v2.y,v1.z - v2.z); - return v; - } - - public Vector3D div(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x/n,v1.y/n,v1.z/n); - return v; - } - - public Vector3D mult(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x*n,v1.y*n,v1.z*n); - return v; - } - - public float distance (Vector3D v1, Vector3D v2) { - float dx = v1.x - v2.x; - float dy = v1.y - v2.y; - float dz = v1.z - v2.z; - return (float) Math.sqrt(dx*dx + dy*dy + dz*dz); - } - - public void display(float x, float y, float scayl) { - pushMatrix(); - float arrowsize = 4; - // Translate to location to render vector - translate(x,y); - // stroke(255); - // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate - rotate(heading2D()); - // Calculate length of vector & scale it to be bigger or smaller if necessary - float len = magnitude()*scayl; - // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction) - line(0,0,len,0); - line(len,0,len-arrowsize,+arrowsize/2); - line(len,0,len-arrowsize,-arrowsize/2); - popMatrix(); - } - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "SimpleParticleSystem" }); - } -} diff --git a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.pde b/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.pde deleted file mode 100644 index 148b53c0c..000000000 --- a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/SimpleParticleSystem.pde +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Simple Particle System - * by Daniel Shiffman. - * - * Particles are generated each cycle through draw(), - * fall with gravity and fade out over time - * A ParticleSystem object manages a variable size (ArrayList) - * list of particles. - */ - -ParticleSystem ps; - -void setup() { - size(640, 360); - colorMode(RGB, 255, 255, 255, 100); - ps = new ParticleSystem(1,new Vector3D(width/2,height/2,0)); - smooth(); -} - -void draw() { - background(0); - ps.run(); - ps.addParticle(mouseX,mouseY); -} - - - diff --git a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/loading.gif b/android/examples/Topics/Simulate/SimpleParticleSystem/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/SimpleParticleSystem/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/Smoke/applet/Smoke.java b/android/examples/Topics/Simulate/Smoke/applet/Smoke.java deleted file mode 100644 index 80bc64ba4..000000000 --- a/android/examples/Topics/Simulate/Smoke/applet/Smoke.java +++ /dev/null @@ -1,284 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Smoke extends PApplet { - -/** - * Smoke - * by Glen Murphy. - * - * Drag the mouse across the image to move the particles. - * Code has not been optimised and will run fairly slowly. - */ - -int res = 2; -int penSize = 30; -int lwidth; -int lheight; -int pnum = 30000; -vsquare[][] v; -vbuffer[][] vbuf; -particle[] p; -int pcount = 0; -int mouseXvel = 0; -int mouseYvel = 0; - -int randomGust = 0; -int randomGustMax; -float randomGustX; -float randomGustY; -float randomGustSize; -float randomGustXvel; -float randomGustYvel; - -public void setup() -{ - size(200, 200); - lwidth = width/res; - lheight = height/res; - v = new vsquare[lwidth+1][lheight+1]; - vbuf = new vbuffer[lwidth+1][lheight+1]; - p = new particle[pnum]; - noStroke(); - for(int i = 0; i < pnum; i++) { - p[i] = new particle(random(width/2-20,width/2+20),random(height-20,height)); - } - for(int i = 0; i <= lwidth; i++) { - for(int u = 0; u <= lheight; u++) { - v[i][u] = new vsquare(i*res,u*res); - vbuf[i][u] = new vbuffer(i*res,u*res); - } - } -} - -public void draw() -{ - background(0xffcccccc); - - int axvel = mouseX-pmouseX; - int ayvel = mouseY-pmouseY; - - mouseXvel = (axvel != mouseXvel) ? axvel : 0; - mouseYvel = (ayvel != mouseYvel) ? ayvel : 0; - - if(randomGust <= 0) { - if(random(0,10)<1) { - randomGustMax = (int)random(5,12); - randomGust = randomGustMax; - randomGustX = random(0,width); - randomGustY = random(0,height-10); - randomGustSize = random(0,50); - if(randomGustX > width/2) { - randomGustXvel = random(-8,0); - } else { - randomGustXvel = random(0,8); - } - randomGustYvel = random(-2,1); - } - randomGust--; - } - - for(int i = 0; i < lwidth; i++) { - for(int u = 0; u < lheight; u++) { - vbuf[i][u].updatebuf(i,u); - v[i][u].col = 0; - } - } - for(int i = 0; i < pnum-1; i++) { - p[i].updatepos(); - } - for(int i = 0; i < lwidth; i++) { - for(int u = 0; u < lheight; u++) { - v[i][u].addbuffer(i, u); - v[i][u].updatevels(mouseXvel, mouseYvel); - v[i][u].display(i, u); - } - } - randomGust = 0; -} - -class particle -{ - float x; - float y; - float xvel; - float yvel; - float temp; - int pos; - - particle(float xIn, float yIn) { - x = xIn; - y = yIn; - } - - public void reposition() { - x = width/2+random(-20,20); - y = random(height-10,height); - - xvel = random(-1,1); - yvel = random(-1,1); - } - - public void updatepos() { - int vi = (int)(x/res); - int vu = (int)(y/res); - - if(vi > 0 && vi < lwidth && vu > 0 && vu < lheight) { - v[vi][vu].addcolour(2); - - float ax = (x%res)/res; - float ay = (y%res)/res; - - xvel += (1-ax)*v[vi][vu].xvel*0.05f; - yvel += (1-ay)*v[vi][vu].yvel*0.05f; - - xvel += ax*v[vi+1][vu].xvel*0.05f; - yvel += ax*v[vi+1][vu].yvel*0.05f; - - xvel += ay*v[vi][vu+1].xvel*0.05f; - yvel += ay*v[vi][vu+1].yvel*0.05f; - - v[vi][vu].yvel -= (1-ay)*0.003f; - v[vi+1][vu].yvel -= ax*0.003f; - - if(v[vi][vu].yvel < 0) v[vi][vu].yvel *= 1.00025f; - - x += xvel; - y += yvel; - } - else { - reposition(); - } - if(random(0,400) < 1) { - reposition(); - } - xvel *= 0.6f; - yvel *= 0.6f; - } -} - -class vbuffer -{ - int x; - int y; - float xvel; - float yvel; - float pressurex = 0; - float pressurey = 0; - float pressure = 0; - - vbuffer(int xIn,int yIn) { - x = xIn; - y = yIn; - pressurex = 0; - pressurey = 0; - } - - public void updatebuf(int i, int u) { - if(i>0 && i0 && u0 && i0 && u 0) { - adj = x - randomGustX; - opp = y - randomGustY; - dist = sqrt(opp*opp + adj*adj); - if(dist < randomGustSize) { - if(dist < res*2) dist = randomGustSize; - mod = randomGustSize/dist; - xvel += (randomGustMax-randomGust)*randomGustXvel*mod; - yvel += (randomGustMax-randomGust)*randomGustYvel*mod; - } - } - xvel *= 0.99f; - yvel *= 0.98f; - } - - public void addcolour(int amt) { - col += amt; - if(col > 196) col = 196; - } - - public void display(int i, int u) { - float tcol = 0; - if(i>0 && i0 && u width/2) { - randomGustXvel = random(-8,0); - } else { - randomGustXvel = random(0,8); - } - randomGustYvel = random(-2,1); - } - randomGust--; - } - - for(int i = 0; i < lwidth; i++) { - for(int u = 0; u < lheight; u++) { - vbuf[i][u].updatebuf(i,u); - v[i][u].col = 0; - } - } - for(int i = 0; i < pnum-1; i++) { - p[i].updatepos(); - } - for(int i = 0; i < lwidth; i++) { - for(int u = 0; u < lheight; u++) { - v[i][u].addbuffer(i, u); - v[i][u].updatevels(mouseXvel, mouseYvel); - v[i][u].display(i, u); - } - } - randomGust = 0; -} - -class particle -{ - float x; - float y; - float xvel; - float yvel; - float temp; - int pos; - - particle(float xIn, float yIn) { - x = xIn; - y = yIn; - } - - void reposition() { - x = width/2+random(-20,20); - y = random(height-10,height); - - xvel = random(-1,1); - yvel = random(-1,1); - } - - void updatepos() { - int vi = (int)(x/res); - int vu = (int)(y/res); - - if(vi > 0 && vi < lwidth && vu > 0 && vu < lheight) { - v[vi][vu].addcolour(2); - - float ax = (x%res)/res; - float ay = (y%res)/res; - - xvel += (1-ax)*v[vi][vu].xvel*0.05; - yvel += (1-ay)*v[vi][vu].yvel*0.05; - - xvel += ax*v[vi+1][vu].xvel*0.05; - yvel += ax*v[vi+1][vu].yvel*0.05; - - xvel += ay*v[vi][vu+1].xvel*0.05; - yvel += ay*v[vi][vu+1].yvel*0.05; - - v[vi][vu].yvel -= (1-ay)*0.003; - v[vi+1][vu].yvel -= ax*0.003; - - if(v[vi][vu].yvel < 0) v[vi][vu].yvel *= 1.00025; - - x += xvel; - y += yvel; - } - else { - reposition(); - } - if(random(0,400) < 1) { - reposition(); - } - xvel *= 0.6; - yvel *= 0.6; - } -} - -class vbuffer -{ - int x; - int y; - float xvel; - float yvel; - float pressurex = 0; - float pressurey = 0; - float pressure = 0; - - vbuffer(int xIn,int yIn) { - x = xIn; - y = yIn; - pressurex = 0; - pressurey = 0; - } - - void updatebuf(int i, int u) { - if(i>0 && i0 && u0 && i0 && u 0) { - adj = x - randomGustX; - opp = y - randomGustY; - dist = sqrt(opp*opp + adj*adj); - if(dist < randomGustSize) { - if(dist < res*2) dist = randomGustSize; - mod = randomGustSize/dist; - xvel += (randomGustMax-randomGust)*randomGustXvel*mod; - yvel += (randomGustMax-randomGust)*randomGustYvel*mod; - } - } - xvel *= 0.99; - yvel *= 0.98; - } - - void addcolour(int amt) { - col += amt; - if(col > 196) col = 196; - } - - void display(int i, int u) { - float tcol = 0; - if(i>0 && i0 && u= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - // Method to add a force vector to all particles currently in the system - void add_force(Vector3D dir) { - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.add_force(dir); - } - - } - - void addParticle() { - particles.add(new Particle(origin,img)); - } - - void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - boolean dead() { - if (particles.isEmpty()) { - return true; - } else { - return false; - } - } - -} - diff --git a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.java b/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.java deleted file mode 100644 index b53b27fc2..000000000 --- a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.java +++ /dev/null @@ -1,360 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class SmokeParticleSystem extends PApplet { - -/** - * Smoke Particle System - * by Daniel Shiffman. - * - * A basic smoke effect using a particle system. - * Each particle is rendered as an alpha masked image. - */ - -ParticleSystem ps; -Random generator; - -public void setup() { - - size(640, 200); - colorMode(RGB, 255, 255, 255, 100); - - // Using a Java random number generator for Gaussian random numbers - generator = new Random(); - - // Create an alpha masked image to be applied as the particle's texture - PImage msk = loadImage("texture.gif"); - PImage img = new PImage(msk.width,msk.height); - for (int i = 0; i < img.pixels.length; i++) img.pixels[i] = color(255); - img.mask(msk); - ps = new ParticleSystem(0,new Vector3D(width/2,height-20),img); - - smooth(); -} - -public void draw() { - background(75); - - // Calculate a "wind" force based on mouse horizontal position - float dx = (mouseX - width/2) / 1000.0f; - Vector3D wind = new Vector3D(dx,0,0); - wind.display(width/2,50,500); - ps.add_force(wind); - ps.run(); - for (int i = 0; i < 2; i++) { - ps.addParticle(); - } -} - - - - - - - - - - - -// A simple Particle class, renders the particle as an image - -class Particle { - Vector3D loc; - Vector3D vel; - Vector3D acc; - float timer; - PImage img; - - // One constructor - Particle(Vector3D a, Vector3D v, Vector3D l, PImage img_) { - acc = a.copy(); - vel = v.copy(); - loc = l.copy(); - timer = 100.0f; - img = img_; - } - - // Another constructor (the one we are using here) - Particle(Vector3D l,PImage img_) { - acc = new Vector3D(0.0f,0.0f,0.0f); - float x = (float) generator.nextGaussian()*0.3f; - float y = (float) generator.nextGaussian()*0.3f - 1.0f; - vel = new Vector3D(x,y,0); - loc = l.copy(); - timer = 100.0f; - img = img_; - } - - public void run() { - update(); - render(); - } - - // Method to apply a force vector to the Particle object - // Note we are ignoring "mass" here - public void add_force(Vector3D f) { - acc.add(f); - } - - // Method to update location - public void update() { - vel.add(acc); - loc.add(vel); - timer -= 2.5f; - acc.setXY(0,0); - } - - // Method to display - public void render() { - imageMode(CORNER); - tint(255,timer); - image(img,loc.x-img.width/2,loc.y-img.height/2); - } - - // Is the particle still useful? - public boolean dead() { - if (timer <= 0.0f) { - return true; - } else { - return false; - } - } -} - - - - -// A class to describe a group of Particles -// An ArrayList is used to manage the list of Particles - -class ParticleSystem { - - ArrayList particles; // An arraylist for all the particles - Vector3D origin; // An origin point for where particles are birthed - PImage img; - - ParticleSystem(int num, Vector3D v, PImage img_) { - particles = new ArrayList(); // Initialize the arraylist - origin = v.copy(); // Store the origin point - img = img_; - for (int i = 0; i < num; i++) { - particles.add(new Particle(origin, img)); // Add "num" amount of particles to the arraylist - } - } - - public void run() { - // Cycle through the ArrayList backwards b/c we are deleting - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.run(); - if (p.dead()) { - particles.remove(i); - } - } - } - - // Method to add a force vector to all particles currently in the system - public void add_force(Vector3D dir) { - for (int i = particles.size()-1; i >= 0; i--) { - Particle p = (Particle) particles.get(i); - p.add_force(dir); - } - - } - - public void addParticle() { - particles.add(new Particle(origin,img)); - } - - public void addParticle(Particle p) { - particles.add(p); - } - - // A method to test if the particle system still has particles - public boolean dead() { - if (particles.isEmpty()) { - return true; - } else { - return false; - } - } - -} - -// Simple Vector class - -class Vector3D { - float x; - float y; - float z; - - Vector3D(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - Vector3D(float x_, float y_) { - x = x_; - y = y_; - z = 0f; - } - - Vector3D() { - x = 0f; - y = 0f; - z = 0f; - } - - public void setX(float x_) { - x = x_; - } - - public void setY(float y_) { - y = y_; - } - - public void setZ(float z_) { - z = z_; - } - - public void setXY(float x_, float y_) { - x = x_; - y = y_; - } - - public void setXYZ(float x_, float y_, float z_) { - x = x_; - y = y_; - z = z_; - } - - public void setXYZ(Vector3D v) { - x = v.x; - y = v.y; - z = v.z; - } - public float magnitude() { - return (float) Math.sqrt(x*x + y*y + z*z); - } - - public Vector3D copy() { - return new Vector3D(x,y,z); - } - - public Vector3D copy(Vector3D v) { - return new Vector3D(v.x, v.y,v.z); - } - - public void add(Vector3D v) { - x += v.x; - y += v.y; - z += v.z; - } - - public void sub(Vector3D v) { - x -= v.x; - y -= v.y; - z -= v.z; - } - - public void mult(float n) { - x *= n; - y *= n; - z *= n; - } - - public void div(float n) { - x /= n; - y /= n; - z /= n; - } - - /* float dot(Vector3D v) { - //implement DOT product - }*/ - - /* Vector3D cross(Vector3D v) { - //implement CROSS product - }*/ - - public void normalize() { - float m = magnitude(); - if (m > 0) { - div(m); - } - } - - public void limit(float max) { - if (magnitude() > max) { - normalize(); - mult(max); - } - } - - public float heading2D() { - float angle = (float) Math.atan2(-y, x); - return -1*angle; - } - - public Vector3D add(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z); - return v; - } - - public Vector3D sub(Vector3D v1, Vector3D v2) { - Vector3D v = new Vector3D(v1.x - v2.x,v1.y - v2.y,v1.z - v2.z); - return v; - } - - public Vector3D div(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x/n,v1.y/n,v1.z/n); - return v; - } - - public Vector3D mult(Vector3D v1, float n) { - Vector3D v = new Vector3D(v1.x*n,v1.y*n,v1.z*n); - return v; - } - - public float distance (Vector3D v1, Vector3D v2) { - float dx = v1.x - v2.x; - float dy = v1.y - v2.y; - float dz = v1.z - v2.z; - return (float) Math.sqrt(dx*dx + dy*dy + dz*dz); - } - - public void display(float x, float y, float scayl) { - pushMatrix(); - float arrowsize = 4; - // Translate to location to render vector - translate(x,y); - stroke(255); - // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate - rotate(heading2D()); - // Calculate length of vector & scale it to be bigger or smaller if necessary - float len = magnitude()*scayl; - // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction) - line(0,0,len,0); - line(len,0,len-arrowsize,+arrowsize/2); - line(len,0,len-arrowsize,-arrowsize/2); - popMatrix(); - } - -} - - - static public void main(String args[]) { - PApplet.main(new String[] { "SmokeParticleSystem" }); - } -} diff --git a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.pde b/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.pde deleted file mode 100644 index 4a30fc970..000000000 --- a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/SmokeParticleSystem.pde +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Smoke Particle System - * by Daniel Shiffman. - * - * A basic smoke effect using a particle system. - * Each particle is rendered as an alpha masked image. - */ - -ParticleSystem ps; -Random generator; - -void setup() { - - size(640, 200); - colorMode(RGB, 255, 255, 255, 100); - - // Using a Java random number generator for Gaussian random numbers - generator = new Random(); - - // Create an alpha masked image to be applied as the particle's texture - PImage msk = loadImage("texture.gif"); - PImage img = new PImage(msk.width,msk.height); - for (int i = 0; i < img.pixels.length; i++) img.pixels[i] = color(255); - img.mask(msk); - ps = new ParticleSystem(0,new Vector3D(width/2,height-20),img); - - smooth(); -} - -void draw() { - background(75); - - // Calculate a "wind" force based on mouse horizontal position - float dx = (mouseX - width/2) / 1000.0; - Vector3D wind = new Vector3D(dx,0,0); - wind.display(width/2,50,500); - ps.add_force(wind); - ps.run(); - for (int i = 0; i < 2; i++) { - ps.addParticle(); - } -} - - - - - - - - - - diff --git a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/loading.gif b/android/examples/Topics/Simulate/SmokeParticleSystem/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/SmokeParticleSystem/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/SoftBody/applet/SoftBody.java b/android/examples/Topics/Simulate/SoftBody/applet/SoftBody.java deleted file mode 100644 index de3f7e74f..000000000 --- a/android/examples/Topics/Simulate/SoftBody/applet/SoftBody.java +++ /dev/null @@ -1,119 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class SoftBody extends PApplet { - -/** - * Soft Body - * by Ira Greenberg. - * - * Softbody dynamics simulation using curveVertex() and curveTightness(). - */ - -// center point -float centerX = 0, centerY = 0; - -float radius = 45, rotAngle = -90; -float accelX, accelY; -float springing = .0009f, damping = .98f; - -//corner nodes -int nodes = 5; -float nodeStartX[] = new float[nodes]; -float nodeStartY[] = new float[nodes]; -float[]nodeX = new float[nodes]; -float[]nodeY = new float[nodes]; -float[]angle = new float[nodes]; -float[]frequency = new float[nodes]; - -// soft-body dynamics -float organicConstant = 1; - -public void setup() { - size(640, 360); - //center shape in window - centerX = width/2; - centerY = height/2; - // iniitalize frequencies for corner nodes - for (int i=0; i left && mouseX < right && mouseY > ps && mouseY < ps + s_height) { - over = true; - } else { - over = false; - } - - // Set and constrain the position of top bar - if(move) { - ps = mouseY - s_height/2; - if (ps < min) { ps = min; } - if (ps > max) { ps = max; } - } -} - -public void mousePressed() { - if(over) { - move = true; - } -} - -public void mouseReleased() -{ - move = false; -} - - static public void main(String args[]) { - PApplet.main(new String[] { "Spring" }); - } -} diff --git a/android/examples/Topics/Simulate/Spring/applet/Spring.pde b/android/examples/Topics/Simulate/Spring/applet/Spring.pde deleted file mode 100644 index e36286bd9..000000000 --- a/android/examples/Topics/Simulate/Spring/applet/Spring.pde +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Spring. - * - * Click, drag, and release the horizontal bar to start the spring. - */ - -// Spring drawing constants for top bar -int s_height = 16; // Height -int left = 50; // Left position -int right = 150; // Right position -int max = 100; // Maximum Y value -int min = 20; // Minimum Y value -boolean over = false; // If mouse over -boolean move = false; // If mouse down and over - -// Spring simulation constants -float M = 0.8; // Mass -float K = 0.2; // Spring constant -float D = 0.92; // Damping -float R = 60; // Rest position - -// Spring simulation variables -float ps = 60.0; // Position -float vs = 0.0; // Velocity -float as = 0; // Acceleration -float f = 0; // Force - - -void setup() -{ - size(200, 200); - rectMode(CORNERS); - noStroke(); -} - -void draw() -{ - background(102); - updateSpring(); - drawSpring(); -} - -void drawSpring() -{ - // Draw base - fill(0.2); - float b_width = 0.5 * ps + -8; - rect(width/2 - b_width, ps + s_height, width/2 + b_width, 150); - - // Set color and draw top bar - if(over || move) { - fill(255); - } else { - fill(204); - } - rect(left, ps, right, ps + s_height); -} - - -void updateSpring() -{ - // Update the spring position - if(!move) { - f = -K * (ps - R); // f=-ky - as = f / M; // Set the acceleration, f=ma == a=f/m - vs = D * (vs + as); // Set the velocity - ps = ps + vs; // Updated position - } - if(abs(vs) < 0.1) { - vs = 0.0; - } - - // Test if mouse is over the top bar - if(mouseX > left && mouseX < right && mouseY > ps && mouseY < ps + s_height) { - over = true; - } else { - over = false; - } - - // Set and constrain the position of top bar - if(move) { - ps = mouseY - s_height/2; - if (ps < min) { ps = min; } - if (ps > max) { ps = max; } - } -} - -void mousePressed() { - if(over) { - move = true; - } -} - -void mouseReleased() -{ - move = false; -} diff --git a/android/examples/Topics/Simulate/Spring/applet/loading.gif b/android/examples/Topics/Simulate/Spring/applet/loading.gif deleted file mode 100644 index 1ddae5089..000000000 Binary files a/android/examples/Topics/Simulate/Spring/applet/loading.gif and /dev/null differ diff --git a/android/examples/Topics/Simulate/Springs/applet/Springs.java b/android/examples/Topics/Simulate/Springs/applet/Springs.java deleted file mode 100644 index 6b96d128f..000000000 --- a/android/examples/Topics/Simulate/Springs/applet/Springs.java +++ /dev/null @@ -1,182 +0,0 @@ -import processing.core.*; - -import java.applet.*; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; -import java.util.zip.*; -import java.util.regex.*; - -public class Springs extends PApplet { - -/** - * Springs. - * - * Move the mouse over one of the circles and click to re-position. - * When you release the mouse, it will snap back into position. - * Each circle has a slightly different behavior. - */ - - -int num = 3; -Spring[] springs = new Spring[num]; - -public void setup() -{ - size(200, 200); - noStroke(); - smooth(); - springs[0] = new Spring( 70, 160, 20, 0.98f, 8.0f, 0.1f, springs, 0); - springs[1] = new Spring(150, 110, 60, 0.95f, 9.0f, 0.1f, springs, 1); - springs[2] = new Spring( 40, 70, 120, 0.90f, 9.9f, 0.1f, springs, 2); -} - -public void draw() -{ - background(51); - - for (int i = 0; i < num; i++) { - springs[i].update(); - springs[i].display(); - } -} - -public void mousePressed() -{ - for (int i = 0; i < num; i++) { - springs[i].pressed(); - } -} - -public void mouseReleased() -{ - for (int i=0; i