Sets the ambient color of shapes’ surface material.
The ambientMaterial()
color sets the components of the ambientLight() color that shapes will reflect. For example, calling ambientMaterial(255, 255, 0)
would cause a shape to reflect red and green light, but not blue light.
ambientMaterial()
can be called three ways with different parameters to set the material’s color.
The first way to call ambientMaterial()
has one parameter, gray
. Grayscale values between 0 and 255, as in ambientMaterial(50)
, can be passed to set the material’s color. Higher grayscale values make shapes appear brighter.
The second way to call ambientMaterial()
has one parameter, color
. A p5.Color object, an array of color values, or a CSS color string, as in ambientMaterial('magenta')
, can be passed to set the material’s color.
The third way to call ambientMaterial()
has three parameters, v1
, v2
, and v3
. RGB, HSB, or HSL values, as in ambientMaterial(255, 0, 0)
, can be passed to set the material’s colors. Color values will be interpreted using the current colorMode().
Note: ambientMaterial()
can only be used in WebGL mode.
Examples
Syntax
ambientMaterial(v1, v2, v3)
ambientMaterial(gray)
ambientMaterial(color)
Parameters
red or hue value in the current colorMode().
green or saturation value in the current colorMode().
blue, brightness, or lightness value in the current colorMode().
grayscale value between 0 (black) and 255 (white).
color as a p5.Color object, an array of color values, or a CSS string.