lunes, 4 de junio de 2012

REFERENCIA

import processing.video.*;


Movie myMovie;
void setup() {
  size(640, 480, P2D);
  background(0);
  // Load and play the video in a loop
  myMovie = new Movie(this, "station.mov");
  myMovie.loop();
}
void movieEvent(Movie myMovie) {
  myMovie.read();
}
void draw() {
  tint(255, 20);
  image(myMovie, mouseX-myMovie.width/2, mouseY-myMovie.height/2);
}

lunes, 14 de mayo de 2012

CLASE 14mayo


EJERCICIOS 1 - 2

EJERCICIO 1
imágenes aleatorias



int cantidadImagenes = 4; //total de imagenes
int indexImagenes =0; //variable con la primera imagen
PImage[] imagenes = new PImage[cantidadImagenes];
void setup() {
  size(200,200);
for (int i = 0; i < imagenes.length; i ++ ) {
  imagenes[i] = loadImage( i + ".jpg");
}}
void draw() {
  image(imagenes[indexImagenes],0,0);
}
void mousePressed() {
  indexImagenes = int(random(imagenes.length));
}


..............................................................

EJERCICIO 2
imágenes aleatorias


int cantidadImagenes = 4; //total de imagenes
int indexImagenes =0; //variable con la primera imagen
PImage[] imagenes = new PImage[cantidadImagenes]; 
void setup() {
  size(200,200);
for (int i = 0; i < imagenes.length; i ++ ) {
  imagenes[i] = loadImage( i + ".jpg"); 
}
frameRate(3);
}
void draw() {
  background(0);
  image(imagenes[indexImagenes],0,0);
  indexImagenes = (indexImagenes + 1) % imagenes.length;
}


..............................................................

EJERCICIO 3


size(200,200);
loadPixels();
for (int i=0; i < pixels.length; i ++) {
float rand = random(225);
color c = color(rand,100);
pixels[i] = c;
}
updatePixels();
..............................................................

EJERCICIO 4


PImage img;
void setup() {
  size(200,200);
  img = loadImage("1.jpg");
}
void draw() {
  loadPixels();
  img.loadPixels();
  for (int y = 0; y < height; y++ ) {
  for (int x = 0; x < width; x ++ ) {
  int loc = x + y*height;
float r = red(img.pixels [loc]);
float g = green(img.pixels [loc]);
float b = blue(img.pixels [loc]);
pixels[loc] = color(r+10,g,b+100);
  }
}
updatePixels();



}

lunes, 23 de abril de 2012

clase 23 abril

LINEA QUE SE MUEVE HORIZONTALMENTE

//se declara un numero decimal
float a = 0.0;

void draw() {
  background(204); // color de fondo
  a = (a+0.5) % width; //asignarle un valor a la variable
  line(a,0,a,height); //modularlo para qe se mueva horizontal
  println(a); //imprimir para ver el valor de a
}

...........................................................

LINEA ALEATORIA1


size(500,100);
background(255);
strokeWeight(5);
smooth();

stroke(0,30);
line(20,50,480,50);

stroke(20,50,70);
float randX =random(width);
float randY =random(height);
line(20,50,randX,randY);
println(randX+","+randY);

...........................................................

LINEA ALEATORIA2


//posicion comienzo de la linea
float principioX = 10;
float principioY;
//posicion fin de la linea
float finX = 20;
float finY = 50;
//variable de random
float y = 50;


//ciclo for que cuenta de 20 a 480, y va sumando en x 10
for (int x=20; x<=480; x+=principioX) {
//se agrega un valor aleatorio entre 0 - 20 y se le resta 10
principioY = random(20) -10;
//se le entrega a y un numero aleatorio
y+= principioY;


line(x,y,finX,finY);
finX = x; //valor estatico
finY = y; //valor aleatorio

}

........................................................

CODIGO ALEATORIO1


