import { Action } from './Action' ; import { User } from './User' ; import { BoardManager } from './boardManager' ; import { Delineation } from './Delineation' ; import { Tool } from './Tool' ; export abstract class ToolAbstractShape extends Tool { lastDelineation = new Delineation ( ) ; shape : SVGRectElement = undefined ; abstract compute = undefined ; abstract getShape = undefined ; abstract actionDrawShape : ( evt ) => Action = undefined ; abstract fillDelineation = undefined ; constructor ( user ) { super ( user ) ; if ( this . user . isCurrentUser ) { document . getElementById ( "buttonEraser" ) . hidden = false ; document . getElementById ( "buttonChalk" ) . hidden = true ; document . getElementById ( "canvas" ) . style . cursor = "crosshair" ; } } mousedown ( evt ) { this . lastDelineation . reset ( ) ; this . compute ( evt ) ; this . shape = this . getShape ( evt ) ; document . getElementById ( "svg" ) . appendChild ( this . shape ) ; } mousemove ( evt ) { if ( this . isDrawing ) { this . shape . remove ( ) ; this . compute ( evt ) ; this . shape = this . getShape ( evt ) ; document . getElementById ( "svg" ) . appendChild ( this . shape ) ; } } mouseup ( evt ) { if ( this . isDrawing ) { this . fillDelineation ( evt ) ; this . lastDelineation . finish ( ) ; const action = this . actionDrawShape ( evt ) ; action . redo ( ) ; BoardManager . addAction ( action ) ; this . shape . remove ( ) ; } } updateCursor ( ) { if ( this . user . isCurrentUser ) { } } }