We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › strokeWeight() question
Page Index Toggle Pages: 1
strokeWeight() question (Read 1424 times)
strokeWeight() question
Oct 14th, 2009, 12:10pm
 
When I use strokeWeight() to set the width of the stroke it seems one of the things strokeWeight does it sets the border of my canvas to that stroke weight as well. Is there any way to increase the width of the stroke without also effecting the border?

I can't post live links (to show what I am talking about) till I have made 5 posts, it seems
Re: strokeWeight() question
Reply #1 - Oct 14th, 2009, 1:45pm
 
How are you doing your canvas? Usually, it is drawn with background(), which should have no border.
Beside, you can set strokeWidth() several times, before each drawing call if needed (if must change).
Re: strokeWeight() question
Reply #2 - Oct 14th, 2009, 2:07pm
 
I do use background but it has a border because of strokeWeight. Here is my code.

void setup() {
 size(400,400);
 background(0);
 smooth();
}

void draw() {
 fill(0,10);
 rectMode(CORNER);
 rect(0,0,width,height);
 strokeWeight(10);
 stroke(255);
 line(pmouseX,pmouseY,mouseX,mouseY);
}


I think I see what you are saying. So I added another strokeWeight before filling my canvas to fade to black like so

void setup() {
 size(400,400);
 background(0);
 smooth();
}

void draw() {
strokeWeight(0);
 fill(0,10);
 rectMode(CORNER);
 rect(0,0,width,height);
 strokeWeight(10);
 stroke(255);
 line(pmouseX,pmouseY,mouseX,mouseY);
}

thanks for the tip, I should've thought of using strokeWeight multiple times.
Re: strokeWeight() question
Reply #3 - Oct 15th, 2009, 1:21am
 
or better still:

Code:
void draw() {
noStroke();
fill(0,10);
// the default is CORNER so no need for this unless you specifically use another mode elsewhere
//rectMode(CORNER);
rect(0,0,width,height);
strokeWeight(10);
stroke(255);
line(pmouseX,pmouseY,mouseX,mouseY);
}
Re: strokeWeight() question
Reply #4 - Oct 15th, 2009, 2:45am
 
Ah, I was thinking more of:
Code:
void draw() {
background(0,10);
strokeWeight(10);
stroke(255);
line(pmouseX,pmouseY,mouseX,mouseY);
}
because that's the common idiom, but indeed it doesn't do the same effect... Smiley
Because "It is not possible to use transparency (alpha) in background colors with the main drawing surface"...
Page Index Toggle Pages: 1