
import { SGraphyItem } from '@sybotan-web/graphy';
import { SRect, SSize, SPoint } from "@sybotan-web/base";
import { SPen, SPainter, SColor } from "@sybotan-web/draw";
/**
 * 坐标点
 *
 */
export default class SGraphyPointItem extends SGraphyItem {
    width: number = 100;
    point: SPoint;
    color: SColor;
    fillColor: SColor;

    /**
     * 构造函数
     *
     * @param r          圆半径
     * @param width      圆线的宽度
     * @param color      圆线的颜色
     * @param fillColor  圆填充的颜色
     * @param parent    
     */
    constructor(
        parent: SGraphyItem | null,
        width: number = 100,
        point: SPoint = new SPoint(0, 0),
        color: SColor = new SColor('#F56C6C'),
        fillColor: SColor = new SColor('#F56C6C')
    ) {
        super(parent);
        this.width = width;
        this.point = point;
        this.color = color;
        this.fillColor = fillColor;
   
    } // Constructor()

    /**
     * Item对象边界区域
     * 
     * @return SRect
     */
    boundingRect(): SRect {
        let minX = this.point.x;
        let miny = this.point.y;
        let maxX = this.point.x + this.width;
        let maxY = this.point.y + this.width;
        return new SRect(
            minX,
            miny,
            maxX, maxY
        );
    } // Function boundingRect()

    /**
     * Item绘制操作
     *
     * @param   painter       painter对象
     * @param   rect          绘制区域
     */
    onDraw(painter: SPainter, rect?: SRect): void {
        painter.pen.color = this.color;
        painter.brush.color = this.fillColor;
        painter.drawRect(this.point.x,this.point.y,this.width,this.width)
    }
} // Class SGraphyCircleItem
