import { SGraphyItem } from '@sybotan-web/graphy' import { SRect, SSize, SPoint } from "@sybotan-web/base"; import { SPen, SPainter, SColor } from "@sybotan-web/draw"; /** * 矩形Item类 * */ export class SGraphyRectItem extends SGraphyItem { startX: number; startY: number; width: number; height: number; color: SColor = SColor.Black; isVirtual: boolean = false; /** * 构造函数 * * @param startX 线的起始x坐标 * @param startY 线的起始y坐标 * @param width 矩形的宽度 * @param height 矩形的宽度 * @param color 矩形填充的颜色 * @param parent * @param isVirtual 是否为虚线 */ constructor( parent: SGraphyItem | null, startX: number, startY: number, width: number, height: number, color: SColor = SColor.Black, isVirtual: boolean = false ) { super(parent); this.startX = startX this.startY = startY this.width = width; this.height = height this.color = color; this.isVirtual = isVirtual; } // Constructor() /** * Item对象边界区域 * * @return SRect */ boundingRect(): SRect { return new SRect( this.startX, this.startY, this.width, this.height ); } // Function boundingRect() /** * Item绘制操作 * * @param painter painter对象 * @param rect 绘制区域 */ onDraw(painter: SPainter, rect: SRect): void { painter.pen = new SPen(this.color, this.width); painter.drawRect(this.startX,this.startY,this.width,this.height) } } // Class SGraphyRectItem