Felix/ProcessingWithJavi: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "==Screensaver Code== <nowiki>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(){ backgro...")
 
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Screensaver Code==
==Screensaver Code==
<nowiki>float x = 0.0;
float x = 0.0;
float y = 200.0;
float y = 200.0;
float speed = 1.0;
float speed = 1.0;
float speedY = 1.0;
float speedY = 1.0;
 
void setup(){
void setup(){
  size(800,600);  
  size(800,600);  
  frameRate(300);
  frameRate(300);
}
}
 
void draw(){
void draw(){
   background(255,255,255);
   background(255,255,255);
   fill(255,0,150);
   fill(255,0,150);
Line 22: Line 22:
     speed = speed * -1.0;
     speed = speed * -1.0;
   }
   }
 
 
 
 
     if(y == height-55 || y <= 0)
     if(y == height-55 || y <= 0)
   {
   {
Line 32: Line 30:
   }
   }
    
    
 
}
 
 
==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;


}</nowiki>
while (colourMouseX>255)
{
colourMouseX= colourMouseX/2;
}
 
while (colourMouseX>255)
{
colourMouseY= colourMouseY/2;
}
 
 
 
}

Latest revision as of 17:16, 21 January 2019

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;
}
 
 
 
}