Skip to content

Commit

Permalink
fix: add padding for canvas (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
devlzl authored Feb 25, 2024
1 parent a0aa261 commit 68d130d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Kernel/ToolBox/controller/PenToolController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { selectionManager, slideManager, toolBox, zoom } from '@Kernel/index'
import { ArrayStore } from '@Kernel/Store/ArrayStore'
import { OriginMap } from '@Kernel/Store/_Store'

const CANVAS_PADDING = 10

export class PenToolController extends ToolController {
private _drawing = false
private _canvasBlock?: CanvasBlock
Expand Down Expand Up @@ -35,16 +37,16 @@ export class PenToolController extends ToolController {
if (this._drawing) {
this._drawing = false
const block = new CanvasBlock(
this._range.left,
this._range.top,
this._range.right - this._range.left,
this._range.bottom - this._range.top
this._range.left - CANVAS_PADDING,
this._range.top - CANVAS_PADDING,
this._range.right - this._range.left + CANVAS_PADDING * 2,
this._range.bottom - this._range.top + CANVAS_PADDING * 2
)
for (const point of this._canvasBlock?.points as ArrayStore) {
const { x, y } = point as OriginMap
block.points.push({
x: (x as number) - this._range.left,
y: (y as number) - this._range.top,
x: (x as number) - this._range.left + CANVAS_PADDING,
y: (y as number) - this._range.top + CANVAS_PADDING,
})
}
const slide = slideManager.currentSlide
Expand Down

0 comments on commit 68d130d

Please sign in to comment.