MCPcopy
hub / github.com/KilledByAPixel/LittleJS / toString

Method toString

src/engineMath.js:1048–1054  ·  view source on GitHub ↗

Returns this color expressed as a hex color code * @param {boolean} [useAlpha] - if alpha should be included in result * @return {string}

(useAlpha = true)

Source from the content-addressed store, hash-verified

1046 * @param {boolean} [useAlpha] - if alpha should be included in result
1047 * @return {string} */
1048 toString(useAlpha = true)
1049 {
1050 if (debug && !this.isValid())
1051 return '#000';
1052 const toHex = (c)=> ((c=clamp(c)*255|0)<16 ? '0' : '') + c.toString(16);
1053 return '#' + toHex(this.r) + toHex(this.g) + toHex(this.b) + (useAlpha ? toHex(this.a) : '');
1054 }
1055
1056 /** Set this color from a hex code
1057 * @param {string} hex - html hex code

Callers 15

math.test.mjsFile · 0.45
debugRectFunction · 0.45
debugPolyFunction · 0.45
debugCircleFunction · 0.45
debugTextFunction · 0.45
debugRenderFunction · 0.45
drawEngineLogoFunction · 0.45
updateCanvasFunction · 0.45
drawTileFunction · 0.45
drawRectGradientFunction · 0.45
drawLineListFunction · 0.45
drawPolyFunction · 0.45

Calls 1

isValidMethod · 0.95

Tested by

no test coverage detected