12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import SGraphyItem from '../SGraphyItem'
- import SRect from '../types/SRect';
- export default class SGraphyCircleItem extends SGraphyItem {
-
- constructor(X, Y, color, Radius, isSolid, name, parent = null) {
- super(parent)
- this.X = X
- this.Y = Y
- this.color = color
- this.Radius = Radius
- this.isSolid = isSolid
- this.minX = this.X - this.Radius
- this.minY = this.Y - this.Radius
- this.maxX = this.X + this.Radius
- this.maxY = this.Y + this.Radius
- this.sAngle = null || 0
- this.eAngle = null || 2 * Math.PI
- this.name = name
- this.type = 6
- this.lineWidth = null
- }
-
- boundingRect() {
- return new SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY)
- }
-
- onDraw(canvas, rect) {
- canvas.lineWidth = this.lineWidth || 240
- canvas.strokeStyle = this.color || '#000'
- canvas.fillStyle = this.color || '#000'
- canvas.beginPath();
- canvas.arc(this.X, this.Y, this.Radius, this.sAngle, this.eAngle);
- if (!!this.isSolid) {
- canvas.fillStyle = this.color;
- canvas.fill();
- }
- canvas.stroke()
- if (!!this.name) {
- canvas.font = "oblique small-caps bold " + this.lineWidth * 10 + "px Arial";
-
- canvas.fillStyle = 'green'
- canvas.fillText(this.name, this.X, this.Y);
- }
- }
- }
|