Difference between revisions of "FSOSS 2010/processing.js/example4"
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
/* | /* | ||
FSOSS 2010 | FSOSS 2010 | ||
+ | Andor Salga | ||
Example of strokeWeight() & stroke() | Example of strokeWeight() & stroke() | ||
*/ | */ | ||
Line 18: | Line 19: | ||
// normalize 0..500 then multiply by scalar | // normalize 0..500 then multiply by scalar | ||
− | // from 0.. | + | // from 0..10 |
strokeWeight( (mouseY /(float)height * 10 )); | strokeWeight( (mouseY /(float)height * 10 )); | ||
Line 39: | Line 40: | ||
} | } | ||
</source> | </source> | ||
− | Run me | + | [http://studio.sketchpad.cc/p7edjcRbb4 Run me] |
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);
}