1/** 2 * Relative luminance 3 */ 4import get from "./get.js"; 5import set from "./set.js"; 6import xyz_d65 from "./spaces/xyz-d65.js"; 7 8/** @import { ColorTypes } from "./types.js" */ 9 10/** 11 * 12 * @param {ColorTypes} color 13 * @returns {number} 14 */ 15export function getLuminance (color) { 16 // Assume getColor() is called on color in get() 17 return get(color, [xyz_d65, "y"]); 18} 19 20/** 21 * @param {ColorTypes} color 22 * @param {number | ((coord: number) => number)} value 23 */ 24export function setLuminance (color, value) { 25 // Assume getColor() is called on color in set() 26 set(color, [xyz_d65, "y"], value); 27} 28 29/** 30 * @param {typeof import("./color.js").default} Color 31 */ 32export function register (Color) { 33 Object.defineProperty(Color.prototype, "luminance", { 34 get () { 35 return getLuminance(this); 36 }, 37 set (value) { 38 setLuminance(this, value); 39 }, 40 }); 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.