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 › I cant run some of the animations. why :(
Page Index Toggle Pages: 1
I cant run some of the animations. why ? :( (Read 363 times)
I cant run some of the animations. why ? :(
Dec 13th, 2007, 10:01am
 

for example http://www.harukit.com/process/sp/applet/index.html this animation is running on my web browser but processing cant run.

is it about java plugin???

processing version is 0134

source code is :

// Shining Particle by harukit
// Created with Processing 68 alpha on September 11 , 2004
// http://www.harukit.com


int pNum =4;
Particle[] p = new Particle[pNum];
float rr,gg,bb,dis;
int gain = 5;
float[] cc = new float[3];

void setup(){
 size(200,200);
 noStroke();
 background(0);
 for(int i=0;i<3;i++){
   cc[i]=random(40)+random(40)+random(40)+random(40)+random(40);
 }
 for(int i=0;i<pNum;i++){
   p[i] = new Particle(random(width),random(height),random(0.1,0.3));
 }
}

void loop(){
 for(int i=0;i<pNum;i++){
   p[i].update();
 }
 for(int y=0;y<height;y++){
   for(int x=0;x<width;x++){
       int pos=y*width+x;
       color col = pixels[pos];
       rr = col >> 16 & 0xff;
       gg = col >> 8 & 0xff;
       bb = col  & 0xff;
       for(int i=0;i<pNum;i++){
         dis =dist(p[i].xpos,p[i].ypos,x,y)/2;
         rr += cc[0]/dis-gain;
         gg += cc[1]/dis-gain;
         bb += cc[2]/dis-gain;
       }
       pixels[pos]=color(rr,gg,bb);
   }
 }
}

void mousePressed(){
 background(0);
 Particle[] p = new Particle[pNum];
}

void mouseReleased(){
 for(int i=0;i<3;i++){
   cc[i]=random(40)+random(40)+random(40)+random(40)+random(40);
 }
 background(0);
 for(int i=0;i<pNum;i++){
   p[i] = new Particle(random(width),random(height),random(0.1,0.3));
 }
}

class Particle{
 float xpos,ypos,del;
 Particle(float x,float y,float d){
   xpos=x;
   ypos=y;
   del = d;
 }
 void update(){
   xpos += (mouseX-xpos)*del;
   ypos += (mouseY-ypos)*del;
 }
}
Re: I cant run some of the animations. why ? :(
Reply #1 - Dec 13th, 2007, 10:26am
 
replace
void loop() with void draw()
add loadPixels(); as first function call in draw() since you are manipulating pixels.
at the end of the draw() function, put updatePixels();


since the sketch is done in processing 68, alpha version, you can read about the changes in the revisions.txt , search for "things that break your code".
best,
andi
Re: I cant run some of the animations. why ? :(
Reply #2 - Dec 13th, 2007, 11:03am
 
thank u so much Cheesy
Page Index Toggle Pages: 1