All files / gameFiles/frontend DrawingCanvas.js

0% Statements 0/26
100% Branches 1/1
100% Functions 1/1
0% Lines 0/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                                       
 
/**
 * This class handles all data associated with the drawing canvas
 */
import { Fabric } from 'fabric';
class DrawingCanvas{
    /**
     * Creates the instance of a DrawingCanvas
     * 
     * @param {"pen" | "eraser"} currentTool The current tool being used on the board
     * @param {String} strokeColor The color to draw with
     * @param {number} strokeWidth The width of the pen/eraser
     * @param {string | null} referenceImage The image being displayed to the drawer
     * @throes An error if referenceImage value is not set 
     */
    constructor(currentTool, strokeColor, strokeWidth, referenceImage){
        this.canvas = Fabric.Canvas;
        this.strokeColor = strokeColor;
        this.currentTool = currentTool;
        this.strokeWidth = strokeWidth;
        this.referenceImage = referenceImage;
        // needs to import from "ReferenceImageProvider" class
        if (referenceImage == null){
            throw new Error('reference image not set');
        }
    }
}