column.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div>
  3. <canvas id="wall" width="800" height="400" tabindex="0"/>
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import { SGraphScene, SGraphView } from "@persagy-web/graph/";
  8. import { SColumnItem } from "@persagy-web/big/lib/items/floor/SColumnItem";
  9. import { Component, Vue } from "vue-property-decorator";
  10. @Component
  11. export default class ColumnCanvas extends Vue {
  12. view: SGraphView | undefined;
  13. // 图中靠上位置的黑色矩形轮廓
  14. outline1 = [[{X: 120, Y: 10}, {X: 120, Y: 30}, {X: 10, Y: 30}, {X: 10, Y: 10}]];
  15. // 图中靠下位置的,绘制多个图形,会覆盖
  16. outline2 = [
  17. [{X: 120, Y: -30}, {X: 120, Y: -50}, {X: 10, Y: -50}, {X: 10, Y: -30}],
  18. [{X: 20, Y: -30}, {X: 20, Y: -85}, {X: 110, Y: -85}, {X: 110, Y: -40}]
  19. ];
  20. /**
  21. * 页面挂载
  22. */
  23. mounted(): void {
  24. this.init();
  25. };
  26. init(): void {
  27. this.view = new SGraphView('wall');
  28. const scene = new SGraphScene();
  29. this.view.scene = scene;
  30. // 只模拟了轮廓数据
  31. const item = new SColumnItem(null, {OutLine: this.outline1});
  32. scene.addItem(item);
  33. // 只模拟了轮廓数据
  34. const item2 = new SColumnItem(null, {OutLine: this.outline2});
  35. scene.addItem(item2);
  36. this.view.fitSceneToView();
  37. this.view.scalable = false;
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. </style>