SGraphyPointItem.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * 坐标点
  6. *
  7. */
  8. export default class SGraphyPointItem extends SGraphyItem {
  9. width: number = 100;
  10. point: SPoint;
  11. color: SColor;
  12. fillColor: SColor;
  13. /**
  14. * 构造函数
  15. *
  16. * @param r 圆半径
  17. * @param width 圆线的宽度
  18. * @param color 圆线的颜色
  19. * @param fillColor 圆填充的颜色
  20. * @param parent
  21. */
  22. constructor(
  23. parent: SGraphyItem | null,
  24. width: number = 100,
  25. point: SPoint = new SPoint(0, 0),
  26. color: SColor = new SColor('#F56C6C'),
  27. fillColor: SColor = new SColor('#F56C6C')
  28. ) {
  29. super(parent);
  30. this.width = width;
  31. this.point = point;
  32. this.color = color;
  33. this.fillColor = fillColor;
  34. } // Constructor()
  35. /**
  36. * Item对象边界区域
  37. *
  38. * @return SRect
  39. */
  40. boundingRect(): SRect {
  41. let minX = this.point.x;
  42. let miny = this.point.y;
  43. let maxX = this.point.x + this.width;
  44. let maxY = this.point.y + this.width;
  45. return new SRect(
  46. minX,
  47. miny,
  48. maxX, maxY
  49. );
  50. } // Function boundingRect()
  51. /**
  52. * Item绘制操作
  53. *
  54. * @param painter painter对象
  55. * @param rect 绘制区域
  56. */
  57. onDraw(painter: SPainter, rect?: SRect): void {
  58. painter.pen.color = this.color;
  59. painter.brush.color = this.fillColor;
  60. painter.drawRect(this.point.x,this.point.y,this.width,this.width)
  61. }
  62. } // Class SGraphyCircleItem