export interface MiShapeConfig { fill ? : string ; fillStyle ? : string ; stroke ? : string ; strokeStyle ? : string ; strokeWidth ? : number ; lineJoin ? : string ; lineCap ? : string ; lineWidth ? : number ; shadowBlur ? : number ; shadowColor ? : string ; globalCompositeOperation ? : string ; } export abstract class Shape < config extends MiShapeConfig = MiShapeConfig > { public attrs : { [ index ] : any ; } = { } ; param config protected constructor ( config ? ) { this . setAttrs ( config ) ; } param ctx protected assign ( ctx ) { const params = { } ; for ( const i in this . attrs ) { if ( Object . prototype . hasOwnProperty . call ( this . attrs , i ) ) { if ( this . attrs [ i ] && ! ( i in this ) ) { params [ i ] = JSON . parse ( JSON . stringify ( this . attrs [ i ] ) ) ; } } } Object . assign ( ctx , params ) ; } return { } public getAttrs ( ) { return this . attrs ; } param config public setAttrs ( config ) { if ( ! config ) return this ; for ( const key in config ) { if ( Object . prototype . hasOwnProperty . call ( config , key ) ) { this . attrs [ key ] = config [ key ] ; } } } }