martes, 29 de abril de 2014


float x;
float y;
float velocidad = 2.5;

void setup(){
  size(240,220);
}
void draw(){
    y += random(-velocidad, velocidad);
  x += random(-velocidad, velocidad);
 
  ellipse(x+50,y+50,30,30);
}

______________________________________________________________________________

void setup(){
  size(240,320);
}
void draw(){
  //for= variable, comparacion y sumatoria
  for (int x=20; x < width; x +=20){
    line(x,20,x,100);
  }
_______________________________________________________________________________

void setup(){
  size(240,320);
}
void draw(){
  background(125);
  //for= variable, comparacion y sumatoria
  for (int x=20; x < width; x +=20){
    float mx = mouseX / 10;
    println(mx);
    float aleatorio = random(-mx,mx);
    line(x+aleatorio,20,x,100);
  }
}

sonido


//importar boblioteca
//sin esto el sonido no funciona

import ddf.minim.*;

//audio player tipo de variable
//player es el nombre de la variable
AudioPlayer sonido;
//Minim es el tipo de variable
//minim objeto que estoy creando
//minim es un nombre variable
Minim minimo;

void setup(){
  size(200,200);
  //gwenera un clase para trabajar con el sonido
    minimo = new Minim(this);
      sonido = minimo.loadFile("cancion.mp3", 2048);
      sonido.play();
 
}

void draw(){
  background(100,0,100);
}







_______________________________________________________________________________



//importar boblioteca
//sin esto el sonido no funciona

import ddf.minim.*;

//audio player tipo de variable
//player es el nombre de la variable
AudioPlayer sonido;
//Minim es el tipo de variable
//minim objeto que estoy creando
//minim es un nombre variable
Minim minimo;

void setup(){
  size(200,200);
  //gwenera un clase para trabajar con el sonido
    minimo = new Minim(this);
      sonido = minimo.loadFile("cancion.mp3", 2048);
      sonido.play();
 
}

void draw(){
  background(100,0,100);
  /*if(keyPressed) {
    if (key == 'b' || key == 'B') {
      fill(0);
      sonido.pause();
    }
  } else {
    sonido.play();
 
  }*/
  if (mouseX <= 100){
    sonido.play();
  } else {
    sonido.pause();
  }

}

_______________________________________________________________________________



lunes, 29 de octubre de 2012

CLASE 29-10-2012


EJERCICIO 2


import processing.opengl.*;
void setup(){

  size(600,600,OPENGL);
  noStroke();
}
void draw() {
  background(0);
  translate(width/2,height/2);
  pointLight(150,100,0,200,0,0);
  pointLight(150,100,0,-200,0,0);
  rotateY(map(mouseX,0,width,0,PI));
  rotateX(map(mouseY,0,height,0,PI));
  box(200);
}

EJERCICIO 3



import processing.opengl.*;
PImage img;
void setup(){
  size(640,360,OPENGL);
  img = loadImage("zombie.jpg");
  noStroke();
}

void draw(){
  background(125);
  translate(width/2,height/2);
  rotateY(map(mouseX,0,width,-PI,PI));
  beginShape();
  texture(img);
  vertex(-100,-100,0,0,0);
  vertex(100,-100,0,100,0);
  vertex(100,100,0,200,200);
  vertex(-100,100,0,0,200);
  endShape();
}







lunes, 8 de octubre de 2012

trabajo en clases


PImage pta1;
PImage pta2;
PImage pta3;
PImage pto1;
PImage pto2;
PImage pto3;

float speed = 6.5;

float x;
float y;

void setup() {
  fill(242,141,7);
  size(700,700);
  pta1 = loadImage("camilasilva.jpg");
  pta2 = loadImage("camilasilva2.jpg");
  pta3 = loadImage("camilasilva3.jpg");
  pto1 = loadImage("maximilianopino.jpg");
  pto2 = loadImage("maximilianopino2.jpg");
  pto3 = loadImage("maximiliano3.jpg");
 
  smooth();
  x = width/1;
  y = height/1;

}
void draw() {
  x += random(-speed, speed);
  y += random(-speed, speed);
 
  image(pta1, x-100, y-200, 100, 100);
  image(pta2, x-400, y-500, 100, 100);
  image(pta3, x-300, y-400, 100, 100);
  image(pto1, x-200, y-100, 100, 100);
  image(pto2, x-600, y-700, 100, 100);
  image(pto3, x-700, y-600, 100, 100);
 
 
 
}

clase 08 de octubre


// 00 MOVIMIENTO /////////////////////////////

float a;

void setup() {
  size(640, 360);
  stroke(255);
  a = height/2;
}

void draw() {
  background(51);
  line(0, a, width, a);
  a = a - 0.5;
}


// 01 RECONOCIMIENTO DE BORDE

float a;

void setup() {
  size(640, 360);
  stroke(255);
  a = height/2;
}

void draw() {
  background(51);
  line(0, a, width, a);
  a = a - 0.5;
  if (a < 0) {
    a = height;
  }
}


// 02 RECONOCIMIENTO DE BORDE

 int rad = 60;        // ancho de l figura
float xpos, ypos;    // posiciion inicial  

float xvelocidad = 2.8;  // velocidad en x
float yvelocidad = 2.2;  // velocdad en y

int xdireccion = 1;  // direccion en x
int ydireccion = 1;  // direccion en y


void setup()
{
  size(640, 360);
  noStroke();
  frameRate(30);
  ellipseMode(RADIUS);
 
  xpos = width/2;
  ypos = height/2;
}

void draw()
{
  background(102);
 
  /*
  xpos = xpos + ( xvelocidad * xdireccion );
  ypos = ypos + ( yvelocidad * ydireccion );
 
  if (xpos > width-rad || xpos < rad) {
    xdireccion *= -1;
  }
  if (ypos > height-rad || ypos < rad) {
    ydireccion *= -1;
  }
*/
  ellipse(xpos, ypos, rad, rad);
}


// 03 RANDOM ////////////////////////////////

float speed = 2.5;
int diameter = 20;
float x;
float y;

void setup() {
  size(240, 120);
  smooth();
  x = width/2;
  y = height/2;
}

void draw() {
  x += random(-speed, speed);
  y += random(-speed, speed);
  ellipse(x, y, diameter, diameter);
}

// 04 TIMER


int tiempo1 = 2000;
int tiempo2 = 4000;
float x = 0;

void setup() {
  size(480, 120);
  smooth();
}

void draw() {
  int tiempoActual = millis();
  background(204);
  if (tiempoActual > tiempo2) {
    x -= 0.5;
  } else if (tiempoActual > tiempo1) {
    x += 2;
  }
  ellipse(x, 60, 90, 90);
}


// 06 TRANSLATE

void setup() {
  size(120, 120);
}

void draw() {
  translate(mouseX, mouseY);
  rect(0, 0, 30, 30);
  translate(35, 10);
  rect(0, 0, 15, 15);
}


// 07 ROTATE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  rotate(angle);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}


// 08 ROBOT


float rango = 0.0;
float velocidad = 0.005;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  background(204);
  translate(20, 25);  
  rotate(rango);
  strokeWeight(12);
  line(0, 0, 40, 0);
  translate(40, 0);    
  rotate(rango * 2.0);
  strokeWeight(6);
  line(0, 0, 30, 0);
  translate(30, 0);    
  rotate(rango * 2.5);
  strokeWeight(3);
  line(0, 0, 20, 0);
 
  rango += velocidad;
 
  if ((rango > 1) || (rango < 0)) {
    velocidad *= -1;
  }

}



