This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float x; // X-coordinate | |
float y; // Y-coordinate | |
void setup() { | |
size(600, 600); | |
x = width/2; | |
y = height/2; | |
randomSeed(0); // Force the same random values | |
background(0); | |
stroke(255); | |
} | |
void draw() { | |
x += random(-2, 2); // Assign new x-coordinate | |
y += random(-2, 2); // Assign new y-coordinate | |
point(x, y); | |
} |
Movimiento rectilíneo uniforme:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float velocidad = 5.0; | |
int radio= 10; | |
float x = radio+1; | |
void setup(){ | |
size(400, 400); | |
stroke(255); | |
smooth(); | |
fill(255); | |
frameRate(15); | |
} | |
void draw(){ | |
background(0); | |
for (float i = 0; i< width; i+= 3){ | |
point(i, height/2); | |
} | |
x += velocidad; | |
ellipse(x, height/2, radio, radio); | |
} |
Movimiento rectilíneo acelerado:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float velocidad = 5.0; | |
int direccion = 1; | |
float aceleracion = 1.01; | |
int radio= 5; | |
float x = radio; | |
void setup(){ | |
size(400, 400); | |
stroke(255); | |
smooth(); | |
ellipseMode(RADIUS); | |
frameRate(15); | |
} | |
void draw(){ | |
// fill(0, 50); | |
//rect(0, 0, width, height); | |
background(0); | |
fill(255); | |
for (float i = 0; i< width; i+= 3){ | |
point(i, height/2); | |
} | |
if(x>height-radio || x< radio ){ | |
direccion = -direccion; | |
} | |
velocidad *= aceleracion; | |
x += velocidad*direccion; | |
ellipse(x, height/2, radio, radio); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float velocidad = 5.0; | |
int radio= 5; | |
float x = radio+1; | |
float y = radio+1; | |
void setup(){ | |
size(400, 400); | |
stroke(255); | |
smooth(); | |
fill(255); | |
frameRate(30); | |
} | |
void draw(){ | |
background(0); | |
ellipseMode(RADIUS); | |
for (int i = 0; i < width; i++) { | |
float n = norm(i, 0.0, width); | |
float j = pow(n, 2); | |
j *= height; | |
point(i, j); | |
} | |
if (y<= height-radio*2){ | |
x += velocidad; | |
} | |
float n = norm(x, 0.0, width); | |
y = pow(n, 2); | |
y *= height; | |
ellipse(x, y, radio, radio); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float angulo = 0.0; | |
float incremento = 0.001; | |
float freq = 100; | |
float amplitud = 50; | |
float x = 0; | |
float velocidad = 0.5; | |
void setup() { | |
size(400, 400); | |
noStroke(); | |
smooth(); | |
background(0); | |
frameRate(30); | |
} | |
void draw() { | |
fill(0, 10); | |
rect(0, 0, width, height); | |
//background (0); | |
angulo += incremento; | |
float sinval = sin(angulo*freq)*amplitud; | |
// float cosval = cos(angulo*freq)*amplitud; | |
float y = sinval+height/2; | |
// float y2 = cosval+height/2; | |
x+= velocidad; | |
if (x > width){ | |
x = 0; | |
} | |
fill(255); | |
ellipse(x, y, 5, 5); | |
// ellipse(x, y2, 5, 5); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float angle = 0.0; | |
float speed = 0.05; | |
float radiusX = 30.0; | |
float radiusY = 30.0; | |
float sx = 2.0; | |
float sy = 2.0; | |
void setup() { | |
size(100, 100); | |
noStroke(); | |
smooth(); | |
} | |
void draw() { | |
fill(0, 4); | |
rect(0, 0, width, height); | |
angle += speed; | |
float sinval = sin(angle); | |
float cosval = cos(angle); | |
float x = 50 + (cosval * radiusX); | |
float y = 50 + (sinval * radiusY); | |
fill(255); | |
ellipse(x, y, 2, 2); | |
} |
Recent Comments