import VectorType from "../enum/VectorType.js"; import SelectState from "../enum/SelectState.js"; import Geometry from "./Geometry"; import Constant from "../Constant.js"; import Style from '../CanvasStyle' //不靠墙 export default class Circle extends Geometry { constructor(center, radius, vectorId) { super(); this.radius = Style.Circle.radius; this.center = null; this.color = Style.Circle.strokeStyle; this.points = []; //包含圆的4个顶点,按照顺时针的方式存入数组中,第一个元素是左上角顶点 this.geoType = VectorType.Circle; this.setId(vectorId); this.setRadius(radius); this.setCenter(center); this.createPoints(); } setRadius(radius) { this.radius = radius; } setCenter(center) { if (center) { this.center = {}; this.center.x = center.x; this.center.y = center.y; } } createPoints() { this.points[0] = { x: this.center.x - this.radius, y: this.center.y + this.radius, }; this.points[1] = { x: this.center.x + this.radius, y: this.center.y + this.radius, }; this.points[2] = { x: this.center.x + this.radius, y: this.center.y - this.radius, }; this.points[3] = { x: this.center.x - this.radius, y: this.center.y - this.radius, }; } setColor(value) { this.color = value; } }