// ROTATE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  rotate(angle);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}



// 07 SCALE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  scale(sin(angle) + 2);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}






lunes, 10 de septiembre de 2012

clase del 10 de septiembre

ejercicio 1:


/* graficar linea */

size(480,120); //tamaño del documento
smooth(); //suavisar la linea
strokeWeight(8); //ancho de linea
line(20,40,60,80); //dibujamos la linea en el plano


ejercicio 2:


/* ciclo for */

size(480,120); //tamaño del documento
smooth(); //suavisar la linea
strokeWeight(8); //ancho de linea
line(20,40,60,80); //dibujamos la linea en el plano
line(40,40,80,80);


ejercicio 3:


/* ciclo for (trama repetida de un objeto determinado)*/

size(480,120); //tamano sketch
smooth();
strokeWeight(8); //anchio linea
//el ciclo for es un contador que cuenta
//una cantidad de veces segun una condicion
//determinada
for(int i=20; //variable y valor
    i <400; //si es menora 400
    i +=60) { //le suma i 60
  rect(i,40,i,80);
}


ejercicio 4:

size(480,120); //tamano sketch
background(0);
smooth();
noStroke(); //anchio linea
//for (int y = 0;y <= height; y += 40) {
 //reconoce el ancho total de la aplicacion
for(int x=0; x<= width; x +=40) {
    fill(random(255), random(255), random(255),
    random(255));
    ellipse (x,y,40,40);
}
}

