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

From CDOT Wiki
Jump to: navigation, search
(Created page with '<source lang="JavaScript"> FSOSS 2010 Example of strokeWeight() & stroke(): void setup(){ size(500, 500); // set the circle's fill same as // the background col…')
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[category: FSOSS 2010 PJS Examples]]
 
<source lang="JavaScript">
 
<source lang="JavaScript">
 
/*
 
/*
 
   FSOSS 2010
 
   FSOSS 2010
 +
  Andor Salga
 
   Example of strokeWeight() & stroke()
 
   Example of strokeWeight() & stroke()
 
*/
 
*/
Line 17: 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 ));
 
   
 
   
Line 38: Line 40:
 
}
 
}
 
</source>
 
</source>
Run me
+
[http://studio.sketchpad.cc/p7edjcRbb4 Run me]

Latest revision as of 07: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