This expands on the Shape Primitives example by adding color. background() fills the canvas with one color, stroke() sets the color for drawing lines, and fill() sets the color for the inside of shapes. noStroke() and noFill() turn off line color and inner color, respectively.
Colors can be represented in many different ways. This example demonstrates several options.
Color by p5.js Contributors and the Processing Foundation is licensed under CC BY-NC-SA 4.0.