[−][src]Static p5_sys::global::spotLight
pub static spotLight: SpotLightInternalType
Creates a spotlight with a given color, position, direction of light, angle and concentration. Here, angle refers to the opening or aperture of the cone of the spotlight, and concentration is used to focus the light towards the center. Both angle and concentration are optional, but if you want to provide concentration, you will also have to specify the angle.
A maximum of 5 spotLight can be active at one time
Examples
function setup() { createCanvas(100, 100, WEBGL); } function draw() { background(0); //move your mouse to change light position let locX = mouseX - width / 2; let locY = mouseY - height / 2; // to set the light position, // think of the world's coordinate as: // -width/2,-height/2 -------- width/2,-height/2 // | | // | 0,0 | // | | // -width/2,height/2--------width/2,height/2 ambientLight(50); spotLight(0, 250, 0, locX, locY, 100, 0, 0, -1, Math.PI / 16); noStroke(); sphere(40); }
Overloads
v1
red or hue value (depending on the current
color mode),
v2
green or saturation value
v3
blue or brightness value
x
x axis position
y
y axis position
z
z axis position
rx
x axis direction of light
ry
y axis direction of light
rz
z axis direction of light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
color
color Array, CSS color string,
or p5.Color value
position
the position of the light
direction
the direction of the light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
v1
red or hue value (depending on the current
color mode),
v2
green or saturation value
v3
blue or brightness value
position
the position of the light
direction
the direction of the light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
color
color Array, CSS color string,
or p5.Color value
x
x axis position
y
y axis position
z
z axis position
direction
the direction of the light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
color
color Array, CSS color string,
or p5.Color value
position
the position of the light
rx
x axis direction of light
ry
y axis direction of light
rz
z axis direction of light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
v1
red or hue value (depending on the current
color mode),
v2
green or saturation value
v3
blue or brightness value
x
x axis position
y
y axis position
z
z axis position
direction
the direction of the light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
v1
red or hue value (depending on the current
color mode),
v2
green or saturation value
v3
blue or brightness value
position
the position of the light
rx
x axis direction of light
ry
y axis direction of light
rz
z axis direction of light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100
color
color Array, CSS color string,
or p5.Color value
x
x axis position
y
y axis position
z
z axis position
rx
x axis direction of light
ry
y axis direction of light
rz
z axis direction of light
angle?
optional parameter for angle. Defaults to PI/3
conc?
optional parameter for concentration. Defaults to 100