martes, 15 de noviembre de 2011

avance examen

void setup() {
size(500 , 500);
smooth();
strokeWeight(6);
background(135, 206, 235);
}
public void draw() {
loadPixels();
VectorType fernRootPos = new VectorType(width / 2, height*0.97f);
VectorType fernBranchPos = new VectorType(width / 2 + (mouseX-width/2)*0.2, height * 0.8f + mouseY*0.1);
float bending = -(mouseX-width/2)*0.0005;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
float scaling, rotation;
VectorType uv = new VectorType(x, y);
VectorType limb = new VectorType(uv);
scaling = 1.23f;
rotation = bending;
limb.affineTransformation(scaling, rotation, fernBranchPos);
limb.x += fernRootPos.x - fernBranchPos.x;
limb.y += fernRootPos.y - fernBranchPos.y;
int limbColor = getColor(limb, pixels);
VectorType leftArm = new VectorType(uv);
scaling = 2.5f;
rotation = -0.9+ bending;
leftArm.affineTransformation(scaling, rotation, fernBranchPos);
leftArm.x += fernRootPos.x - fernBranchPos.x;
leftArm.y += fernRootPos.y - fernBranchPos.y;
int leftArmColor = getColor(leftArm, pixels);
VectorType rightArm = new VectorType(uv);
scaling = 2.5f;
rotation = 0.9 + bending;
rightArm.affineTransformation(scaling, rotation, fernBranchPos);
rightArm.x += fernRootPos.x - fernBranchPos.x;
rightArm.y += fernRootPos.y - fernBranchPos.y;
int rightArmColor = getColor(rightArm, pixels);
int col = minColor(leftArmColor, limbColor);
col = minColor(col, rightArmColor);
set(x, y, col);
}
}
line(fernRootPos.x, fernRootPos.y, fernBranchPos.x, fernBranchPos.y);
ellipse(mouseX, mouseY, 25, 25);
fill(135, 206, 235);
}
public int minColor(int c1, int c2) {
float r1, g1, b1, r2, g2, b2;
r1 = red(c1);
r2 = red(c2);
g1 = green(c1);
g2 = green(c2);
b1 = blue(c1);
b2 = blue(c2);
return color(min(r1, r2), min(g1, g2), min(b1, b2));
}
public int maxColor(int c1, int c2) {
float r1, g1, b1, r2, g2, b2;
r1 = red(c1);
r2 = red(c2);
g1 = green(c1);
g2 = green(c2);
b1 = blue(c1);
b2 = blue(c2);
return color(max(r1, r2), max(g1, g2), max(b1, b2));
}
/**
* @param subPixelPosition
* @return bilinear filtered color
*/
public int getColor(VectorType subPixelPosition, int[] sourcePixels) {
int x = floor(subPixelPosition.x);
int y = floor(subPixelPosition.y);
float u = subPixelPosition.x - x;
float v = subPixelPosition.y - y;
if (x < 0 || y < 0 || x >= width - 1 || y >= height - 1) {
return color(255);
}
int indexTopLeft = x + y * width;
int indexTopRight = x + 1 + y * width;
int indexBottomLeft = x + (y + 1) * width;
int indexBottomRight = x + 1 + (y + 1) * width;
try {
int col = lerpColor(lerpColor(sourcePixels[indexTopLeft],
sourcePixels[indexTopRight], u), lerpColor(
sourcePixels[indexBottomLeft], sourcePixels[indexBottomRight], u), v);
float r = red(col);
float g = green(col);
float b = blue(col);
r = constrain(r + 10, 0, 255);
g = constrain(g + 30, 0, 255);
b = constrain(b + 20, 0, 255);
return color(r, g, b);
} catch (Exception e) {
System.out.println("getBufferColor: " + x + " | " + y);
}
return color(0);
}
public class VectorType {
float x, y;
public VectorType() {
x = 0;
y = 0;
}
public VectorType(float x, float y) {
this.x = x;
this.y = y;
}
public VectorType(VectorType v) {
x = v.x;
y = v.y;
}
public VectorType add(VectorType vector) {
x += vector.x;
y += vector.y;
return this;
}
public VectorType sub(VectorType vector) {
x -= vector.x;
y -= vector.y;
return this;
}
public float distance(VectorType theOtherVector) {
return sqrt((x - theOtherVector.x) * (x - theOtherVector.x)
+ (y - theOtherVector.y) * (y - theOtherVector.y));
}
public float length() {
return sqrt(x * x + y * y);
}
public float angle() {
return atan2(x, y);
}
public VectorType affineTransformation(float scaling, float rotation,
VectorType center) {
sub(center);
float ang, d;
ang = angle() + rotation;
d = length();
x = scaling * sin(ang) * d;
y = scaling * cos(ang) * d;
add(center);
return this;
}
}





miércoles, 2 de noviembre de 2011

código y sonido

Import ddf.minim.*;

AudioPlayer player;
Minim minim;

