Creates a light that shines from all directions.
Ambient light does not come from one direction. Instead, 3D shapes are lit evenly from all sides. Ambient lights are almost always used in combination with other types of lights.
There are three ways to call ambientLight()
with optional parameters to set the light’s color.
The first way to call ambientLight()
has two parameters, gray
and alpha
. alpha
is optional. Grayscale and alpha values between 0 and 255 can be passed to set the ambient light’s color, as in ambientLight(50)
or ambientLight(50, 30)
.
The second way to call ambientLight()
has one parameter, color. A p5.Color object, an array of color values, or a CSS color string, as in ambientLight('magenta')
, can be passed to set the ambient light’s color.
The third way to call ambientLight()
has four parameters, v1
, v2
, v3
, and alpha
. alpha
is optional. RGBA, HSBA, or HSLA values can be passed to set the ambient light’s colors, as in ambientLight(255, 0, 0)
or ambientLight(255, 0, 0, 30)
. Color values will be interpreted using the current colorMode().
Examples
Syntax
ambientLight(v1, v2, v3, [alpha])
ambientLight(gray, [alpha])
ambientLight(value)
ambientLight(values)
ambientLight(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().
alpha (transparency) value in the current colorMode().
grayscale value between 0 and 255.
color as a CSS string.
color as an array of RGBA, HSBA, or HSLA values.
color as a p5.Color object.