SAnchorItem.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { SPainter, SColor } from "@saga-web/draw/lib";
  2. import { SGraphItem } from "../SGraphItem";
  3. /**
  4. * 锚点item
  5. *
  6. * @author 郝建龙(1061851420@qq.com)
  7. */
  8. export class SAnchorItem extends SGraphItem {
  9. /** 锚点宽 */
  10. private width: number = 3;
  11. /** 锚点高 */
  12. private height: number = 3;
  13. /** 是否被连接 */
  14. isConnected: boolean = false;
  15. /** 全局灵敏度 */
  16. dis: number = 30;
  17. /** 灵敏度转换为场景长度 */
  18. sceneDis: number = 10;
  19. /**
  20. * Item绘制操作
  21. *
  22. * @param painter painter对象
  23. */
  24. onDraw(painter: SPainter): void {
  25. this.sceneDis = painter.toPx(this.dis);
  26. painter.pen.lineWidth = painter.toPx(1);
  27. painter.pen.color = new SColor("#2196f3");
  28. painter.brush.color = SColor.White;
  29. if (this.isConnected) {
  30. painter.brush.color = painter.pen.color;
  31. }
  32. painter.drawRect(
  33. -this.width / 2,
  34. -this.height / 2,
  35. this.width,
  36. this.height
  37. );
  38. } // Function onDraw()
  39. } // Class SAnchorItem