virtualWall.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 */
  13. view: SGraphView | undefined;
  14. // 图中靠上位置的黑色矩形轮廓
  15. outline1 = [[{X: 12000, Y: 1000}, {X: 12000, Y: 3000}, {X: 1000, Y: 3000}, {X: 1000, Y: 1000}]];
  16. // 图中靠下位置的,中间掏洞
  17. outline2 = [
  18. [{X: 12000, Y: -3000}, {X: 12000, Y: -5000}, {X: 1000, Y: -5000}, {X: 10, Y: -3000}],
  19. [{X: 2000, Y: -4000}, {X: 2000, Y: -4500}, {X: 10000, Y: -4500}, {X: 10000, Y: -4000}]
  20. ];
  21. /**
  22. * 页面挂载
  23. */
  24. mounted() {
  25. this.init();
  26. };
  27. /**
  28. * 初始化加载
  29. */
  30. init() {
  31. this.view = new SGraphView('wall');
  32. const scene = new SGraphScene();
  33. this.view.scene = scene;
  34. // 只模拟了轮廓数据
  35. const item = new SVirtualWallItem(null, {OutLine: this.outline1});
  36. scene.addItem(item);
  37. // 只模拟了轮廓数据
  38. const item2 = new SVirtualWallItem(null, {OutLine: this.outline2});
  39. scene.addItem(item2);
  40. this.view.fitSceneToView();
  41. this.view.scalable = false;
  42. }
  43. }
  44. </script>
  45. <style scoped>
  46. </style>