-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: User Experience Optimization Code Merge about Drawing (#143)
* feat: Add useCursor hook * feat: Fix cursor offset and improve canvas edge interpolation * feat: Change flood fill logic and fix lazy issue with fill operation on local * feat: Add requestAnimationFrame about draw rendering * feat: Delete requestAnimationFrame * feat: Add drawSmoothLine method * feat: Edge drawing re-improvement * feat: Modified so that the lines are drawn roundly * feat: Apply early return to flood fill * feat: Merge if and else if * feat: Move 'cursor correction' work file to handle folder * feat: Recover accidentally deleted types * feat: Save current state to change branch * feat: Delete stroke interpolation
- Loading branch information
Showing
4 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { RefObject } from 'react'; | ||
import { Point } from '@troublepainter/core'; | ||
import { getCanvasContext } from '@/utils/getCanvasContext'; | ||
|
||
const handleInCanvas = (canvasRef: RefObject<HTMLCanvasElement>, point: Point, brushSize: number) => { | ||
const { canvas, ctx } = getCanvasContext(canvasRef); | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
|
||
ctx.beginPath(); | ||
ctx.lineWidth = 2; | ||
ctx.arc(point.x, point.y, brushSize / 2, 0, 2 * Math.PI); | ||
ctx.stroke(); | ||
}; | ||
|
||
const handleOutCanvas = (canvasRef: RefObject<HTMLCanvasElement>) => { | ||
const { canvas, ctx } = getCanvasContext(canvasRef); | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
}; | ||
|
||
export { handleInCanvas, handleOutCanvas }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters