Midva
YaBB Newbies
Offline
Posts: 1
exporting transparent video
Jun 24th , 2009, 1:04pm
Hi, we just managed to make a video out of sketch animation using saveFrame() function. Now we want to make a video with transparent background but we can't export even a single picture with transparent background. we tried using class createGraphics() but without luck. we are new to Processing and programming in general so a dummy help would be very welcome. Here is the code based on the example from Ira Greenberg's book: /* title: bouncing balls description: balls deflect off sketch window edges created: August 9, 2005 by: Ira Greenberg */ // global variables int ballCount = 500; int ballSize = 8; int ballSpeed = 3; float[]xspeed = new float[ballCount]; float[]yspeed= new float[ballCount]; float[]xpos = new float[ballCount]; float[]ypos = new float[ballCount]; float[]wdth = new float[ballCount]; float[]ht = new float[ballCount]; //initialize sketch void setup(){ //set sketch window size and background color smooth(); size(400, 400); background(0); //initialize values for all balls for (int i= 0; i< ballCount; i++){ // set varied ball speed xspeed[i] = random(1, ballSpeed); yspeed[i] = random(-ballSpeed, ballSpeed); // ball varied ball sizes wdth[i]= random(1, ballSize); ht[i]= wdth[i]; // set initial ball placement xpos[i] = width/2+random(-width/3, width/3); ypos[i] = height/2+random(-height/3, height/3); } // turn off shape stroke rendering noStroke(); //set the animation loop speed frameRate(30); } // begin animation loop void draw(){ /*updates background comment out to use alternate fill option below*/ background(0); for (int i=0; i<ballCount; i++){ /*To use this fill option: 1. uncomment fill call below 2. comment out the background function call above*/ fill(i*255/ballCount, i*100/ballCount, i*170/ballCount); //draw balls ellipse(xpos[i], ypos[i], wdth[i], ht[i]); //upgrade position values xpos[i]+=xspeed[i]; ypos[i]+=yspeed[i]; /*conditionals: detects ball collision with sketch window edges accounting for ball thickness. */ if (xpos[i]+wdth[i]/2>=width || xpos[i]<=wdth[i]/2){ xspeed[i]*=-1; } if (ypos[i]+ht[i]/2>=height || ypos[i]<=ht[i]/2){ yspeed[i]*=-1; } } } We would like to export this as a video with transparent background (=set of images with transparent background) so if anyone could fix our code or explain where/how to use createGraphics() we would be very very grateful. Thank you very much, kind regards, Midva:*