/*
FSOSS 2010
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