Changeset 0c6b92a for imaps-frontend/src/scripts/shapes/Stairs.js
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/scripts/shapes/Stairs.js
rd565449 r0c6b92a 1 1 import Konva from "konva"; 2 import { MapShape } from "./MapShape"; 2 import MapNode from "../base/MapNode.js"; 3 import {_registerNode} from "konva/lib/Global.js"; 4 import Room from "./Room.js"; 5 export default class Stairs extends MapNode{ 6 constructor(attrs,id) { 3 7 8 if(!attrs.fromLoad){ 9 attrs.width *= 4; 10 } 11 12 super({ 13 x: attrs.position.x, 14 y: attrs.position.y, 15 width: attrs.width * attrs.scaleX, 16 height: attrs.height * attrs.scaleY, 17 fill: "rgb(225,213,124)", 18 stroke: "rgb(16,15,15)", 19 strokeWidth: 1, 20 name: "mapObj", 21 rotation: attrs.rotation, 22 draggable: true 23 }, 24 attrs.layer, 25 attrs.blockSize, 26 attrs.snap 27 ); 28 29 this.floorNum = attrs.floorNum; 30 31 this.type = "Stairs" 32 this._info = { 33 name: `Stairs${id} [${this.floorNum}F]`, 34 description: "", 35 selectedPins: [] 36 }; 37 38 this.id = id; 39 this.eventName = "openStairsModalEvent"; 40 this.initText(); 41 } 42 43 44 _sceneFunc(context, shape) { 45 const { width, height} = this.attrs; 46 47 let steps = 5; 48 context.beginPath() 49 for(let i = 0; i < steps; i++){ 50 context.rect((-this.blockSize) * i,(this.blockSize * 0.6) * i,width * 0.86,height/2) 51 context.fillStrokeShape(shape); 52 } 53 context.closePath() 54 } 55 56 loadInfo(attrs) { 57 this.info.name = attrs.obj_name; 58 this.info.description = attrs.description; 59 this.info.selectedPins = attrs.connected_pins; 60 this.floorNum = attrs.floor_num; 61 } 62 63 saveShapeDetails() { 64 this.setAttr("connected_pins", this.info.selectedPins); 65 this.setAttr("obj_name", this.info.name); 66 this.setAttr("description", this.info.description); 67 this.setAttr("floor_num",this.floorNum) 68 } 69 connect(node,draw = true) { 70 let canDraw = this.floorNum === node.floorNum; 71 super.connect(node,canDraw); 72 } 73 74 } 75 76 Stairs.prototype.className = "Stairs"; 77 _registerNode(Stairs); 4 78 //TODO
Note:
See TracChangeset
for help on using the changeset viewer.