martes, 26 de agosto de 2008

Codigos

Antes que nada perdon por la falta de acentos, pero por problemas de conectividad estoy trabajando desde windows y el teclado esta configurado en ingles. En fin, les pongo los codigos de los ejemplos trabajados este lunes. Pueden hacer directo copy/paste a la ventana de processing y darle play.

Nos vemos manana (por cierto, tampoco hay n, bueno, me entienden no?)

Saludos.

void setup() {
size(200, 200);
background(0);
noStroke();
fill(102);
frameRate(25);}
int a = 0;
void draw() {
background(0);
fill(mouseX);
rect(120, 10, 80, 80);
fill (100, mouseX, 87);
rect (50,20, 50, 30);
fill(150,20,82);
ellipse(100, 154, 115, mouseY);
fill (mouseY,112,108);
triangle(98,90,0,59,30,40);
fill(256, 256, 256);
rect(mouseX, mouseY, 10, 10);
}

para darle formato con las tabulaciones solo deben poner ctrl+t en la ventana de processing.

import processing.opengl.*;
float a;
void setup() {
size(800, 600, OPENGL);
fill(0, 153); noStroke();
//frameRate(15);}
void draw() {
background(255);
translate(width/2, height/2);
rotateX(a);
rotateY(a*2);
//rotateX(mouseX/10);
//rotateY(mouseY/10);
fill(128, 32, 1);
ellipse(-0, -0, 400, 400);
rotateX(PI/2);
fill(1, 10, 100);
ellipse(-0, -0, 400, 400);
a += 0.05;
}

Los que no entiendan por favor chequen la documentacion en http://processing.org/reference/index.html

2 comentarios:

Anónimo dijo...

// Ping Pong
// by Krister Olsson http://tree-axis.com

// Loads a sound from the Web. Uses the
// audioOutputPan event to pan back and forth

// Created 1 May 2005
// Updated 18 May 2006

import krister.Ess.*;

AudioChannel mySound;

void setup() {
size(256,200);

// start up Ess

Ess.start(this);

mySound=new AudioChannel("http://www.tree-axis.com/Ess/_examples/_sounds/counting.aiff");

mySound.smoothPan=true;
mySound.pan(Ess.LEFT);
mySound.play(Ess.FOREVER);

mySound.panTo(1,2000);

frameRate(30);

noStroke();
fill(255);
}

void draw() {
background(0,0,255);

// paddles

rect(5,80,10,40);
rect(241,80,10,40);

// pong

float interp=lerp(15,236,(mySound.pan+1)/2.0);

rect(interp,98,5,5);
}

// clean up Ess before exiting

public void stop() {
Ess.stop();
super.stop();
}

void audioOutputPan(AudioOutput c) {
// reverse pan direction

c.panTo(-c.pan,2000);
}

karen turcott dijo...

Hola jordi!! jejej aquie está mi código,le cambie el color y lo de sonido no le entiendo m baja el prorama para macox mm bueno eso es todod oo bueno luego le cambio m´s cosas por lo pronto aqui etsá esto ;) bye atte ana karen

import traer.physics.*;

ParticleSystem physics;
Particle[] particles;
Particle od;
Particle oi;
Particle aod;
Particle aoi;

void setup()
{
size( 400, 400 );
smooth();
fill( 0 );
frameRate( 24 );
//ellipseMode( CENTER );

physics = new ParticleSystem( 5.0, 0.05 );

particles = new Particle[10];

//p = physics.makeParticle( 1.0, width/2, height/2, 0 );
particles[0] = physics.makeParticle( 1.0, width/2, height/2, 0 );
particles[0].makeFixed();

od= physics.makeParticle( 5.0, width/3, height/3, 0 );
oi= physics.makeParticle( 5.0,2* width/3, height/3, 0 );
aod= physics.makeParticle( 5.0, width/3, height/3, 0 );
aoi= physics.makeParticle( 5.0,2* width/3, height/3, 0 );
aod.makeFixed();
aoi.makeFixed();
physics.makeSpring( aod,od, 2.0, 0.1, 0.01 );
physics.makeSpring( aoi,oi, 3.0, 0.1, 0.05 );

for ( int i = 1; i < particles.length; ++i )
{
particles[i] = physics.makeParticle( 1.0, width/2, height/2+i, 0 );
physics.makeSpring( particles[i-1], particles[i], 2.0, 0.1, 0.01 );
}

particles[particles.length-1].setMass( 5.0 );
}

void draw()
{
physics.advanceTime( 1.0 );

if ( mousePressed )
{
particles[particles.length-1].moveTo( mouseX, mouseY, 0 );
particles[particles.length-1].velocity().clear();
oi.moveTo( 50 +mouseX,mouseY-40, 0 );
od.moveTo( mouseX-50, mouseY-40, 0 );
}

background(#FF69B4);

beginShape(POLYGON);
fill(#9370DB);
stroke(0);
curveVertex( particles[0].position().x(), particles[0].position().y() );
for ( int i = 0; i < particles.length; ++i )
{
curveVertex( particles[i].position().x(), particles[i].position().y() );
}
curveVertex( particles[particles.length-1].position().x(), particles[particles.length-1].position().y() );
endShape();
fill(#1E90FF);
triangle( particles[0].position().x(), particles[0].position().y(),particles[0].position().x()+25, particles[0].position().y()+25,
particles[0].position().x()-25, particles[0].position().y()+25);
fill(#008000);
rect( particles[particles.length-1].position().x(), particles[particles.length-1].position().y(), 60, 20 );
rect( particles[particles.length-1].position().x(), particles[particles.length-1].position().y(), -60, 20 );
fill(#FFFF00);
ellipse( od.position().x(),od.position().y(),20,50);
ellipse( oi.position().x(),oi.position().y(),50,20);


}

void mouseReleased()
{
particles[particles.length-1].setVelocity( (mouseX - pmouseX), (mouseY - pmouseY), 0 );
}