lunes, 13 de junio de 2016

EJERCICIOS PROCESSING

void setup() {
  size (600,400);
  background (1, 2, 3);
}
void draw () {
  stroke (0);
  fill (140, 100, 100);
 rectMode (LEFT);
  rect (mouseX, mouseY, 80,80);
  fill ((random(600)),(random(400)),60,60);
  ellipse ((random(600)),(random(400)),60,60);
}





void setup() {
  size (600,400);
  background (0);
}
void draw () {
  stroke ((random(600)),(random(400)),60,60);
  fill (80, 3, 2);
 rectMode (CENTER);
  rect (mouseX, mouseY, 80,80);
  fill ((random(600)),(random(400)),60,300);
  ellipse ((random(600)),(random(400)),60,300);
}







             // declare global variables
int xspeed, yspeed;
int xpos,ypos,wdth,ht;
            // initialize sketch
void setup() {
             // set sketch window size + background color
  size(600,400);
  background(170);
              // ball speed
  xspeed=10;
  yspeed=10;
              // ball size
  wdth = 70;
  ht=60;
              // turn off shapestroke rendering
  noStroke ();
              // initial ball placement
  xpos=width/2;
  ypos=height/2;
  frameRate(190);
}
            // begin animation loop
void draw(){
              // draw ball
  smooth ();
  fill ((random (600)),(random (256)),(random (256)));
  ellipse(xpos,ypos,wdth,ht);
             // upgrade position values
  xpos+=xspeed;
  ypos+=yspeed;
  /*conditionals
   detects ball collission with sketch window edges
   also accounts for thickness of ball
   */
  if(xpos>=width-wdth/2 || xpos<=wdth/2){
    xspeed*=-1;
  }
  if (ypos>=height-ht/2 || ypos<=ht/2){
    yspeed*=-1;
  }
}






void setup() {
  size (400,600);
  background (255);
}
void draw () {
}
void mousePressed() {
  strokeWeight (9);
  smooth ();
  fill (random (60), random (230), random (256));
 rectMode (CENTER);
  rect (mouseX,mouseY,50,50);
}
void keyPressed () {
  background (255);
}

No hay comentarios:

Publicar un comentario