leopard-js / leopard

Library for making Scratch-like projects with JavaScript.
https://leopardjs.com
MIT License
136 stars 26 forks source link

Ability to disable Renderer._resize() #147

Closed chadulous closed 1 year ago

chadulous commented 1 year ago

Currently working on a project and i want my canvas element to stay as a square as big as possible but still leave room for the elements on the other side, but whenever i change the height the canvas element immediately goes back to being a rectangle

towerofnix commented 1 year ago

The _resize function doesn't have any specific behavior for making a rectangle, it just tries to respect the stage's width and height properties. Have you tried initially updating the stage's dimensions?

I.e, at the top-level index.js, updating your const stage line like this:

const stage = new Stage({
  costumeNumber: 1, // or whatever

  width: 400,
  height: 400,
});

I haven't worked with the canvas/DOM parts of Leopard in a while, but you will probably have better luck maintaining a square instead of a rectangle this way!