You are on page 1of 4

CODIGO PROCESSING INTERACTIVE DANZABILITY 0.1 Beta Version DESCARGABLE EN http://www.mediafire.com/?

zsdz5dnnzryvk4n
import processing.video.*; // Se importa la libreria de Video Capture video; // Inicia captura de Video

int num = 5; // Total de formas que genera el trazado en un tiempo int[] x = new int[num]; int[] y = new int[num]; int barWidth = 5; int lastBar = -1; int brightestX = 100; // Valores de Brillo u Oscuridad en X int brightestY = 100; // Valores de Brillo u Oscuridad en Y int pbrightestX = 0; int pbrightestY = 0; PFont fontA; float easing = 0.05;

void setup() { background(0); size (1280,720); // Tamao del Lienzo respecto a la resolucion max. De una Camara Web HD smooth(); video = new Capture(this,width,height, 30); // Nueva captura ajustada al tamao del lienzo colorMode(RGB, width, height, 100); // Modo de Color RGB //frameRate(20); // Define el FramRate }

void draw() { if (video.available()) { video.read(); // Inicio de lectura del Video float brightestValue = 255; // Valor, numero entero del pixel mas claro RGB=255, Asi el programa buscar el pixel mas claro. video.loadPixels(); int index = 0; for (int y = 0; y < video.height; y++) { // Inicio de condicional de lectura y comparacin del pixel mas claro valor BrightestValue for (int x = 0; x < video.width; x++) { // Get the color stored in the pixel int pixelValue = video.pixels[index]; // Determine the brightness of the pixel float pixelBrightness = brightness(pixelValue); // If that value is brighter than any previous, then store the // brightness of that pixel, as well as its (x,y) location if (pixelBrightness < brightestValue) { brightestValue = pixelBrightness; brightestY = y;// Valor en Y del pixel mas claro, apartir del condicional

brightestX = x; // Valor en X del pixel mas claro, apartir del condicional } index++; } } fill(255, 204, 0, 128); ellipse(brightestX, brightestY, 10, 10); strokeWeight(0); //line(0,0,brightestX, brightestY); //line(640,0,brightestX, brightestY); //line(0,480,brightestX, brightestY); //line(640,480,brightestX, brightestY); } if (mousePressed && (mouseButton == RIGHT)){ background(0); // Esta funcin opera como Reset del programa, limpia el lienzo, poniendo un fondo nuevo al hacer click derecho. } variableEllipse(brightestX, brightestY, pbrightestX, pbrightestY);

if (mousePressed == false) { for (int i = x.length-1; i > 0; i--) { //ellipse catches up x[i] = x[i-1]; y[i] = y[i-1]; } x[0] = brightestX; // Set the first element y[0] = brightestY; // Set the first element

//////////////// COLOR //////////////////////// for (int i = 0; i < x.length; i++) { int whichBar = brightestX / barWidth; //saturation tutorial processing site if (whichBar != lastBar) { int barX = whichBar * barWidth; //creates a pallate depending on mouseX fill(x[i], y[i], 66); // mouseY cooridnate lastBar = whichBar; } stroke(3); ellipse(x[i], y[i], 40, 40); } //Este condicional define el color de relleno que llevara cada elipse que generara el trazado, dependiendo de la posicion en las coordenadas (X,Y) del lienzo en ejecucion la elipse tomara ese color en valores RGB. ////////////////////// COLOR //////////////////// }

if (mousePressed && (mouseButton == LEFT)) { if (frameCount % 300 == 0) { rect(0, 0, width, height); } stroke(3); ellipse (brightestX, brightestY, 20, 20); /////////////->>>>>>>>>>>> UNION ///// // Aqu la elipse toma la posicion del pixel mas claro con las coordenadas de los valores BrightestX y BrightestY for (int i = x.length-1; i > 0; i--) { // as x length gets longe //gradually elipse catches up // I want the last ellipse that catches up to only have the text x[i] = x[i-1]; y[i] = y[i-1]; }

x[0] = brightestX; y[0] = brightestY; for (int i = 0; i > x.length; i++) { int whichBar = brightestX / barWidth; if (whichBar != lastBar) { int barX = whichBar * barWidth; fill(x[i], y[i], 255); lastBar = whichBar; } ellipse(x[i], y[i], 20, 20);

} } pbrightestX = brightestX; pbrightestY = brightestY;

void variableEllipse(int x, int y, int px, int py) { float speed = abs(x-px) + abs(y+py); noStroke(); ellipse(x, y, speed/10, speed/10); // En general esta condicional se ocupa de las elipses secundarias que seran las que marcarn la posicin en (X,Y) con respecto al tamao de esta misma. Tiene la capacidad de cambiar de color en caso de que sea necesario, adicionando un fill(); }

void variabletext(){ textSize(40); fill(0); text("Slime Trail", 100, 100); } ////////////////////// Fin de la Programacion//////////////////////

You might also like