Skip to content

Commit 0459ce9

Browse files
committed
maintained the consistency of code
1 parent 1c82c5c commit 0459ce9

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ See [example](https://harshkhandeparkar.github.io/gpujs-real-renderer).
229229
- `brushColor` (*array*): The color of the brush in the corm `[red, green, blue]` where each of
230230
`red`, `green` and `blue` are between 0 and 1.
231231
- `eraserSize` (*number*): Size of the eraser.
232-
- `tool` ('brush' | 'eraser' | 'line'): The current tool used on the board. This tool can be set in the options or using the `changeTool` method.
232+
- `tool` ('brush' | 'gradient_brush' | 'eraser' | 'line'): The current tool used on the board. This tool can be set in the options or using the `changeTool` method.
233233
234234
##### Options
235235
Since this is a child class of `RealRenderer`, all the options of `RealRender` are applicable here as well.

src/renderers/RealDrawBoard/tools/gradient_brush.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Texture } from 'gpu.js';
33
import { convertHSLToRGB } from '../../../util/convertHSLToRGB';
44

55
let hue: number = 0;
6-
let gradientColors: [number ,number ,number] = [ 1 ,1 ,1 ];
6+
let gradientColors: [number, number, number] = [1, 1, 1];
77

88
export const name = 'gradient_brush';
99

@@ -12,7 +12,7 @@ export function _startStroke(
1212
coords: [number, number],
1313
identifier: string
1414
) {
15-
gradientColors = convertHSLToRGB(hue,90,40);
15+
gradientColors = convertHSLToRGB(hue, 90, 40);
1616
this._doPreview = false;
1717
this._plot(coords[0], coords[1], this.brushSize, gradientColors);
1818
}
@@ -22,7 +22,7 @@ export function _endStroke(
2222
endCoords: [number, number],
2323
identifier: string
2424
) {
25-
gradientColors = convertHSLToRGB(hue,90,40);
25+
gradientColors = convertHSLToRGB(hue, 90, 40);
2626
this._plot(endCoords[0], endCoords[1], this.brushSize, gradientColors);
2727
this._doPreview = true;
2828
}
@@ -32,8 +32,8 @@ export function _doStroke(
3232
coords: [number, number],
3333
identifier: string
3434
) {
35-
hue = (hue+1)%360;
36-
gradientColors = convertHSLToRGB(hue,90,40);
35+
hue = (hue + 1) % 360;
36+
gradientColors = convertHSLToRGB(hue, 90, 40);
3737
this._plot(coords[0], coords[1], this.brushSize, gradientColors);
3838
this._stroke(coords[0], coords[1], this.brushSize, gradientColors, identifier);
3939
}

src/util/convertHSLToRGB.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param l brightness level.
66
* @returns array containing r g and b value
77
*/
8-
export function convertHSLToRGB(h: number, s: number, l: number) :[ number ,number ,number ] {
8+
export function convertHSLToRGB(h: number, s: number, l: number): [number, number, number] {
99

1010
s /= 100;
1111
l /= 100;
@@ -19,21 +19,26 @@ export function convertHSLToRGB(h: number, s: number, l: number) :[ number ,numb
1919

2020
if (0 <= h && h < 60) {
2121
r = c; g = x; b = 0;
22-
} else if (60 <= h && h < 120) {
22+
}
23+
else if (60 <= h && h < 120) {
2324
r = x; g = c; b = 0;
24-
} else if (120 <= h && h < 180) {
25+
}
26+
else if (120 <= h && h < 180) {
2527
r = 0; g = c; b = x;
26-
} else if (180 <= h && h < 240) {
28+
}
29+
else if (180 <= h && h < 240) {
2730
r = 0; g = x; b = c;
28-
} else if (240 <= h && h < 300) {
31+
}
32+
else if (240 <= h && h < 300) {
2933
r = x; g = 0; b = c;
30-
} else if (300 <= h && h < 360) {
34+
}
35+
else if (300 <= h && h < 360) {
3136
r = c; g = 0; b = x;
3237
}
3338

34-
r = Math.round((r + m));
35-
g = Math.round((g + m));
36-
b = Math.round((b + m));
39+
r = Math.round(r + m);
40+
g = Math.round(g + m);
41+
b = Math.round(b + m);
3742

38-
return [ r ,g ,b ];
43+
return [r, g, b];
3944
}

0 commit comments

Comments
 (0)