function World(w, h) {
  /**
   * @property {Number} scale
   *   The percent amount (as a fraction) the canvas resolution is linearly
   *   scaled relative to its original size. For example, if the canvas started
   *   at 1024x768 and it is now rendering at 512x384, then the scale will be
   *   0.5. Notice that the number of virtual pixels rendered on the canvas
   *   changes with the square of the scale.
   */
  this.scale = 1;
  /**
   * @property {Number} _actualXscale
   *   The actual amount the width of the canvas is scaled relative to the
   *   display size.
   *
   * This can be different than `this.scale` due to rounding error. This
   * matters when converting document coordinates to canvas coordinates, for
   * example when tracking mouse coordinates.
   * @ignore
   */
  this._actualXscale = 1;
  /**
   * @property {Number} _actualYscale
   *   The actual amount the height of the canvas is scaled relative to the
   *   display size.
   *
   * This can be different than `this.scale` due to rounding error. This
   * matters when converting document coordinates to canvas coordinates, for
   * example when tracking mouse coordinates.
   * @ignore
   */
  this._actualYscale = 1;

  /**
   * @property {Number} width
   *   The width of the world.
   */
  this.width = w || parseInt($canvas.attr('data-worldwidth'), 10) || canvas.width;
  /**
   * @property {Number} height
   *   The height of the world.
   */
  this.height = h || parseInt($canvas.attr('data-worldheight'), 10) || canvas.height;

  /**
   * @property {Number} originalCanvasWidth
   *   The width of the canvas when the world was initialized.
   *
   * This is used to keep the canvas size consistent when scaling resolution.
   * @ignore
   */
  this.originalCanvasWidth = canvas.width;
  /**
   * @property {Number} originalCanvasHeight
   *   The height of the canvas when the world was initialized.
   *
   * This is used to keep the canvas size consistent when scaling resolution.
   * @ignore
   */
  this.originalCanvasHeight = canvas.height;

  /**
   * @property {Number} xOffset
   *   The pixel-offset of what's being displayed in the canvas compared to the
   *   world origin.
   */
  this.xOffset = (this.width - canvas.width)/2;
  /**
   * @property {Number} yOffset
   *   The pixel-offset of what's being displayed in the canvas compared to the
   *   world origin.
   */
  this.yOffset = (this.height - canvas.height)/2;
  context.translate(-this.xOffset, -this.yOffset);

  /**
   * Resize the world to new dimensions.
   *
   * Careful! This will shift the viewport regardless of where the player is.
   * Objects already in the world will retain their coordinates and so may
   * appear in unexpected locations on the screen.
   *
   * @param {Number} newWidth The new width to which to resize the world.
   * @param {Number} newHeight The new height to which to resize the world.
   */
  this.resize = function(newWidth, newHeight) {
    // Try to re-center the offset of the part of the world in the canvas
    // so we're still looking at approximately the same thing.
    var deltaX = (newWidth - this.width) / 2, deltaY = (newHeight - this.height) / 2;
    this.xOffset += deltaX;
    this.yOffset += deltaY;
    context.translate(-deltaX, -deltaY);

    // Change the world dimensions.
    this.width = newWidth;
    this.height = newHeight;

    /**
     * @event resizeWorld
     *   Broadcast that the world size changed so that objects already in the
     *   world or other things that depend on the world size can update their
     *   position or size accordingly.
     * @param {Number} x How far in pixels the viewport shifted horizontally.
     * @param {Number} y How far in pixels the viewport shifted vertically.
     * @param {World} resizedWorld The world that changed size.
     */
    jQuery(document).trigger('resizeWorld', [deltaX, deltaY, this]);
  };

  /**
   * Scale the resolution of the primary canvas.
   *
   * Passing a factor smaller than 1 allows reducing the resolution of the
   * canvas, which should improve performance (since there is less to render in
   * each frame). It does not actually change the size of the canvas on the
   * page; it just scales how big each "pixel" is drawn on the canvas, much
   * like changing the resolution of your monitor does not change its physical
   * size. It is your responsibility to change the size of any fixed-size
   * entities in the world after resizing, if applicable; if you don't do this,
   * calling this function works much like zooming in or out.
   *
   * Note that this method only scales the primary canvas, not any
   * {@link Layer}s that may be drawn onto it. Drawing non-scaled Layers onto a
   * scaled primary canvas will make the result appear scaled, but the spacing
   * may be off depending on how you are positioning the items you are drawing
   * onto the relevant Layers. Of course, you can manually resize your Layers
   * after scaling, or only scale the primary canvas during initalization and
   * then create all Layers subsequently at appropriate sizes, or make Layers
   * be positioned over the canvas using {@link Layer#positionOverCanvas}().
   *
   * You may want to call this in a listener for the
   * {@link global#low_fps Low FPS event}.
   *
   * @param {Number} factor
   *   The percent amount to scale the resolution on each dimension as a
   *   fraction of the <em>original</em> resolution (typically between zero and
   *   one). In other words, if the original resolution is 1024x768, scaling
   *   the resolution by a factor of 0.5 will result in a resolution of 512x384
   *   (showing 25% as many pixels on the screen). If scaled again by a factor
   *   of 2, the result will be 2048x1536. Use the `scale` property to detect
   *   the factor by which the resolution is currently scaled.
   * @param {Number} [x]
   *   The x-coordinate of a location to center the viewport around after
   *   resizing the canvas. A common use is `player.x`. Defaults to centering
   *   around the current view.
   * @param {Number} [y]
   *   The y-coordinate of a location to center the viewport around after
   *   resizing the canvas. A common use is `player.y`. Defaults to centering
   *   around the current view.
   */
  this.scaleResolution = function(factor, x, y) {
    // Define the display size so we can rescale the rendering size
    if (!$canvas.hasClass('canvas-rescaled')) {
      $canvas.css({
        width: canvas.width + 'px',
        height: canvas.height + 'px',
      });
      $canvas.addClass('canvas-rescaled');
    }
    // Default to centering around the current center of the viewport.
    x = x || this.xOffset + canvas.width / 2;
    y = y || this.yOffset + canvas.height / 2;
    // The original canvas size is pre-set using App.setDefaultCanvasSize() so
    // changing the value of the attributes just changes the number of pixels
    // to render. CSS then scales that buffer to the original canvas size.
    canvas.width = Math.round(this.originalCanvasWidth*factor);
    canvas.height = Math.round(this.originalCanvasHeight*factor);
    this._actualXscale = canvas.width / this.originalCanvasWidth;
    this._actualYscale = canvas.height / this.originalCanvasHeight;
    this.xOffset = Math.round(Math.min(this.width - canvas.width, Math.max(0, x - canvas.width / 2)));
    this.yOffset = Math.round(Math.min(this.height - canvas.height, Math.max(0, y - canvas.height / 2)));
    context.translate(-this.xOffset, -this.yOffset);
    this.scale = factor;
    if (!isAnimating()) {
      draw();
    }
  };

  /**
   * Convert a position over the canvas to a position in the world.
   *
   * The canvas position being converted should be in displayed pixels from the
   * upper-left corner of the canvas.
   *
   * This could be useful when placing objects at a given location in the
   * canvas if you need the object to align with something outside of the
   * canvas. (Note that {@link Mouse.Coords} already has worldX() and worldY()
   * methods for representing the mouse position in the world.)
   *
   * @param {Number} x The x-position over the canvas to convert.
   * @param {Number} y The y-position over the canvas to convert.
   *
   * @return {Object}
   *   An object with `x` and `y` properties representing x- and y-coordinates
   *   in the world.
   */
  this.canvasToWorldPosition = function(x, y) {
    return {
      x: x * this._actualXscale + this.xOffset,
      y: y * this._actualYscale + this.yOffset,
    };
  };
  /**
   * Convert a position in the world to a position over the canvas.
   *
   * The returned canvas position will be in displayed pixels from the
   * upper-left corner of the canvas. This is useful when positioning DOM
   * elements over the canvas, for example with
   * {@link App.Utils#positionOverCanvas}.
   *
   * If you instead want the position relative to the rendered canvas, which
   * may be useful for example if you want to transition something from
   * scrolling to fixed position, you should instead use `x - world.xOffset`
   * and `y - world.yOffset`. The difference between displayed and rendered
   * position is only relevant when the canvas has been scaled with
   * {@link World#scaleResolution}, causing the canvas to be rendered at one
   * size and then scaled to another for display using CSS.
   *
   * @param {Number} x The x-position over the canvas to convert.
   * @param {Number} y The y-position over the canvas to convert.
   *
   * @return {Object}
   *   An object with `x` and `y` properties representing x- and y-coordinates
   *   over the canvas.
   */
  this.worldToCanvasPosition = function(x, y) {
    return {
      x: (x - this.xOffset) / this._actualXscale,
      y: (y - this.yOffset) / this._actualYscale,
    };
  };

  /**
   * Center the viewport around a specific location in the world.
   *
   * @param {Number} x The x-coordinate around which to center the viewport.
   * @param {Number} y The y-coordinate around which to center the viewport.
   */
  this.centerViewportAround = function(x, y) {
    var newXOffset = Math.min(this.width - canvas.width, Math.max(0, x - canvas.width / 2)) | 0,
        newYOffset = Math.min(this.height - canvas.height, Math.max(0, y - canvas.height / 2)) | 0,
        deltaX = this.xOffset - newXOffset,
        deltaY = this.yOffset - newYOffset;
    this.xOffset = newXOffset;
    this.yOffset = newYOffset;
    context.translate(deltaX, deltaY);
  };

  /**
   * Determine whether a Box is inside the viewport.
   *
   * To test whether a Box is inside the World, see World#isInWorld().
   *
   * @param {Box} box
   *   The Box object to check for visibility.
   * @param {Boolean} [partial=false]
   *   Indicates whether to consider the Box inside the viewport if it is only
   *   partially inside (true) or fully inside (false).
   *
   * @return {Boolean}
   *   true if the Box is inside the viewport; false otherwise.
   */
  this.isInView = function(box, partial) {
    if (partial) {
      return box.x + box.width > this.xOffset &&
        box.x < this.xOffset + canvas.width &&
        box.y + box.height > this.yOffset &&
        box.y < this.yOffset + canvas.height;
    }
    return box.x > this.xOffset &&
      box.x + box.width < this.xOffset + canvas.width &&
      box.y > this.yOffset &&
      box.y + box.height < this.yOffset + canvas.height;
  };

  /**
   * Determine whether a Box is inside the world.
   *
   * To test whether a Box is inside the viewport, see World#isInView().
   *
   * @param {Box} box
   *   The Box object to check.
   * @param {Boolean} [partial=false]
   *   Indicates whether to consider the box inside the world if it is only
   *   partially inside (true) or fully inside (false).
   *
   * @return {Boolean}
   *   true if the Box is inside the world; false otherwise.
   */
  this.isInWorld = function(box, partial) {
    if (partial) {
      return box.x + box.width >= 0 && box.x <= world.width &&
        box.y + box.height >= 0 && box.y <= world.height;
    }
    return box.x >= 0 && box.x + box.width <= world.width &&
      box.y >= 0 && box.y + box.height <= world.height;
  };
}
/**
 * The World object.
 *
 * The World represents the complete playable game area. Its size can be set
 * explicitly or is automatically determined by the "data-worldwidth" and
 * "data-worldheight" attributes set on the HTML canvas element (with a
 * fallback to the canvas width and height). If the size of the world is larger
 * than the canvas then by default the view of the world will scroll when the
 * {@link global#player player} approaches a side of the canvas.
 *
 * @param {Number} [w]
 *   The width of the world. Defaults to the value of the "data-worldwidth"
 *   attribute on the HTML canvas element, or (if that attribute is not
 *   present) the width of the canvas element.
 * @param {Number} [h]
 *   The height of the world. Defaults to the value of the "data-worldheight"
 *   attribute on the HTML canvas element, or (if that attribute is not
 *   present) the height of the canvas element.
 */