int x,y;
void setup(){
size(200,200);
background(0);
colorMode(RGB,255,255,255,255); //RGB de color blanco, valor alfa
smooth(); //suaviza la forma
frameRate(30);
}
void draw() {
fill(0,1); //color de relleno negro segundp canal alfa
rect(0,0,width,height);
//calcula la probabilidad entre 0 y 100% basada en la posicion del mouse
float prob = (mouseX / (float) width);
//imprime la probabilidad de la posicion del mouse
println(prob);
//saca un numero entre 0 y 1
float r = random(1);
//imprime un numero entre 1 y 0
println(prob + "," + r);

//si el random es menor que la probabilidad ejecuta
if (r < prob) {
noStroke();
fill(255);
ellipse(x+10,y+10,10,10);
}
}

........................................................

CODIGO ALEATORIO2


int x,y;
void setup(){
size(200,200);
background(0);
colorMode(RGB,255,255,255,255); //RGB de color blanco, valor alfa
smooth(); //suaviza la forma
frameRate(30);
}
void draw() {
fill(0,1); //color de relleno negro segundp canal alfa
rect(0,0,width,height);
//calcula la probabilidad entre 0 y 100% basada en la posicion del mouse
float prob = (mouseX / (float) width);
//imprime la probabilidad de la posicion del mouse
println(prob);
//saca un numero entre 0 y 1
float r = random(1);
//imprime un numero entre 1 y 0
println(prob + "," + r);
//si el random es menor que la probabilidad ejecuta
if (r < prob) {
noStroke();
fill(255);
ellipse(x,y,10,10);
}
x = (x+10) % width;
if (x==0)
y = (y+10) % width;
}

lunes, 26 de marzo de 2012

clase 26 marzo

void setup(){
size (400,400);
}
void draw(){
for (int i = 5; i < 100; i += 5) {
stroke (255,0,0);
line (30,i,80,i);  }
//  if(i < 45) {
// else if (i < 65) {stroke(0,255,0); line (20,i,90,i); }
// else if (i < 100) { stroke(0,0,255); line (0,i,100,i); }
  }
}

..........................................


void setup(){
size (400,400);
}
void draw(){
for (int i = 5; i < 100; i += 5) {
if(i < 45){
    stroke (255,0,0);  //color borde
    line (30,i,80,i);  //linea
}
else if (i < 65) {stroke(0,255,0); line (20,i,90,i); }
else if (i < 100) { stroke(0,0,255); line (0,i,100,i); }
}
  }


..........................................

void setup() {
frameRate (50); //fotogramas por segundos
}
int posicion = 0;
void draw() {
background(204);
posicion++;
line (posicion,20,posicion,80);
if(posicion > width) {
  posicion = 0;
  }
}

..........................................

int pos = 2;
int bcolor = 255;
void setup (){
  size (300,300);
  frameRate (10);
}

void draw (){
pos++;
bcolor--;
for(int i = 5; i < 50; i += 10) {
fill(bcolor,bcolor,random (600));
noStroke();
rect(10,i,pos,10);
if (pos == 255){
// noLoop();
   }
   }
 }

..........................................

float trasparencia= 0.0; //variable con decimales

void setup(){
frameRate(30);
size(400,400);
background(0);
}
void draw (){
  for(int i=0; i < 200; i++) {
  for(int j=0; j < 200; j++) {
 //random
float r = random (0,255);
stroke(r);
point(i,j);
  }
  }
}

..........................................

float posicion= 0.0; //variable con decimales

void setup() {
frameRate(100); //velocidad
size(400,400);
background(0);
}
void draw (){
  posicion = posicion + .01;
  float n = noise(posicion) * height;
  strokeWeight(20);
  stroke(random(147), random(28), random(145), 15);
  line(n,0,n,400);
}


..........................................


//variables

int diam = 10; //diametro
float centX, centY; // tamaño de la elipse
void setup() {
  size (500,500);
  frameRate(40); //velocidad
  smooth(); //suavizado
  background(180);
  centX = width/2; //ancho dividido dos
  centY = height/2; //alto dividido dos
  noFill(); //sin relleno
  }
void draw() {
//si diam es menor o igual a 400 pasa algo
if(diam <= 700) {
stroke(114,random(226),133); // color borde
strokeWeight(20); //ancho
//background(180);
//dibuja elipse
ellipse(centX,centY,diam,diam);
//suma el diametro 10 pixeles
diam += 5;
    }
  }

Primer Trabajo Processing 3er Semestre

Colores