
import { SGraphyItem } from '@sybotan-web/graphy';
import { SRect, SSize } from "@sybotan-web/base";
import { SPen, SPainter, SColor } from "@sybotan-web/draw";

/**
 * 圆Item类
 *
 */
export default class SGraphyCircleItem extends SGraphyItem {
    r: number;
    fillColor: SColor = SColor.White;
    color: SColor = SColor.Black;
    width: number = 1;

    /**
     * 构造函数
     *
     * @param r          圆半径
     * @param width      圆线的宽度
     * @param color      圆线的颜色
     * @param fillColor  圆填充的颜色
     * @param parent    
     */
    constructor(
        parent: SGraphyItem | null,
        r: number,
        fillColor: SColor = SColor.White,
        color: SColor = SColor.Black,
        width: number = 1
    ) {
        super(parent);
        this.r = r;
        this.color = color;
        this.fillColor = fillColor;
        this.width = width;
    } // Constructor()

    /**
     * Item对象边界区域
     * 
     * @return SRect
     */
    boundingRect(): SRect {
        return new SRect(
            -this.r,
            -this.r,
            2 * this.r,
            2 * this.r
        );
    } // Function boundingRect()

    /**
     * Item绘制操作
     *
     * @param   painter       painter对象
     * @param   rect          绘制区域
     */
    onDraw(painter: SPainter, rect?: SRect): void {
        // painter.pen = new SPen(new SColor("#FF0000"), 22);
        painter.pen.color = this.color;
        painter.brush.color = this.fillColor;
        painter.drawCircle(500, 500, this.r);
    }
} // Class SGraphyCircleItem
