MCPcopy Index your code
hub / github.com/processing/p5.js / light

Function light

src/webgl/light.js:11–1765  ·  view source on GitHub ↗
(p5, fn)

Source from the content-addressed store, hash-verified

9import { Color } from '../color/p5.Color';
10
11function light(p5, fn){
12 /**
13 * Creates a light that shines from all directions.
14 *
15 * Ambient light does not come from one direction. Instead, 3D shapes are
16 * lit evenly from all sides. Ambient lights are almost always used in
17 * combination with other types of lights.
18 *
19 * There are three ways to call `ambientLight()` with optional parameters to
20 * set the light’s color.
21 *
22 * The first way to call `ambientLight()` has two parameters, `gray` and
23 * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
24 * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
25 * `ambientLight(50, 30)`.
26 *
27 * The second way to call `ambientLight()` has one parameter, color. A
28 * <a href="#/p5.Color">p5.Color</a> object, an array of color values, or a
29 * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
30 * ambient light’s color.
31 *
32 * The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
33 * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
34 * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
35 * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
36 * the current <a href="#/p5/colorMode">colorMode()</a>.
37 *
38 * @method ambientLight
39 * @param {Number} v1 red or hue value in the current
40 * <a href="#/p5/colorMode">colorMode()</a>.
41 * @param {Number} v2 green or saturation value in the current
42 * <a href="#/p5/colorMode">colorMode()</a>.
43 * @param {Number} v3 blue, brightness, or lightness value in the current
44 * <a href="#/p5/colorMode">colorMode()</a>.
45 * @param {Number} [alpha] alpha (transparency) value in the current
46 * <a href="#/p5/colorMode">colorMode()</a>.
47 * @chainable
48 *
49 * @example
50 * // Click and drag the mouse to view the scene from different angles.
51 * // Double-click the canvas to turn on the light.
52 *
53 * let isLit = false;
54 *
55 * function setup() {
56 * createCanvas(100, 100, WEBGL);
57 *
58 * describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.');
59 * }
60 *
61 * function draw() {
62 * background(200);
63 *
64 * // Enable orbiting with the mouse.
65 * orbitControl();
66 *
67 * // Control the light.
68 * if (isLit === true) {

Callers 2

graphicsFunction · 0.85
light.jsFile · 0.85

Calls 9

_assert3dMethod · 0.80
_getSphereMappingMethod · 0.80
makeDiffusedTextureMethod · 0.80
makeSpecularTextureMethod · 0.80
filterMethod · 0.45
setValueMethod · 0.45
pushMethod · 0.45
applyMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected