Calla-Site/wwwroot/scripts/game.js
/**
     * Render the avatar at a certain size.
     * @param {CanvasRenderingContext2D} g - the context to render to
     * @param {number} width - the width the avatar should be rendered at
     * @param {number} height - the height the avatar should be rendered at.
     * @param {boolean} isMe - whether the avatar is the local user
     */
Render the avatar at a certain size.
@param {CanvasRenderingContext2D} g - the context to render to
@param {number} width - the width the avatar should be rendered at
@param {number} height - the height the avatar should be rendered at.
@param {boolean} isMe - whether the avatar is the local user
Render the avatar at a certain size . @param { CanvasRenderingContext2D } g - the context to render to @param { number } width - the width the avatar should be rendered at @param { number } height - the height the avatar should be rendered at . @param { boolean } isMe - whether the avatar is the local user
draw(g, width, height, isMe) {
        if (this.video.videoWidth > 0
            && this.video.videoHeight > 0) {
            const offset = (this.video.videoWidth - this.video.videoHeight) / 2,
                sx = Math.max(0, offset),
                sy = Math.max(0, -offset),
                dim = Math.min(this.video.videoWidth, this.video.videoHeight);
            setContextSize(this.g, dim, dim);
            this.g.save();
            if (isMe) {
                this.g.translate(dim, 0);
                this.g.scale(-1, 1);
            }
            this.g.drawImage(
                this.video,
                sx, sy,
                dim, dim,
                0, 0,
                dim, dim);
            this.g.restore();
        }
        super.draw(g, width, height, isMe);
    }
draw ( g , width , height , isMe ) { if ( this . video . videoWidth > 0 && this . video . videoHeight > 0 ) { const offset = ( this . video . videoWidth - this . video . videoHeight ) / 2 , sx = Math . max ( 0 , offset ) , sy = Math . max ( 0 , - offset ) , dim = Math . min ( this . video . videoWidth , this . video . videoHeight ) ; setContextSize ( this . g , dim , dim ) ; this . g . save ( ) ; if ( isMe ) { this . g . translate ( dim , 0 ) ; this . g . scale ( - 1 , 1 ) ; } this . g . drawImage ( this . video , sx , sy , dim , dim , 0 , 0 , dim , dim ) ; this . g . restore ( ) ; } super . draw ( g , width , height , isMe ) ; }
Render the avatar at a certain size.
Render the avatar at a certain size .