virtualWall.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 {SVirtualWallItem} from "@persagy-web/big/lib/items/floor/SVirtualWallItem";
  9. import {Component, Vue} from "vue-property-decorator";
  10. @Component
  11. export default class VirtualWallCanvas extends Vue {
  12. view: SGraphView | undefined;
  13. // 图中靠上位置的黑色矩形轮廓
  14. outline1 = [[{X: 12000, Y: 1000}, {X: 12000, Y: 3000}, {X: 1000, Y: 3000}, {X: 1000, Y: 1000}]];
  15. // 图中靠下位置的,中间掏洞
  16. outline2 = [
  17. [{X: 12000, Y: -3000}, {X: 12000, Y: -5000}, {X: 1000, Y: -5000}, {X: 10, Y: -3000}],
  18. [{X: 2000, Y: -4000}, {X: 2000, Y: -4500}, {X: 10000, Y: -4500}, {X: 10000, Y: -4000}]
  19. ];
  20. mounted() {
  21. this.init();
  22. };
  23. init() {
  24. this.view = new SGraphView('wall');
  25. const scene = new SGraphScene();
  26. this.view.scene = scene;
  27. // 只模拟了轮廓数据
  28. const item = new SVirtualWallItem(null, {OutLine: this.outline1});
  29. scene.addItem(item);
  30. // 只模拟了轮廓数据
  31. const item2 = new SVirtualWallItem(null, {OutLine: this.outline2});
  32. scene.addItem(item2);
  33. this.view.fitSceneToView();
  34. this.view.scalable = false;
  35. }
  36. }
  37. </script>
  38. <style scoped>
  39. </style>