Skip to content

Commit

Permalink
fix Rect render
Browse files Browse the repository at this point in the history
  • Loading branch information
leaferjs committed Jun 3, 2024
1 parent 1675e94 commit 56edb15
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/display-module/render/src/RectRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const RectRender: IRectRenderModule = {

__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {

const { width, height, fill, stroke, __drawAfterFill } = this.__
let { width, height, fill, stroke, __drawAfterFill } = this.__

if (fill) {
canvas.fillStyle = fill
Expand All @@ -29,12 +29,21 @@ export const RectRender: IRectRenderModule = {
canvas.strokeRect(0, 0, width, height)
break
case 'inside':
canvas.strokeRect(half, half, width - __strokeWidth, height - __strokeWidth)
width -= __strokeWidth, height -= __strokeWidth
if (width < 0 || height < 0) {
canvas.save()
this.__clip(canvas, options)
canvas.strokeRect(half, half, width, height)
canvas.restore()
} else {
canvas.strokeRect(half, half, width, height)
}
break
case 'outside':
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth)
break
}

}

}
Expand Down

0 comments on commit 56edb15

Please sign in to comment.