0% found this document useful (0 votes)
2K views33 pages

07 Continuous 20130510

The document discusses continuous processing in code. It provides examples of using the frameRate() function to control the speed of animation loops and movement over time. Code snippets demonstrate incrementally moving shapes across the screen at different rates, as well as combining multiple moving shapes and colors. The use of background(), noLoop(), and delay() functions are also illustrated.

Uploaded by

Gene Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views33 pages

07 Continuous 20130510

The document discusses continuous processing in code. It provides examples of using the frameRate() function to control the speed of animation loops and movement over time. Code snippets demonstrate incrementally moving shapes across the screen at different rates, as well as combining multiple moving shapes and colors. The use of background(), noLoop(), and delay() functions are also illustrated.

Uploaded by

Gene Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Processing

Continuous
()

07

Structure 2: Continuous

void setup() {

void draw() {
}

void setup() {

// noLoop();
}

void draw() {
}

float y = 0.0;

void draw() {
frameRate(30);
line(0, y, 100, y);
y = y + 0.5;
}

float y = 0.0;
void setup() {
frameRate(20);
}

void draw() {
background(255);
line(0, y, 100, y);
y = y + 0.5;
}

float y = 0.0;
void setup() {
frameRate(60);
}

void draw() {
background(255);
line(0, y, 100, y);
y = y + 0.5;
if (y >= 100) {y = 0;}
}

float y = 0.0;
void setup() {
frameRate(60);
fill(0);
smooth();
}
void draw() {
background(255);
ellipse(20, y, 10, 10);
ellipse(60, y, 10, 10);
y = y + 0.5;
if (y >= 100) { y = 0;}
}

float y = 0.0;
void setup() {
frameRate(60);
fill(0);
smooth();

noLoop();
}
void draw() {
background(255);
ellipse(20, y, 10, 10);
ellipse(60, y, 10, 10);
y = y + 0.5;
if (y >= 100) { y = 0;}
}

float y = 0.0;
void setup() {
frameRate(60);
fill(0);
smooth();
}
void draw() {
// background(255);
ellipse(20, y, 10, 10);
ellipse(60, y, 10, 10);
y = y + 0.5;
if (y >= 100) { y = 0;}
}

float y = 0.0;
void setup() {
frameRate(60);
fill(0);
smooth();
}
void draw() {
background(255);
ellipse(20, y, 10, 10);
ellipse(60, 100-y, 10, 10);
y = y + 0.5;
if (y >= 100) {y = 0;}
}

float x = 0.0;
float y = 0.0;
void setup() {
frameRate(60);
fill(0);
smooth();
}
void draw() {
background(255);
ellipse(20, x, 10, 10);
ellipse(100-y, 60, 20, 20);
x = x + 1.0;
y = y + 0.5;
if (x >= 100) {x = 0;}
if (y >= 100) {y = 0;}
}

float x = 0.0;
float y = 0.0;

void setup() {
frameRate(60);
smooth();
}
void draw() {
background(0);
fill(255,0,0);
ellipse(20, x, 10, 10);
fill(0,255,0);
ellipse(100-y, 60, 20, 20);
fill(0,0,255);
ellipse(x, y, 30, 30);
x = x + 1.0;
y = y + 0.5;
if (x >= 100) {x = 0;}
if (y >= 100) {y = 0;}
}

float y = 0.0;
void setup() {
size(200, 200);
frameRate(60);
fill(0);
smooth();
}
void draw() {
background(255-y);
fill(y);
ellipse(100, 100, y, y);
y = y + 0.5;
if (y >= 300) { y = 0;}
}

int x = 0;
int y = 0;
void setup () {
size(200,200);
}
void draw () {
fill(255,0,0);
background(0);
rect(x,y,50,50);
x += 1; y += 2;
if (x > width) {x = 0;}
if (y > height) {y = 0;}
}

int w = 200;
int x1 = 0; int y1 = 0;
int x2 = 0; int y2 = w;
int x3 = w; int y3 = w;
int x4 = w; int y4 = 0;

void draw () {
fill(255,0,0);
background(0);
rect(x1,y1,50,50);
x1 += 1; y1 += 1;
if (x1 > width) {x1 = 0;}
if (y1 > height) {y1 = 0;}

void setup () {
size(w,w);
}

rect(x2,y2-50,50,50);
x2 += 1; y2 -= 1;
if (x2 > width) {x2 = 0;}
if (y2 < 0) {y2 = height;}
rect(x3-50,y3-50,50,50);
x3 -= 1; y3 -= 1;
if (x3 < 0) {x3 = width;}
if (y3 < 0) {y3 = height;}
rect(x4-50,y4,50,50);
x4 -= 1; y4 += 1;
if (x4 < 0) {x4 = width;}
if (y4 > height) {y4 = 0;}
}

void setup () {
}
void draw () {
}
noLoop();
delay(100);
frameRate();

int i = 0;

void setup() {
size(720,100);
background(255);
}
void draw (){
float j = sin(i*2*PI/360);
float k = map(j,-1,1,0,100);
stroke(0,0,255);
point(i,k); point(i+5,k); point(i+10,k);
point(i+15,k); point(i+20,k); point(i+25,k);
float m = cos(i*2*PI/360);
float n = map(m,-1,1,0,100);
stroke(255,0,0);
point(i,n); point(i+10,n); point(i+20,n);
i++;
if (i >= 720) {background(255); i = 0;}
}

int x = 0;
void setup(){
size(200, 200);
background(255);
}
void draw(){
for(int i=10; i<width; i=i+10) {
if(i%20 == 0) {
stroke(0);
line(i, 40, i, height/2);
} else {
stroke(102);
//line(i, x+20, i, x+180);
point(i,x);
}
}
//background(255);
x += 5;
frameRate(10);
if (x > height) {background(255); x = 0;}
}

Ch. 20, 31
05/10/2013

You might also like