Skip to content

canvas is weirdly resized upon window resize #1231

@hornta

Description

@hornta

The canvas is weirdly resized upon resizing the browser window. I noticed it when I alt+tabbed between my IDE and the browser, the canvas slowly get larger.

import { Text, device, game, video } from 'melonjs';

device.onReady(function () {
  // initialize the display canvas once the device/browser is ready
  if (!video.init(100, 30, {parent : "screen", scale : "auto"})) {
      alert("Your browser does not support HTML5 canvas.");
      return;
  }

  // set a gray background color
  game.world.backgroundColor.parseCSS("#202020");

  // add a font text display object
  game.world.addChild(new Text(609, 281, {
      font: "Arial",
      size: 160,
      fillStyle: "#FFFFFF",
      textBaseline : "middle",
      textAlign : "center",
      text : "Hello World !"
  }));
});

9db458ca-162c-47db-acd3-f766e4c1ddcc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions