Felix/ProcessingWithJavi

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search

Screensaver Code

float x = 0.0;
float y = 200.0;
float speed = 1.0;
float speedY = 1.0;

void setup(){
size(800,600); 
frameRate(300);
}

void draw(){
  background(255,255,255);
  fill(255,0,150);
  noStroke();
  rect(x,y,55,55);
  x = x + speed;
  y=y+speedY;
  
  if(x == width-55 || x <= 0)
  {
    speed = speed * -1.0;
  }
 
   if(y == height-55 || y <= 0)
  {
  
    speedY = speedY * -1.0;
  
  }
  

}


Drawing code

boolean drawing = false;
int mouseCount = 0;
int colourMouseX=0;
int colourMouseY=0;


void setup(){

 size(800,800);
 smooth();
}
void draw(){
 //background(mouseX,mouseY,mouseX);
 fill(mouseCount,80,20);
noStroke();
 
 if(drawing == true)
{
ellipse(mouseX, mouseY, 30, 30);
}

else{
}

colourMouseRefresh();

}

void mouseReleased() {
 println("Mouse released!");
 drawing = !drawing;
 println(drawing);
 mouseCount ++;
 if(mouseCount>255)
 {
   mouseCount=1;
 }
 else{
 
 }


}


void keyReleased() {
if(key == 's'){
     saveFrame();
 
}

if(key == 'c')
{
background(colourMouseX,colourMouseY,colourMouseX);
}


}

void colourMouseRefresh()
{
colourMouseX=mouseX;
colourMouseY=mouseY; 
while (colourMouseX>255)

{
colourMouseX= colourMouseX/2;
}
 

while (colourMouseX>255) 

{
colourMouseY= colourMouseY/2;
}
 
 
 
}