11import { initContextAttrs } from "@e-board/board-utils" ;
22import { eBoardContainer } from "../../common/IocContainer" ;
33import { IModelService , IModeService , IEventService } from "../../services" ;
4- import { IConfigService , IModel } from "../../services" ;
5- import { IRenderService } from "../../services/renderService/type" ;
4+ import { IConfigService } from "../../services" ;
65import { ITransformService } from "../../services/transformService/type" ;
76import { IBoard , IPluginInitParams } from "../../types" ;
87import { IPlugin } from "../type" ;
@@ -13,7 +12,6 @@ class DrawPlugin implements IPlugin {
1312 private disposeList : ( ( ) => void ) [ ] = [ ] ;
1413 private configService = eBoardContainer . get < IConfigService > ( IConfigService ) ;
1514 private modelService = eBoardContainer . get < IModelService > ( IModelService ) ;
16- private renderService = eBoardContainer . get < IRenderService > ( IRenderService ) ;
1715 private transformService = eBoardContainer . get < ITransformService > ( ITransformService ) ;
1816
1917
@@ -90,7 +88,6 @@ class DrawPlugin implements IPlugin {
9088 public init ( { board } : IPluginInitParams ) {
9189 this . board = board ;
9290 this . initDrawMode ( ) ;
93- this . registerLineDrawHandler ( ) ;
9491
9592 }
9693
@@ -110,33 +107,6 @@ class DrawPlugin implements IPlugin {
110107 } ) ;
111108 }
112109
113- private registerLineDrawHandler ( ) {
114- this . renderService . registerDrawModelHandler ( "line" , this . drawLineModelHandler ) ;
115- }
116-
117- private drawLineModelHandler = ( model : IModel , ctx ?: CanvasRenderingContext2D , useWorldCoords = false ) => {
118- const context = this . board . getCtx ( ) ;
119- if ( ! context ) return ;
120- context . save ( )
121- const toScreenPoint = useWorldCoords
122- ? ( point : { x : number ; y : number } ) => point
123- : ( point : { x : number ; y : number } ) => this . transformPoint ( point ) ;
124- model . points ?. forEach ( ( point , index ) => {
125- const transformedPoint = toScreenPoint ( point ) ;
126- if ( index === 0 ) {
127- context . moveTo ( transformedPoint . x , transformedPoint . y ) ;
128- } else if ( index < 2 ) {
129- context . lineTo ( transformedPoint . x , transformedPoint . y ) ;
130- } else {
131- const p1 = toScreenPoint ( model . points ! [ index - 1 ] ) ;
132- const p2 = toScreenPoint ( point ) ;
133- const midPointX = ( p1 . x + p2 . x ) / 2 ;
134- const midPointY = ( p1 . y + p2 . y ) / 2 ;
135- context . quadraticCurveTo ( p1 . x , p1 . y , midPointX , midPointY ) ;
136- }
137- } ) ;
138- context . restore ( )
139- } ;
140110
141111 private getCanvasPoint ( clientX : number , clientY : number ) {
142112 const canvas = this . board . getCanvas ( ) ;
@@ -194,7 +164,6 @@ class DrawPlugin implements IPlugin {
194164
195165 public dispose ( ) {
196166 this . disposeList . forEach ( dispose => dispose ( ) ) ;
197- this . renderService . unregisterDrawModelHandler ( "line" ) ;
198167 }
199168}
200169
0 commit comments