import Shape from './shape'; import { CircleOptions } from '../models/painter'; import { Decal } from '@utils/decal'; class Circle extends Shape { draw(): void { const { x, y, r, fillStyle, strokeStyle, decal, } = this.config as CircleOptions; const decalObj = new Decal(); decalObj.init(decal); if (decalObj.isValid()) { // ่ƒŒๆ™ฏ็บน็† decalObj.fillCircle(this.ctx, { x, y, radius: r }, fillStyle); } else { this.ctx.save(); this.ctx.beginPath(); this.ctx.arc(x, y, r, 0, Math.PI * 2, false); this.ctx.closePath(); this.ctx.fillStyle = fillStyle; this.ctx.fill(); this.ctx.restore(); } if (strokeStyle) { this.ctx.save(); this.ctx.beginPath(); this.ctx.arc(x, y, r, 0, Math.PI * 2, false); this.ctx.closePath(); this.ctx.strokeStyle = strokeStyle; this.ctx.stroke(); this.ctx.restore(); } } } export default Circle;