32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
|
import { Container, Graphics, Point } from 'pixi.js';
|
||
|
import { VectorText } from 'jl-graphic';
|
||
|
import { SignalColorEnum, signalConsts } from '../bjRtss/Signal.js';
|
||
|
|
||
|
class SignalCode extends Container {
|
||
|
blockedMode = new Graphics();
|
||
|
codeGraph = new VectorText('');
|
||
|
name = 'signalCode';
|
||
|
constructor() {
|
||
|
super();
|
||
|
this.addChild(this.blockedMode);
|
||
|
this.addChild(this.codeGraph);
|
||
|
}
|
||
|
paint(datas) {
|
||
|
this.codeGraph.text = datas?.code || '信号机编号';
|
||
|
this.codeGraph.style.fill = SignalColorEnum.defaultCodeColor;
|
||
|
this.codeGraph.setVectorFontSize(signalConsts.codeFontSize);
|
||
|
this.codeGraph.anchor.set(0.5);
|
||
|
this.codeGraph.position.set(0, 0);
|
||
|
this.blockedMode.clear();
|
||
|
}
|
||
|
createBlockedMode() {
|
||
|
const codeRect = this.codeGraph.getBounds();
|
||
|
const rectP = this.screenToLocalPoint(new Point(codeRect.x, codeRect.y));
|
||
|
this.blockedMode.clear();
|
||
|
this.blockedMode.lineStyle(signalConsts.blockedLineWidth, SignalColorEnum.blockedColor);
|
||
|
this.blockedMode.drawRect(rectP.x, rectP.y, codeRect.width, codeRect.height);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export { SignalCode };
|