Skip to content

Commit acf3969

Browse files
committed
1 parent 242865c commit acf3969

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/website/src/pages/example/stabilizer-pulled-string.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import {
77
} from 'croquis.js/lib/brush/simple';
88
import {
99
getStroke as getPulledStringStroke,
10-
defaultPulledStringConfig,
1110
PulledStringDrawingContext,
1211
} from 'croquis.js/lib/stabilizer/pulled-string';
1312
import type { StrokeDrawingContext } from 'croquis.js/lib/stroke-protocol';
1413
import { getStylusState, createStylusState } from 'croquis.js/lib/stylus';
1514
import PulledStringGuide from '../../components/guide/stabilizer/PulledStringGuide';
1615
import Draw from '../../components/example/Draw';
1716
import GithubCorner from '../../components/GithubCorner';
17+
import DataController from '../../components/DataController';
1818
import useCanvasFadeout from '../../misc/useCanvasFadeout';
1919
import useWindowSize from '../../misc/useWindowSize';
2020
import useForceUpdate from '../../misc/useForceUpdate';
@@ -28,6 +28,14 @@ const Page = () => {
2828
const [drawingPhase, setDrawingPhase] = useState<
2929
StrokeDrawingContext<any, any, BrushStrokeResult>
3030
>();
31+
interface Config {
32+
brushSize: number;
33+
stringLength: number;
34+
}
35+
const [config, setConfig] = useState<Config>(() => ({
36+
brushSize: 40,
37+
stringLength: 200,
38+
}));
3139
useEffect(() => {
3240
if (!drawingPhase?.getState().update) return;
3341
const id = setInterval(drawingPhase.getState().update, 10);
@@ -39,11 +47,11 @@ const Page = () => {
3947
const brushConfig = {
4048
...defaultBrushConfig,
4149
ctx,
42-
size: 20,
50+
size: config.brushSize,
4351
};
4452
const drawingPhase = pulledString.down(
4553
{
46-
...defaultPulledStringConfig,
54+
stringLength: config.stringLength,
4755
targetConfig: brushConfig,
4856
},
4957
stylusState
@@ -89,6 +97,15 @@ const Page = () => {
8997
octoColor="#fff"
9098
href="https://github.com/disjukr/croquis.js/blob/master/packages/website/src/pages/example/stabilizer-pulled-string.tsx"
9199
/>
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+
/>
92109
</>
93110
);
94111
};

packages/website/src/pages/example/stabilizer-snake.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const Page = () => {
3535
weight: number;
3636
}
3737
const [config, setConfig] = useState<Config>(() => ({
38-
brushSize: 20,
39-
tailCount: 3,
40-
weight: 0.5,
38+
brushSize: 40,
39+
tailCount: 5,
40+
weight: 0.7,
4141
}));
4242
useEffect(() => {
4343
if (!drawingPhase) return;

0 commit comments

Comments
 (0)