MCPcopy Create free account
hub / github.com/devforth/painterro / getPaletteColorAtPoint

Method getPaletteColorAtPoint

js/colorPicker.js:125–136  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

123 }
124
125 getPaletteColorAtPoint(e) {
126 let x = e.clientX - this.canvas.documentOffsetLeft;
127 let y = e.clientY - this.canvas.documentOffsetTop;
128 x = (x < 1 && 1) || x;
129 y = (y < 1 && 1) || y;
130 x = (x > this.w && this.w - 1) || x;
131 y = (y > this.h && this.h - 1) || y;
132 const p = this.ctx.getImageData(x, y, 1, 1).data;
133 this.palleteColor = rgbToHex(p[0], p[1], p[2]);
134 this.drawLighter();
135 this.regetColor();
136 }
137
138 regetColor() {
139 const p = this.ctxLight.getImageData(this.lightPosition, 5, 1, 1).data;

Callers 2

handleMouseDownMethod · 0.95
handleMouseMoveMethod · 0.95

Calls 3

drawLighterMethod · 0.95
regetColorMethod · 0.95
rgbToHexFunction · 0.85

Tested by

no test coverage detected