import ddf.minim.*;
PImage img;
float speed =2.5;
int diameter =20;
float x;
float y;

void setup(){

size(440,420,P2D);
minim = new Minim(this);
player = minim.loadFile("m.mp3", 2048);
// play the file
player.play();

img =loadImage("m.jpg");
smooth();
x=width/2;
y=height/2;

}

void draw(){
image(img,0,0,440,420);

//background(204);
x += random(-speed,speed);
y += random (-speed,speed);
translate(mouseX,mouseY);
ellipse (x,y,diameter,diameter);

}

void stop()
{
// always close Minim audio classes when you are done with them
player.close();
minim.stop();

super.stop();
}

código y sonido

Import ddf.minim.*;

AudioPlayer player;
Minim minim;

import ddf.minim.*;
PImage img;
float speed =2.5;
int diameter =20;
float x;
float y;

void setup(){

size(440,420,P2D);
minim = new Minim(this);
player = minim.loadFile("m.mp3", 2048);
// play the file
player.play();

img =loadImage("m.jpg");
smooth();
x=width/2;
y=height/2;

}

void draw(){
image(img,0,0,440,420);

//background(204);
x += random(-speed,speed);
y += random (-speed,speed);
translate(mouseX,mouseY);
ellipse (x,y,diameter,diameter);

}

void stop()
{
// always close Minim audio classes when you are done with them
player.close();
minim.stop();

super.stop();
}

codigo



codigos con fotos.


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

void setup(){
size(240,120);
img =loadImage("s.jpg");
smooth();
x=width/2;
y=height/2;

}
void draw(){
image(img,0,0,240,120);
//background(204);
x += random(-speed,speed);
y += random (-speed,speed);
translate(mouseX,mouseY);
ellipse (x,y,diameter,diameter);

}

martes, 1 de noviembre de 2011

modificaciones

principalmente quiero lograr modificar este código... integrándote alguna forma para que se cree una interactividad desde una cámara web o de sonido.

Lo principal es introducir a este código algo con sonido ya que tiene mas que ver con el tema al que me estoy refiriendo

código de examen


/**
* Recursive Tree
* by Daniel Shiffman.
*
* Renders a simple tree-like structure via recursion.
* The branching angle is calculated as a function of
* the horizontal mouse location. Move the mouse left
* and right to change the angle.
*/
float theta;

void setup() {
size(640, 360);
smooth();
}

void draw() {
background(0);
frameRate(30);
stroke(255);
// Let's pick an angle 0 to 90 degrees based on the mouse position
float a = (mouseX / (float) width) * 90f;
// Convert it to radians
theta = radians(a);
// Start the tree from the bottom of the screen
translate(width/2,height);
// Draw a line 120 pixels
line(0,0,0,-120);
// Move to the end of that line
translate(0,-120);
// Start the recursive branching!
branch(120);

}

void branch(float h) {
// Each branch will be 2/3rds the size of the previous one
h *= 0.66;
// All recursive functions must have an exit condition!!!!
// Here, ours is when the length of the branch is 2 pixels or less
if (h > 2) {
pushMatrix(); // Save the current state of transformation (i.e. where are we now)
rotate(theta); // Rotate by theta
line(0, 0, 0, -h); // Draw the branch
translate(0, -h); // Move to the end of the branch
branch(h); // Ok, now call myself to draw two new branches!!
popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state
// Repeat the same thing, only branch off to the "left" this time!
pushMatrix();
rotate(-theta);
line(0, 0, 0, -h);
translate(0, -h);
branch(h);
popMatrix();
}
}

miércoles, 5 de octubre de 2011

Descripción ante-royecto


1.- Descripcion: (materiales, medidas, etc.)

Mi idea principal es crear la evolución que tiene los arboles, desde lo mas mínimo hasta llegar a la plenitud de éste, de mi árbol principalmente, el que crearé en processing.

El trasfondo principal es dar importancia a aquellas cosas simples de las que mas me rodeo, por el lugar donde vivo y así darle suma importancia a los arboles que observo y darme la motivación para crear un proyecto que me deje satisfecha.

Crear un registro fotográfico con arboles de mi vida cotidiana en el lugar donde vivo, los cuales tengan una forma interesante.

Crear diferentes cuadros del un mismo código, o sea hacer evidencia en papel de lo que haré en processing. Junto a un computador que este evidenciando el proceso que quiero llevar acabo.



2.- Fundamentacion: (referentes, citas, imágenes, autores, artistas, conceptos, etc.)
En openprocessing hay muchas ejemplo de esto, no exactamente de lo que quiero hacer pero si de la idea general.

http://www.openprocessing.org/visuals/?visualID=4162
http://www.openprocessing.org/visuals/?visualID=10318

http://www.openprocessing.org/collections/?collectionID=19


3.- Objetivos:

Sensibilizar al espectador, y evidenciar el proceso o el crecimiento de un arbol, la calma de éste, evidencia de un movimiento lento y delicado.