|
| 1 | +import { RealDrawBoard } from '../RealDrawBoard'; |
| 2 | +import { Texture } from 'gpu.js'; |
| 3 | +import { convertHSLToRGB } from '../../../util/convertHSLToRGB'; |
| 4 | + |
| 5 | +let hue: number = 0; |
| 6 | +let gradientColors: [number, number, number] = [1, 1, 1]; |
| 7 | + |
| 8 | +export const name = 'rainbow_brush'; |
| 9 | + |
| 10 | +export function _startStroke( |
| 11 | + this: RealDrawBoard, |
| 12 | + coords: [number, number], |
| 13 | + identifier: string |
| 14 | +) { |
| 15 | + gradientColors = convertHSLToRGB(hue, 90, 40); |
| 16 | + this._doPreview = false; |
| 17 | + this._plot(coords[0], coords[1], this.brushSize, gradientColors); |
| 18 | +} |
| 19 | + |
| 20 | +export function _endStroke( |
| 21 | + this: RealDrawBoard, |
| 22 | + endCoords: [number, number], |
| 23 | + identifier: string |
| 24 | +) { |
| 25 | + gradientColors = convertHSLToRGB(hue, 90, 40); |
| 26 | + this._plot(endCoords[0], endCoords[1], this.brushSize, gradientColors); |
| 27 | + this._doPreview = true; |
| 28 | +} |
| 29 | + |
| 30 | +export function _doStroke( |
| 31 | + this: RealDrawBoard, |
| 32 | + coords: [number, number], |
| 33 | + identifier: string |
| 34 | +) { |
| 35 | + hue = (hue + 1) % 360; |
| 36 | + gradientColors = convertHSLToRGB(hue, 90, 40); |
| 37 | + this._plot(coords[0], coords[1], this.brushSize, gradientColors); |
| 38 | + this._stroke(coords[0], coords[1], this.brushSize, gradientColors, identifier); |
| 39 | +} |
| 40 | + |
| 41 | +export function _toolPreview( |
| 42 | + this: RealDrawBoard, |
| 43 | + coords: [number, number], |
| 44 | + identifier: string |
| 45 | +): Texture { |
| 46 | + return <Texture>this._previewPlot( |
| 47 | + this.graphPixels, |
| 48 | + coords[0], |
| 49 | + coords[1], |
| 50 | + this.brushSize, |
| 51 | + gradientColors |
| 52 | + ) |
| 53 | +} |
0 commit comments