Sets the color used to draw points, lines, and the outlines of shapes.
Calling stroke(255, 165, 0)
or stroke('orange')
means all shapes drawn after calling stroke()
will be filled with the color orange. The way these parameters are interpreted may be changed with the colorMode() function.
The version of stroke()
with one parameter interprets the value one of three ways. If the parameter is a Number
, it's interpreted as a grayscale value. If the parameter is a String
, it's interpreted as a CSS color string. A p5.Color object can also be provided to set the stroke color.
The version of stroke()
with two parameters interprets the first one as a grayscale value. The second parameter sets the alpha (transparency) value.
The version of stroke()
with three parameters interprets them as RGB, HSB, or HSL colors, depending on the current colorMode()
.
The version of stroke()
with four parameters interprets them as RGBA, HSBA, or HSLA colors, depending on the current colorMode()
. The last parameter sets the alpha (transparency) value.
Examples
Syntax
stroke(v1, v2, v3, [alpha])
stroke(value)
stroke(gray, [alpha])
stroke(values)
stroke(color)
Parameters
red value if color mode is RGB or hue value if color mode is HSB.
green value if color mode is RGB or saturation value if color mode is HSB.
blue value if color mode is RGB or brightness value if color mode is HSB.
a color string.
a grayscale value.
an array containing the red, green, blue, and alpha components of the color.
the stroke color.