@@ -3,18 +3,28 @@ import { Texture } from 'gpu.js';
33import { convertHSLToRGB } from '../../../util/convertHSLToRGB' ;
44
55let hue : number = 0 ;
6- let gradientColors : [ number , number , number ] = [ 1 , 1 , 1 ] ;
6+ let gradientColors : [ number , number , number ] = [ 1 , 1 , 1 ] ;
77
88export const name = 'rainbow_brush' ;
99
10+ export interface RainbowBrushSettings {
11+ brushSize : number ,
12+ changeSpeed : number
13+ }
14+
15+ export const RainbowBrushDefaults : RainbowBrushSettings = {
16+ brushSize : 1 ,
17+ changeSpeed : 1
18+ }
19+
1020export function _startStroke (
1121 this : RealDrawBoard ,
1222 coords : [ number , number ] ,
1323 identifier : string
1424) {
1525 gradientColors = convertHSLToRGB ( hue , 90 , 40 ) ;
1626 this . _doPreview = false ;
17- this . _plot ( coords [ 0 ] , coords [ 1 ] , this . brushSize , gradientColors ) ;
27+ this . _plot ( coords [ 0 ] , coords [ 1 ] , this . toolSettings . brushSize , gradientColors ) ;
1828}
1929
2030export function _endStroke (
@@ -23,7 +33,7 @@ export function _endStroke(
2333 identifier : string
2434) {
2535 gradientColors = convertHSLToRGB ( hue , 90 , 40 ) ;
26- this . _plot ( endCoords [ 0 ] , endCoords [ 1 ] , this . brushSize , gradientColors ) ;
36+ this . _plot ( endCoords [ 0 ] , endCoords [ 1 ] , this . toolSettings . brushSize , gradientColors ) ;
2737 this . _doPreview = true ;
2838}
2939
@@ -32,10 +42,10 @@ export function _doStroke(
3242 coords : [ number , number ] ,
3343 identifier : string
3444) {
35- hue = ( hue + 1 ) % 360 ;
45+ hue = ( hue + this . toolSettings . changeSpeed ) % 360 ;
3646 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 ) ;
47+ this . _plot ( coords [ 0 ] , coords [ 1 ] , this . toolSettings . brushSize , gradientColors ) ;
48+ this . _stroke ( coords [ 0 ] , coords [ 1 ] , this . toolSettings . brushSize , gradientColors , identifier ) ;
3949}
4050
4151export function _toolPreview (
@@ -47,7 +57,7 @@ export function _toolPreview(
4757 this . graphPixels ,
4858 coords [ 0 ] ,
4959 coords [ 1 ] ,
50- this . brushSize ,
60+ this . toolSettings . brushSize ,
5161 gradientColors
5262 )
5363}
0 commit comments