ejercicio 5:

// void= vendria siendo una funcion
//funciuon es una accion que va a cumplir el programa
//siempre la funcion se le da un nombre (){}
//la funcion que cumple siempre va a estar dentro de las llaves
//setup es para setear el programa, es decir,
//cosas que no se van a modificar
void setup() {
  println("estoy partiendo");
}
//aqui los objetos van siendo modificados en la ejecucion
// del programa

void draw() {
  println("estoy ejecutando");
}

ejercicio 6:

void setup() {
  size(480,120);
  fill(0,102);
  smooth();
  noStroke();
}

void draw() {
  //background(204);
  //ellipse(mouseX, mouseY,9,9);
  ellipse(0,0,9,9);
}
  
ejercicio 7:

void setup() {
  size(480,120);
  fill(0,102);
  smooth();
  noStroke();
}

void draw() {
  //background(204);
  ellipse(mouseX, mouseY,9,9);
  ellipse(0,0,9,9);
}
  

ejercicio 8:


void setup () {
  size (240,120);
  smooth ();
  strokeWeight (30);
}
void draw () {
  background (204);
  stroke (103);
  line (40,0,70,height);
  //if (mousePressed == true) {
    // stroke(0);
    //}
    line (0,70,width,50);
}


 ejercicio 9 (ejercicio 8 pero variado):


void setup () {
  size (240,120);
  smooth ();
  strokeWeight (30);
}
void draw () {
  background (204);
  stroke (103);
  line (40,0,70,height);
  if (mousePressed == true) {
    stroke(0);
    }
    line (0,70,width,50);
}

ejercicio 10 (movimiento del teclado):


void setup () {
  size (240,120);
  smooth ();
}
void draw () {
  background (204);
  line (20,20,220,100);
  if (keyPressed) {
    line (220,20,20,100);
}
}

ejercicio 11:


void setup () {
  size (240,120);
  smooth ();
}
void draw () {
  background (204);
  //condicional multiple nos permite trabajar con multiples teclas
  if (keyPressed) {
    if ((key == 'h') || (key == 'H')) {
      line (30,60,90,60);
    }}
    if ((key == 'n') || (key == 'N')) {
    
    line (30,20,30,100);
    line (90,20,90,100);
  }
}

ejercicio 12:


//variable nombre x 215
int x = 215;
void setup () {
size (480,120);
}
void draw () {
 if (keyPressed && (key == CODED)) {
    if (keyCode == LEFT) {
      x--; //restar en un punto el valor de x
    }
    //else if (keyCode == RIGHT) {
      // x++; //suma en un punto el valor de x
      //}
  }
  rect (x,45,50,50);
}



lunes, 27 de agosto de 2012

27 de agosto

ejercicio 1:

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
PImage lobo; //variable imagen
lobo =loadImage("lobo.jpg"); //cargar imagen
image(lobo,20,20,350,300); //graficar imagen

ejercicio 2 :

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
//color amarillo = color(220,214,41);
PImage lobo; //variable imagen
lobo =loadImage("lobo.jpg"); //cargar imagen
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
noTint();
image(lobo,50,0,200,150);


ejercicio 3:



/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
//color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
noTint();
image(conejo

ejercicio 4: 

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
//color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
noTint();
image(conejo,50,0,200,150);


ejercicio 5:

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
noTint();
image(conejo,50,0,200,150);
tint(amarillo);
image(lobo,100,0);

ejercicio 6:

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
tint(amarillo);
image(conejo,50,0,200,150);
tint(amarillo);


ejercicio 7:

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");
tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen
tint(amarillo);
image(conejo,50,0,200,150);
tint(amarillo);

ejercicio 8:

/*01 carga imagen*/
/*variable de la imagen,
tipo de la variable define
lo que es*/

size(500,500);
color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");

tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen

noTint();//no contiene amarillo
image(conejo,50,0,200,150);

tint(amarillo);//contiene tinte amarillo
image(lobo,50,200,200,250);// posision segunda imagen


ejercicio 9:

/*transparencia*/

PImage lobo; //variable imagen
PImage conejo; //variable imagen
size(400,400); //tamaño sketch
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg"); //cargar imagen
background(255); //fondo blanco

tint(255,102);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,200,200);//posicion imagen

