Estos ejercicios fueron introductorios para aprender a manejar este programa cuya principal característica es el uso de código para generar el diseño, algunos ejercicios van con la opción for e int para integrar calculo matemático. A continuación algunos ejercicios realizados:
Ejercicio 1 con Formas y su respectivo código:
![]() |
Clic para agrandar la imagen |
background (72,61,139);
stroke (0,128,128);
strokeWeight (3);
fill (60,179,113);
rect (360,360,40,40);
fill (128,128,0);
triangle (80,20,138,360,112,400);
stroke (255,165,0);
line (20,500,180,5);
line (90,400,250,10);
line (80,500,500,30);
line (70,600,750,60);
line (60,800,900,100);
line (500,700,950,120);
beginShape ();
vertex (170,200);
vertex (188,108);
vertex (400,196);
vertex (240,40);
vertex (170,200);
endShape ();
fill (189,183,107);
ellipse (480,480,240,240);
fill (144,238,144);
triangle (350,0,280,150,600,4);
triangle (346,349,346,255,325,90);
triangle (34,45,535,234,234,224);
triangle (10,110,80,20,130,130);
triangle (700,50,37,47,54,38);
fill (139,0,139);
rect (0,500,300,50);
fill (255,0,255);
rect (300,500,57,47);
fill (0,206,209);
rect (570,150,100,200);
fill (255,255,0);
rect (400,300,100,100);
rect (20,350,120,120);
fill (255,0,0);
triangle (400,100,690,720,560,600);
Ejercicio 1 con For y su respectivo código:
![]() |
Clic para agrandar la imagen |
background (230,230,250);
for (int w=5; w<height; w+=20){
for (int z=33; z<width; z+=2){
triangle (w+z,w,8-w/7,8-w/7,w-z,z*2);
}
};
for(int y = 50; y<900; y +=12) {
fill (102,205,170,100);
rect(y+2,y,10,700);
}
for(int z = 10; z<900; z +=40) {
fill (25,25,112,100);
ellipse (z+5,z++,20,500);
}
Ejercicio 1 con if y su respectivo código:
void setup (){
size (700,500);
}
void draw(){
background (210,180,140);
if ((t>70) && (t<530) ) {
fill (0,255,127);
ellipse (t+6,59,36,t*2);
fill (100,149,237);
rect (40,28,90,90);
}
if ((t<30) && (t>2) ) {
fill (199,21,133);
triangle (164,146,126,t*4/6,37,t+10);
}
line (t,0,t,500);
t+=1;
}
Ejercicio 2 con if y su respectivo codigo:
float y = 0;
float z = 1;
float p = 3;
void setup() {
size(700, 350);
noStroke ();
fill (255,255,255,100);
}
void draw() {
background(z+30,+144,-255);
y = y + 0.5;
z = z + 1.2;
p = p + 1.8;
rect (y, 0, y, height/2);
rect (z, height/2, z, height);
ellipse (height, p+1, height, p-2);
if(y > width) {
y = 0;
}
if(z > width) {
z = 1;
}
if(p > width) {
p = 3;
}
}
Ejercicio 3 realizado con if y con else:
int t =3;
void setup (){
size (700,500);
}
void draw(){
background (210,180,140);
if ((t>70) && (t<530) ) {
fill (0,255,127);
ellipse (t+6,59,36,t*2);
fill (100,149,237);
rect (40,28,90,90);
}
if ((t<30) && (t>2) ) {
fill (199,21,133);
triangle (164,146,126,t*4/6,37,t+10);
}else{
ellipse (54,47,t+6,t+3-10);
}
line (t,0,t,500);
t+=1;
}
void setup (){
size (1000,1000);
background (245,255,250);
stroke (188,143,143,100);
strokeWeight (5);
}
void draw(){
if (mousePressed) {
fill (150,56,74,100);
}else{
fill (34,75,186,100);
}
rect (mouseX,mouseY,200,200);
}
void setup (){
size (700,700);
}
void draw (){
stroke (253,245,230,100);
strokeWeight (5);
if (mousePressed){
fill (mouseX,mouseY,mouseX,250);
}else{
fill (178,034,034,100);
}
rect (mouseX,mouseY,44,44);
}
Ejercicio mouse pressed 3:
float a=20;
float b=5;
float c=50;
float d=70;
void setup (){
size (1200,800);
background (211,211,211);
}
void draw (){
noStroke ();
triangle (500,b++,742,128,65,a+b);
fill (255,165,000);
if (mousePressed){
fill (125,52,242,100);
if (c<100){
triangle (mouseX,mouseY,952,545,685,432);
fill (000,000,128);
}else{
fill (a+b,c+d,d+a,100);
}
if (a<=10){
fill (175,238,238,100);
rect (mouseX,mouseY,a-b,b);
}
}
}
No hay comentarios:
Publicar un comentario