* 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])
| 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 |
no test coverage detected