We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Coders!
I am trying to make my program draw lines, that become just a little bit thicker each step. But: The sketch does not react to my decimal numbers. I want to have a gradient in the strokeWeight of my lines. Is this possible?
void setup () {
size(540, 540);
background(0);
fill(255;
}
void draw() {
background(0);
noStroke();
for (float i = 0; i < a; i++) {
rect(width-i*10,0,i/20,height);
}
}
Answers
Your code does not compile. You're missing a parenthesis, and you haven't defined
a
. Please post the code you're actually running, preferably as an MCVE.It's very unusual to choose a non-whole datatype as the iterator counter.
Unless you've got a good motive for it, just stick w/ regular
int
. 8-|Hi guys, thanks! I've fixed it by changing some numbers
I was wondering how I would do it and I came up with this:
It is not fixed the lines get thicker every sixth line rather than each line.
Change the rect statement to
rect(width-i*10, 0, 1+i/6.0, height);
The difference between
i/6
andi/6.0
isPerfect! Thank you guys!!!