Skip to content

Commit e889db9

Browse files
author
HarshKhandeparkar
committed
feat<demo>: per tool settings
1 parent f075c26 commit e889db9

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

example/examples/drawboard.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ const drawBoardOptions = {
1515
xOffset: 10, // 100%
1616
yOffset: 0, // 100%
1717

18-
brushSize: 5, // The radius of one point of data, in coordinate units
19-
brushColor: [1, 1, 1], // Color of the brush
18+
toolSettings: {
19+
brushSize: 5, // The radius of one point of data, in coordinate units
20+
brushColor: [1, 1, 1], // Color of the brush
21+
lineColor: [1, 1, 1], // Color of the line
22+
lineSize: 5,
23+
changeSpeed: 2,
24+
eraserSize: 5
25+
},
26+
2027
allowUndo: true
2128
}
2229

@@ -30,7 +37,16 @@ const colorWheel = new iro.ColorPicker("#drawboard-colorwheel", {
3037
})
3138

3239
colorWheel.on('input:change', color => {
33-
DrawBoard.changeBrushColor([
40+
DrawBoard.changeToolSetting(
41+
'lineColor',
42+
[
43+
color.red / 255,
44+
color.green / 255,
45+
color.blue / 255
46+
])
47+
DrawBoard.changeToolSetting(
48+
'brushColor',
49+
[
3450
color.red / 255,
3551
color.green / 255,
3652
color.blue / 255
@@ -46,13 +62,14 @@ toolSelector.addEventListener('change', e => {
4662
const brushSizeRange = document.querySelector('#brush-size');
4763
brushSizeRange.addEventListener('input', e => {
4864
e.preventDefault();
49-
DrawBoard.changeBrushSize(Number(brushSizeRange.value))
65+
DrawBoard.changeToolSetting('brushSize', Number(brushSizeRange.value));
66+
DrawBoard.changeToolSetting('lineSize', Number(brushSizeRange.value));
5067
})
5168

5269
const eraserSizeRange = document.querySelector('#eraser-size');
5370
eraserSizeRange.addEventListener('input', e => {
5471
e.preventDefault();
55-
DrawBoard.changeEraserSize(Number(eraserSizeRange.value))
72+
DrawBoard.changeToolSetting('eraserSize', Number(eraserSizeRange.value))
5673
})
5774

5875
document.querySelector('#draw-undo').addEventListener('click', e => {

0 commit comments

Comments
 (0)