We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › exporting transparent video
Page Index Toggle Pages: 1
exporting transparent video (Read 380 times)
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:*


Re: exporting transparent video
Reply #1 - Jun 25th, 2009, 1:01am
 
I don't see video code in the code above.
And although I am not expert in video formats, I have never heard of a format allowing transparency.
The closest I know is animated Gif and perhaps the elusive MNG format.
If I just miss something, I would be happy to be corrected (and to know!).
Page Index Toggle Pages: 1