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