static/src/whiteboard.js
/**
     * Add new lines from a JSON string
     * 
     * @param {data} - The JSON string storing an Array of lines to add
     */
Add new lines from a JSON string

@param {data} - The JSON string storing an Array of lines to add
Add new lines from a JSON string @param { data } - The JSON string storing an Array of lines to add
addLines(data){
        var lines = JSON.parse(data);
        for (let line of lines){
            let type = line[0];
            var points = [];
            for (let point of line[1]){
                points.push(new Pos(point[0], point[1]));
            }
            if(type == 'ERASE'){
                this.smoothDraw(this.ctx, 'destination-out', points, 25);
                this.smoothDraw(this.memCtx, 'destination-out', points, 25);
            }else if(type == 'DRAW'){
                let color = line[2];
                this.smoothDraw(this.ctx, 'source-over', points, 6, color);
                this.smoothDraw(this.memCtx, 'source-over', points, 6, color);
            }
        }
        this.waiting_for_server = false;
    }
addLines ( data ) { var lines = JSON . parse ( data ) ; for ( let line of lines ) { let type = line [ 0 ] ; var points = [ ] ; for ( let point of line [ 1 ] ) { points . push ( new Pos ( point [ 0 ] , point [ 1 ] ) ) ; } if ( type == 'ERASE' ) { this . smoothDraw ( this . ctx , 'destination-out' , points , 25 ) ; this . smoothDraw ( this . memCtx , 'destination-out' , points , 25 ) ; } else if ( type == 'DRAW' ) { let color = line [ 2 ] ; this . smoothDraw ( this . ctx , 'source-over' , points , 6 , color ) ; this . smoothDraw ( this . memCtx , 'source-over' , points , 6 , color ) ; } } this . waiting_for_server = false ; }
Add new lines from a JSON string
Add new lines from a JSON string