Difference between revisions of "FSOSS 2010/processing.js/example4"

From CDOT Wiki
Jump to: navigation, search
 
Line 19: Line 19:
 
   
 
   
 
   // normalize 0..500 then multiply by scalar
 
   // normalize 0..500 then multiply by scalar
   // from 0..20
+
   // from 0..10
 
   strokeWeight( (mouseY /(float)height * 10 ));
 
   strokeWeight( (mouseY /(float)height * 10 ));
 
   
 
   

Latest revision as of 06:53, 28 October 2010

/*
  FSOSS 2010
  Andor Salga
  Example of strokeWeight() & stroke()
*/

void setup(){
  size(500, 500);
 
  // set the circle's fill same as
  // the background color
  fill(#336699);
}

void draw(){
  background(#336699);
 
  // normalize 0..500 then multiply by scalar
  // from 0..10
  strokeWeight( (mouseY /(float)height * 10 ));
 
  // lines, points, rectangle strokes and
  // ellipse stroke colos are set with stroke()
  // Set the stroke color to black
  stroke(0);
  line(0, 0, mouseX, mouseY);
  line(0, height, mouseX, mouseY);
  line(width, 0, mouseX, mouseY);
  line(width, height, mouseX, mouseY);
 
  // change the stroke color from black
  // normalize 0..500 to 0..1 then multiply by scalar
  // from 0..255
  stroke( mouseX/(float)width * 255, 0, 0);
 
  // draw a circle at the user's cursor
  ellipse(mouseX, mouseY, 40, 40);
}

Run me