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

Method setAlpha

src/color/p5.Color.js:708–718  ·  view source on GitHub ↗

* Sets the alpha (transparency) value of a color. * * The range depends on the * colorMode() . In the default RGB mode it's * between 0 and 255. * * @param {Number} alpha the new alpha value. * * @example * function setup() { * createCanvas

(new_alpha, max=[0, 1])

Source from the content-addressed store, hash-verified

706 * }
707 */
708 setAlpha(new_alpha, max=[0, 1]) {
709 this._defaultStringValue = undefined;
710 if(!Array.isArray(max)){
711 max = [0, max];
712 }
713
714 const colorjsMax = Color.#colorjsMaxes[this.mode][3];
715 const newval = map(new_alpha, max[0], max[1], colorjsMax[0], colorjsMax[1]);
716
717 this._color.alpha = newval;
718 }
719
720 _getRGBA(maxes=[1, 1, 1, 1]) {
721 // Get colorjs maxes

Callers 3

setting.jsFile · 0.45
p5.Color.jsFile · 0.45
p5.RendererGL.jsFile · 0.45

Calls 1

mapFunction · 0.85

Tested by

no test coverage detected