Another scale method (original for engine)

This commit is contained in:
OleSTEEP 2024-02-08 22:28:11 +03:00
parent a673524ec3
commit 99631a6d08
2 changed files with 20 additions and 24 deletions

View file

@ -148,18 +148,16 @@ document.addEventListener("backbutton", function(event){
// ===================== // =====================
document.addEventListener("deviceready", () => { document.addEventListener("deviceready", () => {
Graphics._centerElement = function (element) { Graphics._updateRealScale = function () {
console.log("Element centered!!!"); if (this._stretchEnabled) {
var width = 640 * (window.screen.height / 480); var h = window.innerWidth / this._width;
var height = window.screen.height; var v = window.innerHeight / this._height;
element.style.position = 'absolute'; if (h >= 1 && h - 0.01 <= 1) h = 1;
element.style.margin = 'auto'; if (v >= 1 && v - 0.01 <= 1) v = 1;
element.style.top = 0; this._realScale = Math.min(h, v);
element.style.left = 0; } else {
element.style.right = 0; this._realScale = this._scale;
element.style.bottom = 0; }
element.style.width = width + 'px';
element.style.height = height + 'px';
}; };
}) })

View file

@ -148,18 +148,16 @@ document.addEventListener("backbutton", function(event){
// ===================== // =====================
document.addEventListener("deviceready", () => { document.addEventListener("deviceready", () => {
Graphics._centerElement = function (element) { Graphics._updateRealScale = function () {
console.log("Element centered!!!"); if (this._stretchEnabled) {
var width = 640 * (window.screen.height / 480); var h = window.innerWidth / this._width;
var height = window.screen.height; var v = window.innerHeight / this._height;
element.style.position = 'absolute'; if (h >= 1 && h - 0.01 <= 1) h = 1;
element.style.margin = 'auto'; if (v >= 1 && v - 0.01 <= 1) v = 1;
element.style.top = 0; this._realScale = Math.min(h, v);
element.style.left = 0; } else {
element.style.right = 0; this._realScale = this._scale;
element.style.bottom = 0; }
element.style.width = width + 'px';
element.style.height = height + 'px';
}; };
}) })