@@ -7,14 +7,14 @@ import {
7
7
} from 'croquis.js/lib/brush/simple' ;
8
8
import {
9
9
getStroke as getPulledStringStroke ,
10
- defaultPulledStringConfig ,
11
10
PulledStringDrawingContext ,
12
11
} from 'croquis.js/lib/stabilizer/pulled-string' ;
13
12
import type { StrokeDrawingContext } from 'croquis.js/lib/stroke-protocol' ;
14
13
import { getStylusState , createStylusState } from 'croquis.js/lib/stylus' ;
15
14
import PulledStringGuide from '../../components/guide/stabilizer/PulledStringGuide' ;
16
15
import Draw from '../../components/example/Draw' ;
17
16
import GithubCorner from '../../components/GithubCorner' ;
17
+ import DataController from '../../components/DataController' ;
18
18
import useCanvasFadeout from '../../misc/useCanvasFadeout' ;
19
19
import useWindowSize from '../../misc/useWindowSize' ;
20
20
import useForceUpdate from '../../misc/useForceUpdate' ;
@@ -28,6 +28,14 @@ const Page = () => {
28
28
const [ drawingPhase , setDrawingPhase ] = useState <
29
29
StrokeDrawingContext < any , any , BrushStrokeResult >
30
30
> ( ) ;
31
+ interface Config {
32
+ brushSize : number ;
33
+ stringLength : number ;
34
+ }
35
+ const [ config , setConfig ] = useState < Config > ( ( ) => ( {
36
+ brushSize : 40 ,
37
+ stringLength : 200 ,
38
+ } ) ) ;
31
39
useEffect ( ( ) => {
32
40
if ( ! drawingPhase ?. getState ( ) . update ) return ;
33
41
const id = setInterval ( drawingPhase . getState ( ) . update , 10 ) ;
@@ -39,11 +47,11 @@ const Page = () => {
39
47
const brushConfig = {
40
48
...defaultBrushConfig ,
41
49
ctx,
42
- size : 20 ,
50
+ size : config . brushSize ,
43
51
} ;
44
52
const drawingPhase = pulledString . down (
45
53
{
46
- ... defaultPulledStringConfig ,
54
+ stringLength : config . stringLength ,
47
55
targetConfig : brushConfig ,
48
56
} ,
49
57
stylusState
@@ -89,6 +97,15 @@ const Page = () => {
89
97
octoColor = "#fff"
90
98
href = "https://github.com/disjukr/croquis.js/blob/master/packages/website/src/pages/example/stabilizer-pulled-string.tsx"
91
99
/>
100
+ < DataController
101
+ className = "data-controller"
102
+ data = { config }
103
+ setData = { setConfig }
104
+ config = { {
105
+ brushSize : { label : 'Brush Size' , type : 'range' , min : 0 , max : 100 , step : 1 } ,
106
+ stringLength : { label : 'String Length' , type : 'range' , min : 0 , max : 200 , step : 1 } ,
107
+ } }
108
+ />
92
109
</ >
93
110
) ;
94
111
} ;
0 commit comments