Reputation: 541
The first box the loop outputs is a white box with a black outline. I don't understand where it's coming from... https://editor.p5js.org/matranson/present/6fNelJM8_
function setup() {
colorMode(HSB,360,100,100);
createCanvas(400, 400);
var boxh = height / 10;
var boxw = width;
for(var i = 0; i < 10; i++) {
var h = lerp(64, 22, i / 9);
var s = lerp(86, 90, i / 9);
var l = lerp(96, 56, i / 9);
rect(0, i * boxh, boxw, boxh);
fill(h,s,l);
stroke(0,0,100);
}
}
function draw() {
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.js"></script>
Upvotes: 1
Views: 88
Reputation: 210909
stroke()
sets the color used to draw lines and borders. fill()
sets the color used to fill shapes. rect()
draws a rectangle.
The stroke and the fill color has to be set before the rectangle is drawn:
fill(h,s,l);
stroke(0,0,100);
rect(0, i * boxh, boxw, boxh);
function setup() {
colorMode(HSB,360,100,100);
createCanvas(400, 400);
var boxh = height / 10;
var boxw = width;
for(var i = 0; i < 10; i++) {
var h = lerp(64, 22, i / 9);
var s = lerp(86, 90, i / 9);
var l = lerp(96, 56, i / 9);
fill(h,s,l);
stroke(0,0,100);
rect(0, i * boxh, boxw, boxh);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.js"></script>
Upvotes: 1