import { fabric } from 'fabric'
import * as shapes from './shapes'
import * as utils from './utils'

export default class Ship extends fabric.Polygon {
    constructor({id, x, y, r, colour}, canvas) {
        super(shapes.ship, {
            left: x,
            top: y,
            fill: 'transparent',
            stroke: fabric.Color.fromHex(colour).toRgb(),
            selectable: false,
            originX: 'center',
            originY: 'center',
            scaleX: r / 10,
            scaleY: r / 10
        })
        
        this.id = id
        
        canvas.add(this)
    }
    
    update({angle}, duration) {
        var animation = {
            angle: Math.abs(angle)
        }
        
        this.animate(animation, {
            duration: duration,
            easing: utils.easing.linear
        })
        
    }
}
@@ -124,31 +124,8 @@
 hip 
-extends fabric.Polygon 
 %7B%0A  
@@ -183,13 +183,38 @@
     
-super
+this.ship = new fabric.Polygon
 (sha
@@ -578,16 +578,21 @@
 add(this
+.ship
 )%0A    %7D%0A
@@ -721,16 +721,21 @@
    this.
+ship.
 animate(

refactor (ship) use composition instead of inheritance