SGraphyCircleItem.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { SGraphyItem } from '@sybotan-web/graphy';
  2. import { SRect, SSize } from "@sybotan-web/base";
  3. import { SPen, SPainter, SColor } from "@sybotan-web/draw";
  4. /**
  5. * 圆Item类
  6. *
  7. */
  8. export default class SGraphyCircleItem extends SGraphyItem {
  9. r: number;
  10. fillColor: SColor = SColor.White;
  11. color: SColor = SColor.Black;
  12. width: number = 1;
  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. r: number,
  25. fillColor: SColor = SColor.White,
  26. color: SColor = SColor.Black,
  27. width: number = 1
  28. ) {
  29. super(parent);
  30. this.r = r;
  31. this.color = color;
  32. this.fillColor = fillColor;
  33. this.width = width;
  34. } // Constructor()
  35. /**
  36. * Item对象边界区域
  37. *
  38. * @return SRect
  39. */
  40. boundingRect(): SRect {
  41. return new SRect(
  42. -this.r,
  43. -this.r,
  44. 2 * this.r,
  45. 2 * this.r
  46. );
  47. } // Function boundingRect()
  48. /**
  49. * Item绘制操作
  50. *
  51. * @param painter painter对象
  52. * @param rect 绘制区域
  53. */
  54. onDraw(painter: SPainter, rect?: SRect): void {
  55. // painter.pen = new SPen(new SColor("#FF0000"), 22);
  56. painter.pen.color = this.color;
  57. painter.brush.color = this.fillColor;
  58. painter.drawCircle(500, 500, this.r);
  59. }
  60. } // Class SGraphyCircleItem