Skip to content

Commit

Permalink
opt: opt figure circle render
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Jun 5, 2024
1 parent 144d122 commit 0919d2f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/extension/figure/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ export function drawCircle (ctx: CanvasRenderingContext2D, attrs: CircleAttrs |
borderStyle = LineType.Solid,
borderDashedValue = [2, 2]
} = styles
if (
(style === PolygonType.Fill || styles.style === PolygonType.StrokeFill) &&
(!isString(color) || !isTransparent(color))
) {

const solid = (style === PolygonType.Fill || styles.style === PolygonType.StrokeFill) && (!isString(color) || !isTransparent(color))
if (solid) {
ctx.fillStyle = color
circles.forEach(({ x, y, r }) => {
ctx.beginPath()
Expand All @@ -67,10 +66,12 @@ export function drawCircle (ctx: CanvasRenderingContext2D, attrs: CircleAttrs |
ctx.setLineDash([])
}
circles.forEach(({ x, y, r }) => {
ctx.beginPath()
ctx.arc(x, y, r, 0, Math.PI * 2)
ctx.closePath()
ctx.stroke()
if (!solid || r > borderSize) {
ctx.beginPath()
ctx.arc(x, y, r, 0, Math.PI * 2)
ctx.closePath()
ctx.stroke()
}
})
}
}
Expand Down

0 comments on commit 0919d2f

Please sign in to comment.