车站--站控中控

This commit is contained in:
joylink_zhaoerwei 2023-06-26 15:13:25 +08:00
parent 4efb620b42
commit 3a51b0697c

View File

@ -73,75 +73,83 @@ export interface IStationState extends GraphicState {
} }
const stationConsts = { const stationConsts = {
radius: 5, radius: 3,
borderWidth: 1, borderWidth: 1,
borderColor: '0xff0000', circleColorGrey: '0x808080',
fillColor: '0xff0000', circleColorBlue: '0x08F80D',
transferRadius: 3.5, circleColorYellow: '0xFFFA0C',
transferWidth: 0.2,
transferColor: '0x0fe81f',
codeColor: '0xF48815', codeColor: '0xF48815',
codeFontSize: 22, codeFontSize: 22,
codeControlFontSize: 18, codeControlFontSize: 12,
codeOffsetX: -60, codeOffsetY: 30,
codeOffsetY: -25, circleOffsetY: 20,
circleOffsetY: -50, circleBetweenOffset: 40,
circleBetweenOffset: 60, kilometerCodeColor: '0xFFFFFF',
kilometerCodeColor: '0x0fe81f', kilometerCodeFontSize: 8,
kilometerCodeFontSize: 11,
kilometerCodeOffsetY: -25, kilometerCodeOffsetY: -25,
}; };
class constrolGraphic extends Container { class constrolGraphic extends Container {
circleA: Graphics = new Graphics(); circleA: Graphics = new Graphics();
codeGraphA: VectorText = new VectorText(''); //控制名--紧急站控 codeGraphA: VectorText = new VectorText(''); //控制名--站控
circleB: Graphics = new Graphics(); circleB: Graphics = new Graphics();
codeGraphB: VectorText = new VectorText(''); //控制名-- codeGraphB: VectorText = new VectorText(''); //控制名--
circleC: Graphics = new Graphics(); arrow: Graphics = new Graphics();
codeGraphC: VectorText = new VectorText(''); //控制名--站控 inArrow: Graphics = new Graphics();
constructor() { constructor() {
super(); super();
this.addChild(this.circleA); this.addChild(this.circleA);
this.addChild(this.codeGraphA); this.addChild(this.codeGraphA);
this.addChild(this.circleB); this.addChild(this.circleB);
this.addChild(this.codeGraphB); this.addChild(this.codeGraphB);
this.addChild(this.circleC); this.addChild(this.arrow);
this.addChild(this.codeGraphC); this.addChild(this.inArrow);
this.codeGraphA.setVectorFontSize(stationConsts.codeFontSize); this.codeGraphA.setVectorFontSize(stationConsts.codeFontSize);
this.codeGraphB.setVectorFontSize(stationConsts.codeFontSize);
} }
draw(): void { draw(): void {
this.drawCircleCode(this.circleA, this.codeGraphA, '站控'); this.drawCircleCode(this.circleA, this.codeGraphA, '站控');
this.circleA.position.set( this.circleA.position.set(
stationConsts.codeOffsetX, stationConsts.circleBetweenOffset / 2,
stationConsts.circleOffsetY stationConsts.circleOffsetY
); );
this.codeGraphA.position.set( this.codeGraphA.position.set(
stationConsts.codeOffsetX, stationConsts.circleBetweenOffset / 2,
stationConsts.codeOffsetY stationConsts.codeOffsetY
); );
this.drawCircleCode(this.circleB, this.codeGraphB, '遥控', '0x0fe81f'); this.drawCircleCode(
this.circleB,
this.codeGraphB,
'中控',
stationConsts.circleColorBlue
);
this.circleB.position.set( this.circleB.position.set(
stationConsts.codeOffsetX - stationConsts.circleBetweenOffset, -stationConsts.circleBetweenOffset / 2,
stationConsts.circleOffsetY stationConsts.circleOffsetY
); );
this.codeGraphB.position.set( this.codeGraphB.position.set(
stationConsts.codeOffsetX - stationConsts.circleBetweenOffset, -stationConsts.circleBetweenOffset / 2,
stationConsts.codeOffsetY
);
this.drawCircleCode(this.circleC, this.codeGraphC, '紧急站控');
this.circleC.position.set(
stationConsts.codeOffsetX - stationConsts.circleBetweenOffset * 2,
stationConsts.circleOffsetY
);
this.codeGraphC.position.set(
stationConsts.codeOffsetX - stationConsts.circleBetweenOffset * 2,
stationConsts.codeOffsetY stationConsts.codeOffsetY
); );
const arrow = this.arrow;
arrow.clear();
arrow.lineStyle(stationConsts.borderWidth, new Color('0xFFFFFF'));
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
arrow.beginFill('0xFFFFFF');
arrow.drawPolygon(points);
arrow.endFill();
arrow.scale.set(1.1, 1.1);
arrow.position.set(-7, stationConsts.circleOffsetY);
const inArrow = this.inArrow;
inArrow.beginFill(stationConsts.circleColorGrey);
inArrow.drawPolygon(points);
inArrow.endFill();
inArrow.position.set(-6.5, stationConsts.circleOffsetY);
} }
drawCircleCode( drawCircleCode(
circle: Graphics, circle: Graphics,
codeGraph: VectorText, codeGraph: VectorText,
code: string, code: string,
fillcolor = stationConsts.fillColor fillcolor = stationConsts.circleColorGrey
): void { ): void {
circle.clear(); circle.clear();
circle.lineStyle(stationConsts.borderWidth, new Color(fillcolor)); circle.lineStyle(stationConsts.borderWidth, new Color(fillcolor));
@ -149,17 +157,15 @@ class constrolGraphic extends Container {
circle.drawCircle(0, 0, stationConsts.radius); circle.drawCircle(0, 0, stationConsts.radius);
circle.endFill; circle.endFill;
codeGraph.text = code; codeGraph.text = code;
codeGraph.style.fill = stationConsts.codeColor; codeGraph.style.fill = fillcolor;
codeGraph.setVectorFontSize(stationConsts.codeControlFontSize); codeGraph.setVectorFontSize(stationConsts.codeControlFontSize);
codeGraph.anchor.set(0.5); codeGraph.anchor.set(0.5);
} }
clear(): void { clear(): void {
this.circleA.clear(); this.circleA.clear();
this.circleB.clear(); this.circleB.clear();
this.circleC.clear();
this.codeGraphA.text = ''; this.codeGraphA.text = '';
this.codeGraphB.text = ''; this.codeGraphB.text = '';
this.codeGraphC.text = '';
} }
} }
export class Station extends JlGraphic { export class Station extends JlGraphic {