(startX, startY)
| 47 | } |
| 48 | |
| 49 | paintAt(startX, startY) { |
| 50 | startX = Math.round(startX); |
| 51 | startY = Math.round(startY - 1); |
| 52 | startX = (startX > 0) ? startX : 0; |
| 53 | startY = (startY > 0) ? startY : 0; |
| 54 | |
| 55 | // get clicked on color |
| 56 | this.getClickedOnColor(startX, startY); |
| 57 | |
| 58 | var pixelPos = (startY * this.canvasWidth + startX) * 4; |
| 59 | var pixelColor = this.getPixelColor(this.colorLayerData, pixelPos); |
| 60 | var r = pixelColor.r; |
| 61 | var g = pixelColor.g; |
| 62 | var b = pixelColor.b; |
| 63 | var a = pixelColor.a; |
| 64 | |
| 65 | const curColor = HexToRGB( this.main.colorWidgetState.fill.palleteColor ); |
| 66 | this.color = this.main.colorWidgetState.fill.palleteColor; |
| 67 | |
| 68 | if (r === curColor.r && g === curColor.g && b === curColor.b) { |
| 69 | // Return because trying to fill with the same color |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | this.floodFill(startX, startY, r, g, b); |
| 74 | this.ctx.putImageData(this.colorLayerData, 0, 0); |
| 75 | this.main.worklog.captureState(); |
| 76 | } |
| 77 | |
| 78 | // returns true if the current pixel's color matches the clicked on color. |
| 79 | matchStartColor(pixelPos) { |
no test coverage detected