The World object.
The World represents the complete playable game area. Its size can be set
explicitly or is automatically determined by the "data-worldwidth" and
"data-worldheight" attributes set on the HTML canvas element (with a
fallback to the canvas width and height). If the size of the world is larger
than the canvas then by default the view of the world will scroll when the
global#player player approaches a side of the canvas.

@param {Number} [w]
The width of the world. Defaults to the value of the "data-worldwidth"
attribute on the HTML canvas element, or (if that attribute is not
present) the width of the canvas element.
@param {Number} [h]
The height of the world. Defaults to the value of the "data-worldheight"
attribute on the HTML canvas element, or (if that attribute is not
present) the height of the canvas element.
The World object . The World represents the complete playable game area . Its size can be set explicitly or is automatically determined by the " data - worldwidth " and " data - worldheight " attributes set on the HTML canvas element ( with a fallback to the canvas width and height ) . If the size of the world is larger than the canvas then by default the view of the world will scroll when the global#player player approaches a side of the canvas . @param { Number } [ w ] The width of the world . Defaults to the value of the " data - worldwidth " attribute on the HTML canvas element or ( if that attribute is not present ) the width of the canvas element . @param { Number } [ h ] The height of the world . Defaults to the value of the " data - worldheight " attribute on the HTML canvas element or ( if that attribute is not present ) the height of the canvas element .
function World(w, h) {
  this.scale = 1;
  this._actualXscale = 1;
  this._actualYscale = 1;
  this.width = w || parseInt($canvas.attr('data-worldwidth'), 10) || canvas.width;
  this.height = h || parseInt($canvas.attr('data-worldheight'), 10) || canvas.height;
  this.originalCanvasWidth = canvas.width;
  this.originalCanvasHeight = canvas.height;
  this.xOffset = (this.width - canvas.width)/2;
  this.yOffset = (this.height - canvas.height)/2;
  context.translate(-this.xOffset, -this.yOffset);
  this.resize = function(newWidth, newHeight) {
    var deltaX = (newWidth - this.width) / 2, deltaY = (newHeight - this.height) / 2;
    this.xOffset += deltaX;
    this.yOffset += deltaY;
    context.translate(-deltaX, -deltaY);
    this.width = newWidth;
    this.height = newHeight;
    jQuery(document).trigger('resizeWorld', [deltaX, deltaY, this]);
  };
  this.scaleResolution = function(factor, x, y) {
    if (!$canvas.hasClass('canvas-rescaled')) {
      $canvas.css({
        width: canvas.width + 'px',
        height: canvas.height + 'px',
      });
      $canvas.addClass('canvas-rescaled');
    }
    x = x || this.xOffset + canvas.width / 2;
    y = y || this.yOffset + canvas.height / 2;
    canvas.width = Math.round(this.originalCanvasWidth*factor);
    canvas.height = Math.round(this.originalCanvasHeight*factor);
    this._actualXscale = canvas.width / this.originalCanvasWidth;
    this._actualYscale = canvas.height / this.originalCanvasHeight;
    this.xOffset = Math.round(Math.min(this.width - canvas.width, Math.max(0, x - canvas.width / 2)));
    this.yOffset = Math.round(Math.min(this.height - canvas.height, Math.max(0, y - canvas.height / 2)));
    context.translate(-this.xOffset, -this.yOffset);
    this.scale = factor;
    if (!isAnimating()) {
      draw();
    }
  };
  this.canvasToWorldPosition = function(x, y) {
    return {
      x: x * this._actualXscale + this.xOffset,
      y: y * this._actualYscale + this.yOffset,
    };
  };
  this.worldToCanvasPosition = function(x, y) {
    return {
      x: (x - this.xOffset) / this._actualXscale,
      y: (y - this.yOffset) / this._actualYscale,
    };
  };
  this.centerViewportAround = function(x, y) {
    var newXOffset = Math.min(this.width - canvas.width, Math.max(0, x - canvas.width / 2)) | 0,
        newYOffset = Math.min(this.height - canvas.height, Math.max(0, y - canvas.height / 2)) | 0,
        deltaX = this.xOffset - newXOffset,
        deltaY = this.yOffset - newYOffset;
    this.xOffset = newXOffset;
    this.yOffset = newYOffset;
    context.translate(deltaX, deltaY);
  };
  this.isInView = function(box, partial) {
    if (partial) {
      return box.x + box.width > this.xOffset &&
        box.x < this.xOffset + canvas.width &&
        box.y + box.height > this.yOffset &&
        box.y < this.yOffset + canvas.height;
    }
    return box.x > this.xOffset &&
      box.x + box.width < this.xOffset + canvas.width &&
      box.y > this.yOffset &&
      box.y + box.height < this.yOffset + canvas.height;
  };
  this.isInWorld = function(box, partial) {
    if (partial) {
      return box.x + box.width >= 0 && box.x <= world.width &&
        box.y + box.height >= 0 && box.y <= world.height;
    }
    return box.x >= 0 && box.x + box.width <= world.width &&
      box.y >= 0 && box.y + box.height <= world.height;
  };
}
function World ( w , h ) { this . scale = 1 ; this . _actualXscale = 1 ; this . _actualYscale = 1 ; this . width = w || parseInt ( $canvas . attr ( 'data-worldwidth' ) , 10 ) || canvas . width ; this . height = h || parseInt ( $canvas . attr ( 'data-worldheight' ) , 10 ) || canvas . height ; this . originalCanvasWidth = canvas . width ; this . originalCanvasHeight = canvas . height ; this . xOffset = ( this . width - canvas . width ) / 2 ; this . yOffset = ( this . height - canvas . height ) / 2 ; context . translate ( - this . xOffset , - this . yOffset ) ; this . resize = function ( newWidth , newHeight ) { var deltaX = ( newWidth - this . width ) / 2 , deltaY = ( newHeight - this . height ) / 2 ; this . xOffset += deltaX ; this . yOffset += deltaY ; context . translate ( - deltaX , - deltaY ) ; this . width = newWidth ; this . height = newHeight ; jQuery ( document ) . trigger ( 'resizeWorld' , [ deltaX , deltaY , this ] ) ; } ; this . scaleResolution = function ( factor , x , y ) { if ( ! $canvas . hasClass ( 'canvas-rescaled' ) ) { $canvas . css ( { width : canvas . width + 'px' , height : canvas . height + 'px' , } ) ; $canvas . addClass ( 'canvas-rescaled' ) ; } x = x || this . xOffset + canvas . width / 2 ; y = y || this . yOffset + canvas . height / 2 ; canvas . width = Math . round ( this . originalCanvasWidth * factor ) ; canvas . height = Math . round ( this . originalCanvasHeight * factor ) ; this . _actualXscale = canvas . width / this . originalCanvasWidth ; this . _actualYscale = canvas . height / this . originalCanvasHeight ; this . xOffset = Math . round ( Math . min ( this . width - canvas . width , Math . max ( 0 , x - canvas . width / 2 ) ) ) ; this . yOffset = Math . round ( Math . min ( this . height - canvas . height , Math . max ( 0 , y - canvas . height / 2 ) ) ) ; context . translate ( - this . xOffset , - this . yOffset ) ; this . scale = factor ; if ( ! isAnimating ( ) ) { draw ( ) ; } } ; this . canvasToWorldPosition = function ( x , y ) { return { x : x * this . _actualXscale + this . xOffset , y : y * this . _actualYscale + this . yOffset , } ; } ; this . worldToCanvasPosition = function ( x , y ) { return { x : ( x - this . xOffset ) / this . _actualXscale , y : ( y - this . yOffset ) / this . _actualYscale , } ; } ; this . centerViewportAround = function ( x , y ) { var newXOffset = Math . min ( this . width - canvas . width , Math . max ( 0 , x - canvas . width / 2 ) ) | 0 , newYOffset = Math . min ( this . height - canvas . height , Math . max ( 0 , y - canvas . height / 2 ) ) | 0 , deltaX = this . xOffset - newXOffset , deltaY = this . yOffset - newYOffset ; this . xOffset = newXOffset ; this . yOffset = newYOffset ; context . translate ( deltaX , deltaY ) ; } ; this . isInView = function ( box , partial ) { if ( partial ) { return box . x + box . width > this . xOffset && box . x < this . xOffset + canvas . width && box . y + box . height > this . yOffset && box . y < this . yOffset + canvas . height ; } return box . x > this . xOffset && box . x + box . width < this . xOffset + canvas . width && box . y > this . yOffset && box . y + box . height < this . yOffset + canvas . height ; } ; this . isInWorld = function ( box , partial ) { if ( partial ) { return box . x + box . width >= 0 && box . x <= world . width && box . y + box . height >= 0 && box . y <= world . height ; } return box . x >= 0 && box . x + box . width <= world . width && box . y >= 0 && box . y + box . height <= world . height ; } ; }
The World object.
The World object .
/**
   * @property {Number} scale
   *   The percent amount (as a fraction) the canvas resolution is linearly
   *   scaled relative to its original size. For example, if the canvas started
   *   at 1024x768 and it is now rendering at 512x384, then the scale will be
   *   0.5. Notice that the number of virtual pixels rendered on the canvas
   *   changes with the square of the scale.
   */ /**
   * @property {Number} _actualXscale
   *   The actual amount the width of the canvas is scaled relative to the
   *   display size.
   *
   * This can be different than `this.scale` due to rounding error. This
   * matters when converting document coordinates to canvas coordinates, for
   * example when tracking mouse coordinates.
   * @ignore
   */ /**
   * @property {Number} _actualYscale
   *   The actual amount the height of the canvas is scaled relative to the
   *   display size.
   *
   * This can be different than `this.scale` due to rounding error. This
   * matters when converting document coordinates to canvas coordinates, for
   * example when tracking mouse coordinates.
   * @ignore
   */ /**
   * @property {Number} width
   *   The width of the world.
   */ /**
   * @property {Number} height
   *   The height of the world.
   */ /**
   * @property {Number} originalCanvasWidth
   *   The width of the canvas when the world was initialized.
   *
   * This is used to keep the canvas size consistent when scaling resolution.
   * @ignore
   */ /**
   * @property {Number} originalCanvasHeight
   *   The height of the canvas when the world was initialized.
   *
   * This is used to keep the canvas size consistent when scaling resolution.
   * @ignore
   */ /**
   * @property {Number} xOffset
   *   The pixel-offset of what's being displayed in the canvas compared to the
   *   world origin.
   */ /**
   * @property {Number} yOffset
   *   The pixel-offset of what's being displayed in the canvas compared to the
   *   world origin.
   */ /**
   * Resize the world to new dimensions.
   *
   * Careful! This will shift the viewport regardless of where the player is.
   * Objects already in the world will retain their coordinates and so may
   * appear in unexpected locations on the screen.
   *
   * @param {Number} newWidth The new width to which to resize the world.
   * @param {Number} newHeight The new height to which to resize the world.
   */ // Try to re-center the offset of the part of the world in the canvas // so we're still looking at approximately the same thing. // Change the world dimensions. /**
     * @event resizeWorld
     *   Broadcast that the world size changed so that objects already in the
     *   world or other things that depend on the world size can update their
     *   position or size accordingly.
     * @param {Number} x How far in pixels the viewport shifted horizontally.
     * @param {Number} y How far in pixels the viewport shifted vertically.
     * @param {World} resizedWorld The world that changed size.
     */ /**
   * Scale the resolution of the primary canvas.
   *
   * Passing a factor smaller than 1 allows reducing the resolution of the
   * canvas, which should improve performance (since there is less to render in
   * each frame). It does not actually change the size of the canvas on the
   * page; it just scales how big each "pixel" is drawn on the canvas, much
   * like changing the resolution of your monitor does not change its physical
   * size. It is your responsibility to change the size of any fixed-size
   * entities in the world after resizing, if applicable; if you don't do this,
   * calling this function works much like zooming in or out.
   *
   * Note that this method only scales the primary canvas, not any
   * {@link Layer}s that may be drawn onto it. Drawing non-scaled Layers onto a
   * scaled primary canvas will make the result appear scaled, but the spacing
   * may be off depending on how you are positioning the items you are drawing
   * onto the relevant Layers. Of course, you can manually resize your Layers
   * after scaling, or only scale the primary canvas during initalization and
   * then create all Layers subsequently at appropriate sizes, or make Layers
   * be positioned over the canvas using {@link Layer#positionOverCanvas}().
   *
   * You may want to call this in a listener for the
   * {@link global#low_fps Low FPS event}.
   *
   * @param {Number} factor
   *   The percent amount to scale the resolution on each dimension as a
   *   fraction of the <em>original</em> resolution (typically between zero and
   *   one). In other words, if the original resolution is 1024x768, scaling
   *   the resolution by a factor of 0.5 will result in a resolution of 512x384
   *   (showing 25% as many pixels on the screen). If scaled again by a factor
   *   of 2, the result will be 2048x1536. Use the `scale` property to detect
   *   the factor by which the resolution is currently scaled.
   * @param {Number} [x]
   *   The x-coordinate of a location to center the viewport around after
   *   resizing the canvas. A common use is `player.x`. Defaults to centering
   *   around the current view.
   * @param {Number} [y]
   *   The y-coordinate of a location to center the viewport around after
   *   resizing the canvas. A common use is `player.y`. Defaults to centering
   *   around the current view.
   */ // Define the display size so we can rescale the rendering size // Default to centering around the current center of the viewport. // The original canvas size is pre-set using App.setDefaultCanvasSize() so // changing the value of the attributes just changes the number of pixels // to render. CSS then scales that buffer to the original canvas size. /**
   * Convert a position over the canvas to a position in the world.
   *
   * The canvas position being converted should be in displayed pixels from the
   * upper-left corner of the canvas.
   *
   * This could be useful when placing objects at a given location in the
   * canvas if you need the object to align with something outside of the
   * canvas. (Note that {@link Mouse.Coords} already has worldX() and worldY()
   * methods for representing the mouse position in the world.)
   *
   * @param {Number} x The x-position over the canvas to convert.
   * @param {Number} y The y-position over the canvas to convert.
   *
   * @return {Object}
   *   An object with `x` and `y` properties representing x- and y-coordinates
   *   in the world.
   */ /**
   * Convert a position in the world to a position over the canvas.
   *
   * The returned canvas position will be in displayed pixels from the
   * upper-left corner of the canvas. This is useful when positioning DOM
   * elements over the canvas, for example with
   * {@link App.Utils#positionOverCanvas}.
   *
   * If you instead want the position relative to the rendered canvas, which
   * may be useful for example if you want to transition something from
   * scrolling to fixed position, you should instead use `x - world.xOffset`
   * and `y - world.yOffset`. The difference between displayed and rendered
   * position is only relevant when the canvas has been scaled with
   * {@link World#scaleResolution}, causing the canvas to be rendered at one
   * size and then scaled to another for display using CSS.
   *
   * @param {Number} x The x-position over the canvas to convert.
   * @param {Number} y The y-position over the canvas to convert.
   *
   * @return {Object}
   *   An object with `x` and `y` properties representing x- and y-coordinates
   *   over the canvas.
   */ /**
   * Center the viewport around a specific location in the world.
   *
   * @param {Number} x The x-coordinate around which to center the viewport.
   * @param {Number} y The y-coordinate around which to center the viewport.
   */ /**
   * Determine whether a Box is inside the viewport.
   *
   * To test whether a Box is inside the World, see World#isInWorld().
   *
   * @param {Box} box
   *   The Box object to check for visibility.
   * @param {Boolean} [partial=false]
   *   Indicates whether to consider the Box inside the viewport if it is only
   *   partially inside (true) or fully inside (false).
   *
   * @return {Boolean}
   *   true if the Box is inside the viewport; false otherwise.
   */ /**
   * Determine whether a Box is inside the world.
   *
   * To test whether a Box is inside the viewport, see World#isInView().
   *
   * @param {Box} box
   *   The Box object to check.
   * @param {Boolean} [partial=false]
   *   Indicates whether to consider the box inside the world if it is only
   *   partially inside (true) or fully inside (false).
   *
   * @return {Boolean}
   *   true if the Box is inside the world; false otherwise.
   */