Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, March 17, 2010

GUI for Processing

In response to Francesca's post here is a little sample of a GUI that can control x parameters by simply feeding the value of the sliders into whatever you need to change. Thanks Anton for integrating Zoog with Handles:-)
For now only the first two slides do something (change the size of the head) but you can download the source, open it in Processing and assign the other sliders to change color, position or whatever you want in your project. For example in the code:
ellipse(300,70, handles[0].length * 2, handles[1].length *2); handles[0] (the first handle) changes the size of the head in the X dimension and handles[1] in the Y
The reason it is multiplied by 2 is simply to extend the range since in the original code the handles are only giving values from 0 to 89 which was too small a change for the head. Experiment with that. Enjoy
































This browser does not have a Java Plug-in.



Get the latest Java Plug-in here.









Source code: Handles_Control

Thursday, February 4, 2010

OOPS!

Thanks Ashutosh for the math. Play with the code! Make sure to remove the comment tag at /*the beginning and at the end */ which I had to add to prevent blogger from nagging!






























This browser does not have a Java Plug-in.



Get the latest Java Plug-in here.








/*int NO_OF_CIRCLES = 10;

float[] theta = new float[NO_OF_CIRCLES];
float[] deltaTheta = new float[NO_OF_CIRCLES];
float [][] nextXY = new float[NO_OF_CIRCLES][NO_OF_CIRCLES] ;
//int [][][] colorOFCIRCLE = new int [NO_OF_CIRCLES][NO_OF_CIRCLES][NO_OF_CIRCLES] ;
color[] colors = new color[NO_OF_CIRCLES] ;

void setup()
{
size(400,400);

//setup first case then the rest
theta[0] = 0 ;
for (int i = 1 ; i <>
theta[i] = theta[i-1] + 15 ;
//setup first case then the rest
deltaTheta[0] = 0.01 ;
for (int i = 1 ; i <>
deltaTheta[i] = deltaTheta[i-1] + 0.05;
//offseting individual circle translations. Could be time based or random
deltaTheta[1] = 0.07;
deltaTheta[2] = 0.09;
deltaTheta[3] = 0.05;
deltaTheta[4] = -0.04;
deltaTheta[5] = 0.03;
deltaTheta[6] = -0.06;
deltaTheta[7] = 0.01;
deltaTheta[8] = -0.08;

//assign random colors to all circles
color c1 = color(102, 102, 0);

for (int i = 1 ; i <>
{
colors[i] = color(random(255),random(255),random(255), 125) ;
}
}
void draw()
{
float siz = random(255);
background(0);
nextXY[0][0] = 200; //mouseX;
nextXY[0][1] = 200; //mouseY;
smooth();
noStroke();

fill(0,0,255,126);
//draw first circle
ellipse(nextXY[0][0], nextXY[0][1], 60, 60); // Gray ellipse
theta[0] += deltaTheta[0] ;

//now draw the rest
for (int i = 1; i <>
{
fill((color)colors[i]) ;
nextXY[i][0] = nextXY[i-1][0] + 60 * cos(theta[i-1]) ;
nextXY[i][1] = nextXY[i-1][1] + 60 * sin(theta[i-1]) ;
ellipse(nextXY[i][0], nextXY[i][1], 60, 60);
theta[i] += deltaTheta[i] ;
}
try{
Thread.currentThread().sleep(10);
}catch (InterruptedException ie) {}
}

Friday, January 8, 2010

ART && CODE

The 2009 Art&&Code Symposium gathered together some of the pioneers of the open source tools intended to democratize "computer programming for artists, young people, and the rest of us."

The Art&&Code symposium series as well as the social network around it was created by Golan Levin, who is a Professor of Electronic Art at Carnegie Mellon and the director of the STUDIO for Creative Inquiry. You can see some fascinating work of his and his collaborators here.

This video is the presentation of Processing, the program developed by Ben Fry and Casey Reas, which is one of the important open source visualization tools that we have at our disposal.

The presentation is a little long but make sure you get to the demos by the various artists they feature and whose work you will surely enjoy and might trigger some ideas of your own.


ART && CODE SYMPOSIUM: Processing, Ben Fry and Casey Reas from STUDIO for Creative Inquiry on Vimeo.