import { Graphics } from 'pixi.js'; import { JlGraphic, VectorText } from 'jl-graphic'; const zdwxEsbConsts = { codeFontSize: 12, codeColor: 0xffffff, bodyLineColor: 0xff0000, lineWidth: 2, bodyRectLineColor: 0xff0000, bodyRectLineWidth: 1, bodyRectWidth: 20, bodyRectHeight: 20, bodyCircleRadius: 4, bodyColor: 0xff0000, rectOffset: -10, }; class ZdwxEsb extends JlGraphic { static Type = 'esbButton'; codeGraph = new VectorText(''); circleBody = new Graphics(); constructor() { super(ZdwxEsb.Type); this.addChild(this.codeGraph); this.addChild(this.circleBody); this.codeGraph.name = 'zdwx_esb_code'; } get datas() { return this.getDatas(); } get state() { return this.getStates(); } doRepaint() { const codeGraph = this.codeGraph; codeGraph.text = this.datas.code; codeGraph.style.fill = zdwxEsbConsts.codeColor; codeGraph.setVectorFontSize(zdwxEsbConsts.codeFontSize); codeGraph.anchor.set(0.5); const codeTransform = this.datas?.childTransforms?.find((item) => item.name === 'zdwx_esb_code'); if (codeTransform) { const position = codeTransform?.transform.position; const rotation = codeTransform?.transform?.rotation; codeGraph.position.set(position?.x, position?.y); codeGraph.rotation = rotation || 0; } else { codeGraph.position.set(-30, 0); } this.circleBody.clear(); this.circleBody.lineStyle(zdwxEsbConsts.lineWidth, zdwxEsbConsts.bodyColor); if (this.datas.flip) { this.circleBody.arc(0, 0, zdwxEsbConsts.bodyCircleRadius, 0, Math.PI); this.circleBody.moveTo(0, 0); this.circleBody.lineTo(0, -6); } else { this.circleBody.arc(0, 0, zdwxEsbConsts.bodyCircleRadius, Math.PI, 0); this.circleBody.moveTo(0, 0); this.circleBody.lineTo(0, 6); } this.circleBody.drawRect(zdwxEsbConsts.rectOffset, zdwxEsbConsts.rectOffset, zdwxEsbConsts.bodyRectWidth, zdwxEsbConsts.bodyRectHeight); } } export { ZdwxEsb, zdwxEsbConsts };