Examples updates for 2.0

This commit is contained in:
Casey Reas
2011-07-17 06:50:01 +00:00
parent d996b52e66
commit 84dd359b1e
33 changed files with 305 additions and 280 deletions
+26 -17
View File
@@ -10,26 +10,35 @@
* separate ways on the screen.
*/
size(200, 200);
float[] coswave = new float[width];
float[] coswave;
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
void setup() {
size(640, 360);
coswave = new float[width];
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
noLoop();
}
for (int i = 0; i < width; i++) {
stroke(coswave[i]*255);
line(i, 0, i, height/3);
void draw() {
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);
}
}
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);
}
+19 -14
View File
@@ -6,27 +6,32 @@
* 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;
int spacer = 10;
size(200, 200);
background(0);
maxDistance = dist(width/2, height/2, width, height);
distances = new float[width][height];
for(int i=0; i<height; i++) {
for(int j=0; j<width; j++) {
float dist = dist(width/2, height/2, j, i);
distances[j][i] = dist/maxDistance * 255;
void setup() {
size(640, 360);
maxDistance = dist(width/2, height/2, width, height);
distances = new float[width][height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float dist = dist(width/2, height/2, x, y);
distances[x][y] = dist/maxDistance * 255;
}
}
noLoop(); // Run once and stop
}
for(int i=0; i<height; i+=2) {
for(int j=0; j<width; j+=2) {
stroke(distances[j][i]);
point(j, i);
void draw() {
background(0);
for (int y = 0; y < height; y += spacer) {
for (int x = 0; x < width; x += spacer) {
stroke(distances[x][y]);
point(x + spacer/2, y + spacer/2);
}
}
}
@@ -10,12 +10,11 @@ int unit = 40;
int count;
Module[] mods;
void setup() {
size(320, 240);
size(640, 360);
background(176);
noStroke();
smooth();
int wideCount = width / unit;
int highCount = height / unit;
count = wideCount * highCount;
@@ -24,13 +23,13 @@ void setup() {
int index = 0;
for (int y = 0; y < highCount; y++) {
for (int x = 0; x < wideCount; x++) {
mods[index++] = new Module(x*unit, y*unit, unit/2, unit/2, random(0.05, 0.8));
mods[index++] = new Module(x*unit, y*unit, unit/2, unit/2, random(0.05, 0.8), unit);
}
}
}
void draw() {
background(0);
for (int i = 0; i < count; i++) {
mods[i].update();
mods[i].draw();
@@ -1,38 +1,39 @@
class Module {
int mx, my;
int big;
int xOffset;
int yOffset;
float x, y;
int xdir = 1;
int ydir = 1;
int unit;
int xDirection = 1;
int yDirection = 1;
float speed;
// Contructor (required)
Module(int imx, int imy, int ix, int iy, float ispeed) {
mx = imx;
my = imy;
x = ix;
y = iy;
speed = ispeed;
big = unit;
// Contructor
Module(int xOffsetTemp, int yOffsetTemp, int xTemp, int yTemp, float speedTemp, int tempUnit) {
xOffset = xOffsetTemp;
yOffset = yOffsetTemp;
x = xTemp;
y = yTemp;
speed = speedTemp;
unit = tempUnit;
}
// Custom method for updating the variables
void update() {
x = x + (speed * xdir);
if (x >= big || x <= 0) {
xdir *= -1;
x = x + (1 * xdir);
y = y + (1 * ydir);
x = x + (speed * xDirection);
if (x >= unit || x <= 0) {
xDirection *= -1;
x = x + (1 * xDirection);
y = y + (1 * yDirection);
}
if (y >= big || y <= 0) {
ydir *= -1;
y = y + (1 * ydir);
if (y >= unit || y <= 0) {
yDirection *= -1;
y = y + (1 * yDirection);
}
}
// Custom method for drawing the object
void draw() {
stroke(second() * 4);
point(mx+x-1, my+y-1);
fill(255);
ellipse(xOffset + x, yOffset + y, 6, 6);
}
}
+12 -13
View File
@@ -6,26 +6,25 @@
* Move the cursor vertically over each bar to alter its hue.
*/
int barWidth = 5;
int[] hue;
int barWidth = 20;
int lastBar = -1;
void setup()
{
size(200, 200);
colorMode(HSB, 360, height, height);
hue = new int[width/barWidth];
size(640, 360);
colorMode(HSB, height, height, height);
noStroke();
background(0);
}
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++;
int whichBar = mouseX / barWidth;
if (whichBar != lastBar) {
int barX = whichBar * barWidth;
fill(mouseY, height, height);
rect(barX, 0, barWidth, height);
lastBar = whichBar;
}
}
@@ -7,12 +7,12 @@
* Move the cursor vertically over each bar to alter its saturation.
*/
int barWidth = 5;
int barWidth = 20;
int lastBar = -1;
void setup() {
size(200, 200);
size(640, 360);
colorMode(HSB, width, height, 100);
noStroke();
}
@@ -10,15 +10,15 @@
* equal to zero then draw a line.
*/
size(200, 200);
size(640, 360);
background(0);
for(int i=10; i<width; i+=10) {
for(int i = 10; i < width; i += 10) {
// If 'i' divides by 20 with no remainder draw the first line
// else draw the second line
if(i%20 == 0) {
stroke(153);
line(i, 40, i, height/2);
line(i, 80, i, height/2);
} else {
stroke(102);
line(i, 20, i, 180);
@@ -7,20 +7,20 @@
* action.
*/
size(200, 200);
size(640, 360);
background(0);
for(int i=2; i<width-2; i+=2) {
for(int i = 2; i < width-2; i += 2) {
// If 'i' divides by 20 with no remainder
// draw the first line else draw the second line
if(i%20 == 0) {
if((i % 20) == 0) {
stroke(255);
line(i, 40, i, height/2);
} else if (i%10 == 0) {
line(i, 80, i, height/2);
} else if ((i % 10) == 0) {
stroke(153);
line(i, 20, i, 180);
} else {
} else {
stroke(102);
line(i, height/2, i, height-40);
line(i, height/2, i, height-20);
}
}
@@ -2,26 +2,23 @@
* Embedding Iteration.
*
* Embedding "for" structures allows repetition in two dimensions.
*
*/
float box_size = 11;
float box_space = 12;
int margin = 7;
size(200, 200);
size(640, 360);
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;
int gridSize = 40;
for (int x = gridSize; x <= width - gridSize; x += gridSize) {
for (int y = gridSize; y <= height - gridSize; y += gridSize) {
noStroke();
fill(255);
rect(x-1, y-1, 3, 3);
stroke(255, 50);
line(x, y, width/2, height/2);
}
}
@@ -1,45 +1,41 @@
/**
* Iteration.
*
* Iteration with a "for" structure constructs repetitive forms.
* Iteration with a "for" structure to construct repetitive forms.
*/
int k;
int xpos1 = 100;
int xpos2 = 118;
int count = 0;
int timey = 0;
int num = 12;
int y;
int num = 14;
size(200, 200);
size(640, 360);
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;
y = 60;
for(int i = 0; i < num/3; i++) {
rect(50, y, 475, 10);
y+=20;
}
// Black bars
// Gray bars
fill(51);
k = 40;
for(int i=0; i < num; i++) {
rect(105, k, 30, 5);
k += 10;
}
k = 15;
y = 40;
for(int i = 0; i < num; i++) {
rect(125, k, 30, 5);
k +=10;
rect(405, y, 30, 10);
y += 20;
}
y = 50;
for(int i = 0; i < num; i++) {
rect(425, y, 30, 10);
y += 20;
}
// Thin lines
k = 42;
y = 45;
fill(0);
for(int i=0; i < num-1; i++) {
rect(36, k, 20, 1);
k+=10;
for(int i = 0; i < num-1; i++) {
rect(120, y, 40, 1);
y+= 20;
}
@@ -1,41 +1,41 @@
/**
* Logical Operators.
* Logical testerators.
*
* 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);
size(640, 360);
background(126);
boolean op = false;
boolean test = false;
for(int i=5; i<=195; i+=5) {
for(int i = 5; i <= height; i += 5) {
// Logical AND
stroke(0);
if((i > 35) && (i < 100)) {
line(5, i, 95, i);
op = false;
line(width/4, i, width/2, i);
test = false;
}
// Logical OR
stroke(76);
if((i <= 35) || (i >= 100)) {
line(105, i, 195, i);
op = true;
line(width/2, i, width, i);
test = true;
}
// Testing if a boolean value is "true"
// The expression "if(op)" is equivalent to "if(op == true)"
if(op) {
// The expression "if(test)" is equivalent to "if(test == true)"
if(test) {
stroke(0);
point(width/2, i);
point(width/3, i);
}
// Testing if a boolean value is "false"
// The expression "if(!op)" is equivalent to "if(op == false)"
if(!op) {
// The expression "if(!test)" is equivalent to "if(test == false)"
if(!test) {
stroke(255);
point(width/4, i);
}
+3 -3
View File
@@ -7,12 +7,12 @@
* that define the shape of the curve.
*/
size(200, 200);
size(640, 360);
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));
for(int i = 0; i < 200; i += 20) {
bezier(180-(i/2.0), 40+i, 410, 20, 440, 300, 240-(i/16.0), 300+(i/8.0));
}
@@ -18,7 +18,7 @@ color controlPtCol = #222222;
color anchorPtCol = #BBBBBB;
void setup(){
size(200, 200);
size(640, 360);
smooth();
setEllipse(pts, 65, 65);
frameRate(1);
@@ -30,12 +30,12 @@ void draw(){
setEllipse(int(random(3, 12)), random(-100, 150), random(-100, 150));
}
// draw ellipse with anchor/control points
// Draw ellipse with anchor/control points
void drawEllipse(){
strokeWeight(1.125);
stroke(255);
noFill();
// create ellipse
// Create ellipse
for (int i=0; i<pts; i++){
if (i==pts-1) {
bezier(px[i], py[i], cx[i], cy[i], cx2[i], cy2[i], px[0], py[0]);
@@ -48,9 +48,9 @@ void drawEllipse(){
stroke(0);
rectMode(CENTER);
// control handles and tangent lines
for ( int i=0; i< pts; i++){
if (i==pts-1){ // last loop iteration-close path
// Control handles and tangent lines
for ( int i = 0; i < pts; i++){
if (i==pts-1){ // Last loop iteration-close path
line(px[0], py[0], cx2[i], cy2[i]);
}
if (i>0){
@@ -62,18 +62,18 @@ void drawEllipse(){
for ( int i=0; i< pts; i++){
fill(controlPtCol);
noStroke();
//control handles
// Control handles
ellipse(cx[i], cy[i], 4, 4);
ellipse(cx2[i], cy2[i], 4, 4);
fill(anchorPtCol);
stroke(0);
//anchor points
// Anchor points
rect(px[i], py[i], 5, 5);
}
}
// fill up arrays with ellipse coordinate data
// Fill arrays with ellipse coordinate data
void setEllipse(int points, float radius, float controlRadius){
pts = points;
px = new float[points];
@@ -97,7 +97,7 @@ void setEllipse(int points, float radius, float controlRadius){
cy2[i] = height/2+sin(radians(angle+controlAngle2))*
controlRadius/cos(radians(controlAngle1));
//increment angle so trig functions keep chugging along
// Increment angle so trig functions keep chugging along
angle+=360.0/points;
}
}
+20 -12
View File
@@ -5,19 +5,27 @@
* Uses the arc() function to generate a pie chart from the data
* stored in an array.
*/
size(200, 200);
background(100);
smooth();
noStroke();
float diameter = min(width, height) * 0.75;
int[] angs = {30, 10, 45, 35, 60, 38, 75, 67};
float lastAng = 0;
for (int i = 0; i < angs.length; i++){
fill(angs[i] * 3.0);
arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
lastAng += radians(angs[i]);
float diameter;
int[] angles = { 30, 10, 45, 35, 60, 38, 75, 67 };
float lastAngle = 0;
void setup() {
size(640, 360);
background(100);
smooth();
noStroke();
diameter = min(width, height) * 0.75;
noLoop(); // Run once and stop
}
void draw() {
for (int i = 0; i < angles.length; i++) {
fill(angles[i] * 3.0);
arc(width/2, height/2, diameter, diameter, lastAngle, lastAngle+radians(angles[i]));
lastAngle += radians(angles[i]);
}
}
@@ -6,14 +6,15 @@
* The four variables set the positions based on the value of 'd'.
*/
int d = 40;
int d = 70;
int p1 = d;
int p2 = p1+d;
int p3 = p2+d;
int p4 = p3+d;
size(200, 200);
size(640, 360);
background(0);
translate(140, 0);
// Draw gray box
stroke(153);
@@ -8,14 +8,18 @@
* of parameters to determine the shape's position and size.
*/
size(200, 200);
size(640, 360);
smooth();
background(0);
noStroke();
fill(226);
triangle(10, 10, 10, 200, 45, 200);
rect(45, 45, 35, 35);
quad(105, 10, 120, 10, 120, 200, 80, 200);
ellipse(140, 80, 40, 40);
triangle(160, 10, 195, 200, 160, 200);
fill(204);
triangle(18, 18, 18, 360, 81, 360);
fill(153);
rect(81, 81, 63, 63);
fill(204);
quad(189, 18, 216, 18, 216, 360, 144, 360);
fill(255);
ellipse(252, 144, 72, 72);
fill(204);
triangle(288, 18, 351, 360, 288, 360);
@@ -8,45 +8,46 @@
*/
void setup() {
size(200, 200);
size(640, 360);
colorMode(RGB, 100);
smooth();
background(0);
noFill();
noLoop();
noLoop(); // Run once and stop
}
void draw() {
stroke(40);
beginShape();
for(int i=0; i<width; i++) {
for(int i = 0; i < width; i++) {
vertex(i, singraph((float)i/width)*height);
}
endShape();
stroke(55);
beginShape();
for(int i=0; i<width; i++) {
for(int i = 0; i < width; i++) {
vertex(i, quad((float)i/width)*height);
}
endShape();
stroke(70);
beginShape();
for(int i=0; i<width; i++) {
for(int i = 0; i < width; i++) {
vertex(i, quadHump((float)i/width)*height);
}
endShape();
stroke(85);
beginShape();
for(int i=0; i<width; i++) {
for(int i = 0; i < width; i++) {
vertex(i, hump((float)i/width)*height);
}
endShape();
stroke(100);
beginShape();
for(int i=0; i<width; i++) {
for(int i = 0; i < width; i++) {
vertex(i, squared((float)i/width)*height);
}
endShape();
@@ -9,28 +9,38 @@
* Trig functions generate ring.
*/
size(200, 200);
background(204);
smooth();
int x = width/2;
int y = height/2;
float outerRad = min(width, height) * 0.4;
float innerRad = outerRad * 0.6;
float px = 0, py = 0, angle = 0;
int x;
int y;
float outerRad;
float innerRad;
float px = 0;
float py = 0;
float 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;
void setup() {
size(640, 360);
background(204);
smooth();
x = width/2;
y = height/2;
outerRad = min(width, height) * 0.4;
innerRad = outerRad * 0.6;
}
void draw() {
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();
}
endShape();
@@ -9,10 +9,14 @@
* To stop drawing the shape, call the endShape() functions.
*/
size(200, 200);
size(640, 360);
background(0);
noFill();
translate(140, 20);
scale(1.5);
strokeWeight(.5);
stroke(102);
beginShape();
curveVertex(168, 182);
+2 -2
View File
@@ -15,7 +15,7 @@ float hoursRadius;
float clockDiameter;
void setup() {
size(200, 200);
size(640, 360);
stroke(255);
smooth();
@@ -29,7 +29,7 @@ void setup() {
cy = height / 2;
}
void draw2() {
void draw() {
background(0);
// Draw the clock background
@@ -11,11 +11,11 @@ float mx;
float my;
float easing = 0.05;
int radius = 24;
int edge = 56;
int edge = 100;
int inner = edge + radius;
void setup() {
size(200, 200);
size(640, 360);
noStroke();
smooth();
ellipseMode(RADIUS);
+3 -3
View File
@@ -16,14 +16,14 @@ float easing = 0.05;
void setup()
{
size(200, 200);
size(640, 360);
smooth();
noStroke();
}
void draw()
{
background( 51 );
background(51);
targetX = mouseX;
float dx = targetX - x;
@@ -37,5 +37,5 @@ void draw()
y += dy * easing;
}
ellipse(x, y, 33, 33);
ellipse(x, y, 66, 66);
}
@@ -10,7 +10,7 @@
int rectWidth;
void setup() {
size(200, 200);
size(640, 360);
noStroke();
background(0);
rectWidth = width/4;
@@ -9,12 +9,12 @@
* 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 maxHeight = 40;
int minHeight = 20;
int letterHeight = maxHeight; // Height of the letters
int letterWidth = 20; // Width of the letter
int x = -letter_width; // X position of the letters
int x = -letterWidth; // X position of the letters
int y = 0; // Y position of the letters
boolean newletter;
@@ -24,7 +24,7 @@ color[] colors = new color[numChars];
void setup()
{
size(200, 200);
size(640, 360);
noStroke();
colorMode(RGB, numChars);
background(numChars/2);
@@ -39,14 +39,14 @@ void draw()
if(newletter == true) {
// Draw the "letter"
int y_pos;
if (letter_height == max_height) {
if (letterHeight == maxHeight) {
y_pos = y;
rect( x, y_pos, letter_width, letter_height );
rect( x, y_pos, letterWidth, letterHeight );
} else {
y_pos = y + min_height;
rect( x, y_pos, letter_width, letter_height );
y_pos = y + minHeight;
rect( x, y_pos, letterWidth, letterHeight );
fill(numChars/2);
rect( x, y_pos-min_height, letter_width, letter_height );
rect( x, y_pos-minHeight, letterWidth, letterHeight );
}
newletter = false;
}
@@ -54,36 +54,36 @@ void draw()
void keyPressed()
{
// if the key is between 'A'(65) and 'z'(122)
// If the key is between 'A'(65) and 'z'(122)
if( key >= 'A' && key <= 'z') {
int keyIndex;
if(key <= 'Z') {
keyIndex = key-'A';
letter_height = max_height;
letterHeight = maxHeight;
fill(colors[key-'A']);
} else {
keyIndex = key-'a';
letter_height = min_height;
letterHeight = minHeight;
fill(colors[key-'a']);
}
} else {
fill(0);
letter_height = 10;
letterHeight = 10;
}
newletter = true;
// Update the "letter" position
x = ( x + letter_width );
x = ( x + letterWidth );
// Wrap horizontally
if (x > width - letter_width) {
if (x > width - letterWidth) {
x = 0;
y+= max_height;
y+= maxHeight;
}
// Wrap vertically
if( y > height - letter_height) {
if( y > height - letterHeight) {
y = 0; // reset y to 0
}
}
@@ -11,16 +11,16 @@ float scale;
void setup()
{
size(200, 200);
size(640, 360);
noStroke();
scale = width/10;
scale = width/20;
}
void draw()
{
for(int i=0; i<scale; i++) {
for(int i = 0; i < scale; i++) {
colorMode(RGB, (i+1) * scale * 10);
fill(millis()%((i+1) * scale * 10) );
fill(millis()%((i+1) * scale * 10));
rect(i*scale, 0, scale, height);
}
}
+13 -31
View File
@@ -5,43 +5,25 @@
* 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);
size(640, 360);
noStroke();
colorMode(RGB, height, height, height);
rectMode(CENTER);
}
void draw() {
background(0.0);
update(mouseX);
fill(0.0, leftColor + 0.4, leftColor + 0.6);
rect(width/4-gx, height/2-gx, gx*2, gx*2);
fill(0.0, rightColor + 0.2, rightColor + 0.4);
rect(width/1.33-gy, height/2-gy, gy*2, gy*2);
float r1 = map(mouseX, 0, width, 0, height);
float r2 = height-r1;
fill(r1);
rect(width/2 + r1/2, height/2, r1, r1);
fill(r2);
rect(width/2 - r2/2, height/2, r2, r2);
}
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;
}
}
@@ -6,7 +6,7 @@
void setup()
{
size(200, 200);
size(640, 360);
noStroke();
rectMode(CENTER);
}
@@ -6,7 +6,7 @@
float bx;
float by;
int bs = 20;
int bs = 75;
boolean bover = false;
boolean locked = false;
float bdifx = 0.0;
@@ -15,7 +15,7 @@ float bdify = 0.0;
void setup()
{
size(200, 200);
size(640, 360);
bx = width/2.0;
by = height/2.0;
rectMode(RADIUS);
@@ -1,5 +1,5 @@
/**
* Click.
* Mouse Press.
*
* Move the mouse to position the shape.
* Press the mouse button to invert the color.
@@ -7,7 +7,7 @@
void setup() {
size(200, 200);
size(640, 360);
fill(126);
background(102);
}
@@ -13,7 +13,7 @@ int[] bvals;
void setup()
{
size(200, 200);
size(640, 360);
xvals = new int[width];
yvals = new int[width];
bvals = new int[width];
@@ -25,7 +25,7 @@ void draw()
{
background(102);
for(int i=1; i<width; i++) {
for(int i = 1; i < width; i++) {
xvals[i-1] = xvals[i];
yvals[i-1] = yvals[i];
bvals[i-1] = bvals[i];
@@ -6,8 +6,6 @@
* into an array and played back every frame. Between each
* frame, the newest value are added to the end of each array
* and the oldest value is deleted.
*
* Updated 27 February 2010.
*/
int num = 60;
@@ -15,7 +13,7 @@ float mx[] = new float[num];
float my[] = new float[num];
void setup() {
size(200, 200);
size(640, 360);
smooth();
noStroke();
fill(255, 153);
@@ -33,6 +31,6 @@ void draw() {
for (int i = 0; i < num; i++) {
// which+1 is the smallest (the oldest in the array)
int index = (which+1 + i) % num;
ellipse(mx[index], my[index], i/2, i/2);
ellipse(mx[index], my[index], i, i);
}
}
@@ -15,7 +15,7 @@ float[] dx = new float[maxwaves]; // Value for incrementing X, to be ca
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
void setup() {
size(200, 200);
size(640, 360);
frameRate(30);
colorMode(RGB, 255, 255, 255, 100);
smooth();
@@ -7,10 +7,21 @@
* 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://processing.org/img/processing_cover.gif");
if (img != null) {
image(img1, 0, 0);
PImage img;
void setup() {
size(640, 360);
img = loadImage("http://processing.org/img/processing_cover.gif");
noLoop();
}
void draw() {
background(0);
if (img != null) {
image(img, 0, 0);
image(img, 0, img.height);
image(img, 0, img.height * 2);
}
}