Function useDrawingOperation
- useDrawingOperation(canvasRef, state): {
applyFill: ((drawingData: DrawingData) => void);
clearCanvas: (() => void);
drawStroke: ((drawingData: DrawingData) => void);
floodFill: ((startX: number, startY: number) => {
points: Point[];
style: StrokeStyle;
timestamp: number;
});
getCurrentStyle: (() => StrokeStyle);
redrawCanvas: (() => void);
} Parameters
- canvasRef: RefObject<HTMLCanvasElement>
- state: {
brushSize: any;
canRedo: boolean;
canUndo: boolean;
checkInkAvailability: (() => boolean);
crdtRef: MutableRefObject<LWWMap>;
currentColor: any;
currentPlayerId: any;
currentStrokeIdsRef: MutableRefObject<string[]>;
drawingMode: DrawingMode;
historyPointerRef: MutableRefObject<number>;
inkRemaining: any;
resetDrawingState: (() => void);
setBrushSize: Dispatch<any>;
setCurrentColor: Dispatch<any>;
setDrawingMode: Dispatch<any>;
setInkRemaining: Dispatch<any>;
strokeHistoryRef: MutableRefObject<StrokeHistoryEntry[]>;
updateHistoryState: (() => void);
}brushSize: any
canRedo: boolean
canUndo: boolean
checkInkAvailability: (() => boolean)
- (): boolean
Returns boolean
crdtRef: MutableRefObject<LWWMap>
currentColor: any
currentPlayerId: any
currentStrokeIdsRef: MutableRefObject<string[]>
drawingMode: DrawingMode
historyPointerRef: MutableRefObject<number>
inkRemaining: any
resetDrawingState: (() => void)
setBrushSize: Dispatch<any>
setCurrentColor: Dispatch<any>
setDrawingMode: Dispatch<any>
setInkRemaining: Dispatch<any>
strokeHistoryRef: MutableRefObject<StrokeHistoryEntry[]>
updateHistoryState: (() => void)
Returns {
applyFill: ((drawingData: DrawingData) => void);
clearCanvas: (() => void);
drawStroke: ((drawingData: DrawingData) => void);
floodFill: ((startX: number, startY: number) => {
points: Point[];
style: StrokeStyle;
timestamp: number;
});
getCurrentStyle: (() => StrokeStyle);
redrawCanvas: (() => void);
}
드로잉 작업 메소드들을 포함하는 객체
applyFill: ((drawingData: DrawingData) => void)
- (drawingData): void
Returns void
clearCanvas: (() => void)
drawStroke: ((drawingData: DrawingData) => void)
- (drawingData): void
Returns void
floodFill: ((startX: number, startY: number) => {
points: Point[];
style: StrokeStyle;
timestamp: number;
})
- (startX, startY): {
points: Point[];
style: StrokeStyle;
timestamp: number;
} Parameters
- startX: number
- startY: number
Returns {
points: Point[];
style: StrokeStyle;
timestamp: number;
}
points: Point[]
style: StrokeStyle
timestamp: number
getCurrentStyle: (() => StrokeStyle)
- (): StrokeStyle
Returns StrokeStyle
redrawCanvas: (() => void)
캔버스의 실제 드로잉 작업을 수행하는 Hook입니다.
Remarks
캔버스의 실제 드로잉 작업들을 관리합니다.
useDrawingState와 함께 작동하여 드로잉 컨텍스트를 유지하고 캔버스의 실제 픽셀 조작을 처리합니다.
Example