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

From CDOT Wiki
Jump to: navigation, search
Line 3: Line 3:
 
/*
 
/*
 
   FSOSS 2010
 
   FSOSS 2010
 +
  Andor Salga
 
   Example of strokeWeight() & stroke()
 
   Example of strokeWeight() & stroke()
 
*/
 
*/
Line 39: Line 40:
 
}
 
}
 
</source>
 
</source>
Run me
+
[http://studio.sketchpad.cc/p7edjcRbb4 Run me]

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..20
  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