wall.vue 1.4 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 {SWallItem} from "@persagy-web/big/lib/items/floor/SWallItem";
  9. import {Component, Vue} from "vue-property-decorator";
  10. @Component
  11. export default class WallCanvas 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: -40}, {X: 20, Y: -45}, {X: 100, Y: -45}, {X: 100, Y: -40}]
  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 SWallItem(null, {OutLine: this.outline1});
  29. scene.addItem(item);
  30. // 只模拟了轮廓数据
  31. const item2 = new SWallItem(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>