2025-05-27 15:46:31 +08:00

2 lines
1.7 KiB
JavaScript
Executable File

var __pow=Math.pow;!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pixi/graphics"),require("@pixi/text"),require("@pixi/math")):"function"==typeof define&&define.amd?define(["exports","@pixi/graphics","@pixi/text","@pixi/math"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).PIXI=t.PIXI||{},t.PIXI.live2d=t.PIXI.live2d||{}),t.PIXI,t.PIXI,t.PIXI)}(this,(function(t,e,i,s){"use strict";const o=new s.Rectangle;class r extends e.Graphics{constructor(){super(),this.initialized=!1,this.texts=[],this.strokeWidth=4,this.normalColor=14883354,this.activeColor=2017330,this.interactive=!0,this.on("added",this.init).on("pointermove",this.onPointerMove)}init(){const t=this.parent.internalModel,e=new i.TextStyle({fontSize:24,fill:"#ffffff",stroke:"#000000",strokeThickness:4});this.texts=Object.keys(t.hitAreas).map((t=>{const s=new i.Text(t,e);return s.visible=!1,this.addChild(s),s}))}onPointerMove(t){const e=this.parent.hitTest(t.data.global.x,t.data.global.y);this.texts.forEach((t=>{t.visible=e.includes(t.text)}))}_render(t){const e=this.parent.internalModel,i=1/Math.sqrt(__pow(this.transform.worldTransform.a,2)+__pow(this.transform.worldTransform.b,2));this.texts.forEach((t=>{this.lineStyle({width:this.strokeWidth*i,color:t.visible?this.activeColor:this.normalColor});const s=e.getDrawableBounds(e.hitAreas[t.text].index,o),r=e.localTransform;s.x=s.x*r.a+r.tx,s.y=s.y*r.d+r.ty,s.width=s.width*r.a,s.height=s.height*r.d,this.drawRect(s.x,s.y,s.width,s.height),t.x=s.x+this.strokeWidth*i,t.y=s.y+this.strokeWidth*i,t.scale.set(i)})),super._render(t),this.clear()}}t.HitAreaFrames=r,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));