Documentos de Académico
Documentos de Profesional
Documentos de Cultura
}
void draw (){
fill (250); noStroke ();
rect (140,250,300,100);
noFill();stroke (20,20,40);strokeWeight (10);
ellipse (140,250,80,80);
}
void setup (){
size (500,500);
background (25,126,15);
smooth ();
}
void draw (){
dibuja();
}
void dibuja (){
fill (250); noStroke ();
rect (140,250,300,100);
noFill();stroke (20,20,40);strokeWeight (10);
ellipse (140,250,80,80);
}
EJERCICIO MOVIMIENTO PELOTA
void setup (){
size (320,240);
background (0);
smooth ();
}
void draw(){
dibuja ();
}
int pelotax =155;int pelotay= 115;
int pelotadx =1;int pelotady= 1;
void dibuja(){
fill (255); noStroke ();
rect (155,155,10,50);
float rojo = random (256);
float azul = random (100) +155;
noFill ();stroke (rojo,0,azul);strokeWeight (2);
ellipse (pelotax,pelotay,30,30);
mueve ();
}
void mueve (){
if (pelotax <= 15 || pelotax >= 305) pelotadx*=-1;
pelotax+= pelotadx;
if (pelotay <=15 || pelotay >= 225){
pelotady*=-1;
if (pelotady >0){
pelotady =int (random (5)+1);
}else{
pelotady=int (random (5)+1)*-1;
}
}
pelotay += pelotady;
}
MUERTE
void setup (){
size (320,240);
background (0);
smooth ();
}
void draw(){
dibuja ();
}
int pelotax =155;int pelotay= 115;
int pelotadx =1;int pelotady= 1;
void dibuja(){
fill (255); noStroke ();
rect (155,155,10,50);
float rojo = random (256);
float azul = random (100) +155;
fill(25,20);stroke (rojo,0,azul);strokeWeight (2);
ellipse (pelotax,pelotay,30,30);
mueve ();
}
void mueve (){
if (pelotax <= 15 || pelotax >= 305){
pelotadx*=-1;
ciclos++;
println(ciclos);
muerte();
}
pelotax+= pelotadx;
if (pelotay <=15 || pelotay >= 225){
pelotady*=-1;
if (pelotady >0){
pelotady =int (random (5)+1);
}else{
pelotady=int (random (5)+1)*-1;
}
}
pelotay += pelotady;
}
int ciclos = 0;
void muerte (){
if (ciclos==3){
saveFrame("coss.tif");
exit();
}
}
EJERCICIO PLANO CARTESIANO
int xone=0;
int yone=0;
void setup(){
size (200,200);
background (255);
stroke(0);
}
void paleta2(){
if (keyPressed == true){
if (key =='p'){
if (py >0) py = -1;
}
if (key =='l'){
if (py < height-py)pd = 1;
}
}
if (py < 0){
py= 0;
pd= 0;
}
if (py >height-py){
py = height -py;
pd=0;
}
py += pd;
}
void dibujar(){
background (0);
}
inlets =1;
outlets=1;
var pelotas=new Array();
var cuantas=10;
function bang(){
outlet (0, "clear");
for(var i=0; i < cuantas; i++){
if (pelotas [i].y <= 0 || pelotas [i].y >= 390)pelotas[i].vy*=-1
if (pelotas [i].x <= 0 || pelotas [i].x >= 390)pelotas[i].vx*=-1
outlet(0, "frameoval " + pelotas[i].x +" "+ pelotas[i].y + " "+(pelotas[i].x+10)+ " " + (pelotas[i].y+10)+ "
" + pelotas[i].c);
pelotas[i].x +=pelotas[i].vx
pelotas[i].y +=pelotas[i].vy
}
}
function crea(){
for(var i=0; i < cuantas; i++){
pelotas[i]= new pelota(Math.random()*250+10,Math.random()*200+10,5,1,Math.random()*256);
}
}
function pelota(x, y, vx, vy, c){
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.c = c;
}
*6TO CUATRIMESTRE*
size (1000,510);//tamao del cuadro
background(255);//color de fondo
strokeWeight(6);//grosor del contorno
stroke(0); //color de contorno
smooth();
line(250,350,250, 100);
line(310,250,310, 112);
line(310,250,310, 112);
line(190,250,190, 112);
line(310,150,190, 150);
BUCLE WHILE
size(200,200);
background(255);
int y=80;
int x=50;
int espacio=10;
int largo=20;
int fin=150;
stroke(255,0,0);
while (x<=fin){
line (x,y,x,y+largo);
x=x+espacio;
}
Bucle For
void setup (){
size(400,400);
background (0);
}
void draw(){
for(int i=20; i<380 ; i+=10){
stroke(255);
line (i, 20, i+15, 380);
}
}
Mandala usando el raton
void setup (){
size (200,200);
}
void draw (){
background (255);
noFill();
for(int x=0; x<width; x+=30)
for(int y=0; y<height; y+=30)
ellipse(x,y,mouseX,mouseY);
}
IMAGEN TIPO RADAR
int x= 0;
void setup (){
size (600,600);
background (0);
smooth();
}
void draw (){
//background (0);
stroke (0,0,255);
noFill();
ellipse(width*0.5,height*0.5, x,x);
//ellipse(width*0.5, height*0.5, width*0.66,height*0.66);
line(width*0.5,0,width*0.5,height);
line(0,height*0.5,width,height*0.5);
x= x+40;
if (x >= 600){
x=0;
}
}
RANDOM
int x= 0;
void setup (){
size (600,600);
background (0);
smooth();
frameRate(12);
}
void draw (){
//background (0);
stroke (random (255),random (255),random (255));
noFill();
ellipse(width*0.5,height*0.5, x,x);
//ellipse(width*0.5, height*0.5, width*0.66,height*0.66);
line(width*0.5,0,width*0.5,height);
line(0,height*0.5,width,height*0.5);
x= x+10;
if (x >= 600){
x=0;
}
}
Gravedad de la pelota
float x=100;
float y=0;
float velocidad=0;
float gravedad=0.1;
void setup (){
size (200,200);
}
void draw (){
background(255);
//pelota
fill (250,89,30);
stroke (0);
ellipse (x,y,30,30);
y= y + velocidad;
velocidad = velocidad+gravedad;
//invertir velocidad
if (y > height){
velocidad = velocidad* -0.95;
}
}
3 ESFERAS CON DIFUMINACION BLANCA
size (800,300);
background(255);
bounce();
display();
}
//where should functions be placed?
//you can define your function anywhere
//In the code outside os setup () and draw().
//however, the convention is to place
//your function definiting below draw().
//A function to move the ball
void move (){
//change the x location by speed
x=x+speed;
}
//A function to bounce the ball
void bounce(){
//if we ve reached an edge, reversed speed
if ((x > width) || (x <0)) {
speed = speed + -1;
}
}
//A function to display the ball
void display(){
background(0);
ellipseMode(CENTER);
fill (random (255), random (255), random (255));
stroke(255);
ellipse (x,y,50,32);
fill (random (255), random (255), random (255));
rect(x-4,y-4,4,4);
rect(x+4,y-4,4,4);
line(x-4,y+4,x+4,y+4);
}
Animacion de trabajo