tint(255,204,0,153);//R,G,B (color), transparencia
image(conejo,60,60,100,100);//posicion segunda imagen

/*color amarillo = color(220,214,41);
PImage lobo; //variable imagen
PImage conejo;
lobo =loadImage("lobo.jpg"); //cargar imagen
conejo =loadImage("conejo.jpg");

tint(55);//tinte, 25 brillante, 0 opaco
image(lobo,0,0,400,400); //posicion imagen

noTint();//no contiene amarillo
image(conejo,50,0,200,150);

tint(amarillo);//contiene tinte amarillo
image(lobo,50,200,200,250);// posision segunda imagen*/

ejercicio 10:


/*fuentes*/

PFont fuente;
fuente = loadFont("Monospaced-48.vlw");
size(400,400);//tamaño sketch
textFont(fuente);//define tipografia
fill(0);//color fuente negro
text("vision",0,40);//posicion letras
fill(250,30,50);//color fuente rojo
text("ver",0,70);//posicion letra
fill(50,120,20);// color fuente verde
text("vista",0,100);//posicion letra

ejercicio 10:


/*fuentes*/

PFont fuente;
fuente = loadFont("AppleMyungjo-48.vlw");
size(400,400);//tamaño sketch
textFont(fuente);//define tipografia
fill(0);//color fuente negro
text(19,0,40);//posicion numeros sin ""
text(72,0,70);//posicion nuemeros sin ""
text("R",0,100);//posicion letra


ejercicio 11:


size(400,400);//tamaño sketch
PFont fuente;
fuente = loadFont("AppleMyungjo-48.vlw");
size(400,400);//tamaño sketch
textFont(fuente);//define tipografia
fill(0);//color fuente negro
String s = "la vida se extingue los sueños jamás";
/*los valores arman una caja de texto,
text(s,x1,x1,width,heigth);*/
text(s,100,20,200,400);


ejercicio 12:

/*trasladar*/

rect(0,5,70,30);//rectangulo 1
translate(10,30);//transladar punto de inicio en x e y
rect(0,5,70,30);//rectangulo 2

/*tanslate(10,30);
rect(0,5,70,30);
*/

ejercicio 13:

/*rotacion*/

void setup(){//setea el programa
 size(200,200);
 background(255);//color de fondo
 smooth();//suavizar figura
 fill(192);//color figura
 noStroke();//sin borde
 rect(40,40,40,40);//rectangulo
}


ejercicio 14:


void setup(){//setea el programa
 size(200,200);
 background(255);//color de fondo
 smooth();//suavizar figura
 fill(192);//color figura
 noStroke();//sin borde
 rect(40,40,40,40);//rectangulo
 pushMatrix();
 translate(40,40);
 fill(0);
 rect(0,0,40,40);
 fill(255,0,0);
 rect(0,0,10,10);
 popMatrix();
}

ejercicio 15:


void setup(){//setea el programa
 size(200,200);
 background(255);//color de fondo
 smooth();//suavizar figura
 fill(192);//color figura
 noStroke();//sin borde
 rect(40,40,40,40);//rectangulo
 pushMatrix();
 translate(40,40);
 fill(0);
 rect(0,0,40,40);
 fill(255,0,0);
 rotate(radians(45));
 rect(0,0,20,20);
 popMatrix();
}

ejercicio 16:


void setup(){//setea el programa
 size(200,200);
 background(255);//color de fondo
 smooth();//suavizar figura
 fill(192);//color figura
 noStroke();//sin borde
 rect(40,40,40,40);//rectangulo
 pushMatrix();
 translate(40,40);//traslador punto de inicio
 fill(0);
 rect(0,0,40,40);
 fill(255,0,0);
 rotate(radians(45));
 rect(0,0,20,20);
 popMatrix();

 pushMatrix();
 translate(100,100);//traslador punto de inicio
 fill(230);
 scale(2.0); //agrandar imagen
 rotate(radians(45));//rotar
 rect(0,0,40,40);
 popMatrix();
}