Ejercicio 1.- CUBO 3D.
float a = 0;
float r = 0;
Ejercicio 2.- DIBUJO.
int x=400;
int y=400;
int a=0;
void setup(){
size(400,400);
background(50,75,150);
}
void draw(){
if(keyPressed){
if(key== BACKSPACE){
background(50,75,150);
}
}
if (mousePressed){
strokeWeight(5);
stroke(random(255),random(255),random(255));
point(mouseX, mouseY);
if(mouseX<200){
point(x-mouseX, mouseY);
point(x-mouseX, -mouseY+y);
}
if(mouseX>200){
point(-mouseX+x,mouseY);
point(-mouseX+x,-mouseY+y);
}
if(mouseY<200){
point(mouseX,y-mouseY);
point(-mouseX+x,y-mouseY);
}
if(mouseY>200){
point(mouseX,-mouseY+y);
}
}
}
Ejercicio 3.- ELIPSE.
int x=50;
int y=50;
void setup() {
size(150,150);
}
void draw() {
background(100,0,120,200);
ellipse(mouseX-5,mouseY-5,50,70);
}
void mousePressed() {
fill(20,100,50);
}
void mouseReleased(){
fill(130,20,0);
}
if (keyPressed) {
if (key == 'b' || key == 'B'){
y = y + 20;
}
else if (key == 's'){
x = x + 20;
}
}
Ejercicio 4.- LÍNEAS 3D.
void setup(){
size(600,600);
void draw(){
fill(0);
stroke(random(0,255),random(255),random(255));
line(0,600,mouseX,mouseY);
line(0,0,mouseX,mouseY);
line(600,0,mouseX,mouseY);
line(600,600,mouseX,mouseY);
}
Ejercicio 5.- CUBO Y CÍRCULO QUE SE MUEVE.
float x = 300;
float y = 20;
float move_x = 2;
float move_y = -2;
void setup() {
size(400,400);
strokeWeight(7);
}
void draw() {
background(0,0,400);
translate(200,200);
rect(x+80,y,40,40);
ellipse(x,y,40,40);
x=x+move_x;
y=y+move_y;
println("LOOP"+frameRate);
println("Contador",+frameCount);
if(x > width) {
x= height;
move_x = -move_x;
println("DEMASIADO DERECHA");
}
if (y>height);
ellipse(x,y,40,40);
x=x+move_x;
y=y+move_y;
println("LOOP",+frameRate);
println("Contador",+frameCount);
if(x > width) {
x= height;
move_x = move_y;
println("DEMASIADO DERECHA");
}
if (y>height){
y=height;
move_x=move_y;
println("DEMASIADO bottom");
}
if(x>0) {
x=0;
move_x= -move_x;
println("DEMASIADO left");
}
if(y<0) {
y=0;
move_y=-move_y;
println("DEMASIADO TOP");
}
}
Ejercicio 6.- RECTÁNGULO MOVIBLE.
int x=5;
int y=5;
int x1=100;
int y1=100;
void setup() {
size(400,400);
background(250,50,70);
}
void draw() {
line(5,5,100,100);
fill(120,230,0);
rect(x,y,x1,y1);
x=x+5;
y=y+5;
x1=x1+20;
y1=y1+20;
}
Ejercicio 7.- LÍNEA QUE DIBUJA.
void setup() {
size(640, 360);
background(200,300,200);
}
void draw() {
stroke(random(255));
if (mousePressed == true) {
line(mouseX, mouseY, pmouseX, pmouseY);
}
stroke(random(0,0));
if (mousePressed == false)
line(mouseX, mouseY, pmouseX, pmouseY);
}
No hay comentarios:
Publicar un comentario