import { Mesh2D } from '@turbox3d/graphic-view-pixi' ; import * as PIXI from 'pixi.js' ; import { Vec2 } from '@turbox3d/shared' ; import { drawText } from '../_utils/utils' ; interface IProps { center : Vec2 ; angle : number ; radius : string ; description startP : number ; length : number ; textSize : number ; } description export default class RadiusDimension extends Mesh2D < IProps > { protected view = new PIXI . Graphics ( ) ; public draw ( ) { const graphics = this . view ; graphics . clear ( ) ; graphics . lineStyle ( 2 , 0x131313 ) ; graphics . line . native = true ; const textSize = this . props . textSize ; const dir = { x : Math . cos ( this . props . angle ) , y : Math . sin ( this . props . angle ) } ; const startP = { x : this . props . center . x + this . props . startP * dir . x , y : this . props . center . y + this . props . startP * dir . y } ; graphics . moveTo ( startP . x , startP . y ) ; graphics . lineTo ( this . props . center . x + ( this . props . startP + this . props . length ) * dir . x , this . props . center . y + ( this . props . startP + this . props . length ) * dir . y ) ; const textOffsetDir = { x : - dir . y , y : dir . x } ; const a = { x : 2 * textSize * dir . x , y : 2 * textSize * dir . y } ; const b = { x : 0.8 * textSize * textOffsetDir . x , y : 0.8 * textSize * textOffsetDir . y } ; drawText ( graphics , this . props . radius , { offset : { x : startP . x + a . x + b . x , y : startP . y + a . y + b . y } , size : textSize , rotation : this . props . angle } ) ; } }