Adding Color
Learn how to use fill, stroke, noFill, and noStroke to style your shapes with beautiful colors.
Every shape has two parts: the fill (the inside color) and the stroke (the outline). By default, shapes are filled white with a black outline. Use fill() to change the fill color and stroke() to change the outline color. These stay set until you change them again!
Try it!Try changing strokeWeight(3) to strokeWeight(10) — how does the outline change?
Sometimes you want shapes with no fill — just the outline. Call noFill() to turn off the fill. You can also use noStroke() to turn off the outline. And strokeWeight() controls how thick the outline is.
Colors carry forward until you change them. So you can set a fill once and draw multiple shapes with it, or change the fill before each shape for a rainbow effect. Let's make a colorful pattern!
Here's a handy shortcut: instead of a color name, you can pass a number from 0 to 255. 0 is black, 255 is white, and everything in between is a shade of gray. This is great for quick sketching!
What to try next
- Try using CSS color names you've never seen before — "coral", "orchid", "chartreuse", "teal"
- Make a bullseye target using circles with alternating red and white fills
- Create a gradient by drawing many thin rectangles with slightly different gray values
- Draw a rainbow using colored arcs (overlapping circles with noFill and thick strokeWeight)