SGraphyRectItem.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { SGraphyItem } from '@sybotan-web/graphy'
  2. import { SRect, SSize, SPoint } from "@sybotan-web/base";
  3. import { SPen, SPainter, SColor } from "@sybotan-web/draw";
  4. /**
  5. * 矩形Item类
  6. *
  7. */
  8. export class SGraphyRectItem extends SGraphyItem {
  9. startX: number;
  10. startY: number;
  11. width: number;
  12. height: number;
  13. color: SColor = SColor.Black;
  14. isVirtual: boolean = false;
  15. /**
  16. * 构造函数
  17. *
  18. * @param startX 线的起始x坐标
  19. * @param startY 线的起始y坐标
  20. * @param width 矩形的宽度
  21. * @param height 矩形的宽度
  22. * @param color 矩形填充的颜色
  23. * @param parent
  24. * @param isVirtual 是否为虚线
  25. */
  26. constructor(
  27. parent: SGraphyItem | null,
  28. startX: number,
  29. startY: number,
  30. width: number,
  31. height: number,
  32. color: SColor = SColor.Black,
  33. isVirtual: boolean = false
  34. ) {
  35. super(parent);
  36. this.startX = startX
  37. this.startY = startY
  38. this.width = width;
  39. this.height = height
  40. this.color = color;
  41. this.isVirtual = isVirtual;
  42. } // Constructor()
  43. /**
  44. * Item对象边界区域
  45. *
  46. * @return SRect
  47. */
  48. boundingRect(): SRect {
  49. return new SRect(
  50. this.startX,
  51. this.startY,
  52. this.width,
  53. this.height
  54. );
  55. } // Function boundingRect()
  56. /**
  57. * Item绘制操作
  58. *
  59. * @param painter painter对象
  60. * @param rect 绘制区域
  61. */
  62. onDraw(painter: SPainter, rect: SRect): void {
  63. painter.pen = new SPen(this.color, this.width);
  64. painter.drawRect(this.startX,this.startY,this.width,this.height)
  65. }
  66. } // Class SGraphyRectItem