MCPcopy Create free account
hub / github.com/nodejs/node / darken

Method darken

deps/v8/tools/system-analyzer/view/helper.mjs:86–96  ·  view source on GitHub ↗
(hexColorString, amount = -50)

Source from the content-addressed store, hash-verified

84 }
85
86 static darken(hexColorString, amount = -50) {
87 if (hexColorString[0] !== '#') {
88 throw new Error(`Unsupported color: ${hexColorString}`);
89 }
90 let color = parseInt(hexColorString.substring(1), 16);
91 let b = Math.min(Math.max((color & 0xFF) + amount, 0), 0xFF);
92 let g = Math.min(Math.max(((color >> 8) & 0xFF) + amount, 0), 0xFF);
93 let r = Math.min(Math.max(((color >> 16) & 0xFF) + amount, 0), 0xFF);
94 color = (r << 16) + (g << 8) + b;
95 return `#${color.toString(16).padStart(6, '0')}`;
96 }
97
98 static get list() {
99 if (!this._colors) {

Callers 2

listMethod · 0.95
_drawItemMethod · 0.80

Calls 3

minMethod · 0.45
maxMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected