import Group from 'zrender/src/container/Group'; import Rect from 'zrender/src/graphic/shape/Rect'; import Stop_Route from '@/assets/stop_route.png'; import Pattern from 'zrender/src/graphic/Pattern'; import JTriangle from '../../utils/JTriangle'; export default class EStopRouteImg extends Group { constructor(model) { super(); this.model = model; this.zlevel = model.zlevel; this.z = model.z; this.stopRouteImgList = []; this.create(); } create() { const model = this.model.modelData; const style = this.model.style; const modelPoints = model.points; if (model.type !== '04') { const image = new Image(5, 8); image.src = Stop_Route; image.decode() .then(() => { const pattern = new Pattern(image, 'repeat'); for (let i = 1; i < modelPoints.length; i++) { const triangle = new JTriangle(modelPoints[i - 1], modelPoints[i]); this.stopRouteImgList.push(new Rect({ zlevel: this.zlevel, z: this.z + 1, origin: [modelPoints[i - 1].x, modelPoints[i - 1].y], rotation: -triangle.getRotation(), shape: { x: modelPoints[i - 1].x, y: modelPoints[i - 1].y - style.Section.line.width / 2, width: triangle.getLength(), height: style.Section.line.width }, style: { fill: pattern } })); } this.stopRouteImgList.forEach(item => { this.add(item); item.hide(); }); }); } } setModel(dx, dy) { } setCursor(mouseStyle) { this.imageBg.attr('cursor', mouseStyle); } recover() { } setState() { } }