FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Sound
(Moderators: pitaru, REAS)
   Sonia and browser's applet
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Sonia and browser's applet  (Read 2201 times)
stilomatic

WWW
Sonia and browser's applet
« on: Jan 23rd, 2005, 1:24pm »

i'm working on this code, plaid locally works fine,but in the browser fail and report: java.lang.ClassNotFoundException:grid (grid is the name of the application)
what i have to do? I suppose that i should include the jSyn lib but how to?
i got the jSyn plug in installed im running macOsX and i got java for my browser...
 
thanx in advance  
 
int scacchi=8;
int timer,c,d;
int outputLen = 1024;
float amp,freq;
boolean anim;
color currentcolor;
boolean locked = false;
RectButton[][] myButtons = new RectButton[scacchi][scacchi];
 
static public void main(String args[]) {
   BApplet.main(new String[] { "dancing_Grid" });
}
 
 
class RectButton
{
  int x, y;
  int size;
  color basecolor;
  color highlightcolor;
  color currentcolor;
  boolean over = false;
  boolean locked = false;    
  boolean pressed;
 
 
  RectButton(int _x, int _y, int _size, color _basecolor, color _highlightcolor)  
  {
    x = _x;
    y = _y;
    size = _size;
    basecolor = _basecolor;
    highlightcolor = _highlightcolor;
    currentcolor = basecolor;
  }
   
  boolean over()  
  {
    if(overRect(x*size, y*size, size, size) ) {
 over = true;
 return true;
    } else {
 over = false;
 return false;
    }
  }
    void update()  
  {
     if(over() == true && locked == false || over() == false && locked == true) {
   currentcolor = highlightcolor;
 }else if(over() == false && locked == false){
   currentcolor = basecolor;
     }
 }
 
  boolean pressed()  
  {
    if(over) {
 if(locked==false){
    locked=true;
 }else  if(locked == true){
   locked=false;
 }
 pressed = true;
 return true;
 
   }else{
   pressed = false;
   return false;
     }  
  }
  void display()  
  {
    stroke(0);
    fill(currentcolor);
    rect(x*size, y*size, size, size);
  }
}
 
boolean overRect(int x, int y, int width, int height)  
{
  if (mouseX >= x && mouseX <= x+width &&  
 mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}
void update(int x, int y)
{
   for (int j=0; j < scacchi; j++){
    for (int i=0; i < scacchi; i++){
     myButtons[i][j].update();
     if( mousePressed ) {
 myButtons[i][j].pressed();  
  }
 }
 }
 
   
 
}
 
void animation(){
 
   LiveOutput.stopStream();  
   if(c>7){
    c=0;
  }
  for(int z=0;z<scacchi;z++){
  if(  myButtons[c][z].currentcolor != myButtons[c][z].highlightcolor){
   myButtons[c][z].currentcolor = myButtons[c][z].highlightcolor;
   myButtons[d][z].currentcolor = myButtons[d][z].basecolor;
    }
    if( myButtons[d][z].locked ){
     
  freq = float(z+1);
  amp = float(c+1);  
  LiveOutput.startStream();
     
    }
  }
   
  d=c;
  c++;
  //--------------------  
}
 
void liveOutputEvent(){
   
    float oneCycle = (TWO_PI) / outputLen;
    for (int i=0; i < outputLen; i++) {
 LiveOutput.data[i] = amp* sin(float(i*oneCycle*freq));
    }
}
 
public void stop(){
 
  Sonia.stop();
  super.stop();
   
}
 
void setup(){
 
  currentcolor=color(255,255,255);
  size(400,400);
  int dim = (width)/scacchi;
  print(dim);
   
  for (int y=0; y < scacchi; y++){
    for (int x=0; x < scacchi; x++){
 myButtons[x][y] = new RectButton(x, y, dim, color(100,100,100),color(160,160,160));
    }
  }
   
  Sonia.start(this);
  LiveOutput.start(outputLen,outputLen*2);
}
 
 
void loop(){
 
  update(mouseX, mouseY);
  timer++;
   
  if(timer>15){
  animation();
  timer=0;
    }
   for (int y=0; y < scacchi; y++){
    for (int x=0; x < scacchi; x++){
 myButtons[x][y].display();
    }
  }
 
 }
« Last Edit: Jan 23rd, 2005, 3:56pm by stilomatic »  

Best Regards Stilomatic
------------------------------
stilomatic

WWW
Re: Sonia and browser's applet
« Reply #1 on: Jan 23rd, 2005, 4:29pm »

i've re-installed jSyn
and now it works  
 
http://www.stilomatic.net/lab/p.01
 

Best Regards Stilomatic
------------------------------
Pages: 1 

« Previous topic | Next topic »