Skip to content

Commit c6a3986

Browse files
committed
update engine and plugins
1 parent 10a454f commit c6a3986

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

public/litecanvas.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
var assert = (condition, message = "Assertion failed") => {
2828
if (!condition) throw new Error(message);
2929
};
30-
var version = "0.89.2";
30+
var version = "0.90.0";
3131
function litecanvas(settings = {}) {
3232
const root = window, math = Math, TWO_PI = math.PI * 2, raf = requestAnimationFrame, _browserEventListeners = [], on = (elem, evt, callback) => {
3333
elem.addEventListener(evt, callback, false);
@@ -1341,11 +1341,13 @@
13411341
_canvas.width = width;
13421342
_canvas.height = height;
13431343
if (settings.autoscale) {
1344+
let maxScale = +settings.autoscale;
13441345
if (!_canvas.style.display) {
13451346
_canvas.style.display = "block";
13461347
_canvas.style.margin = "auto";
13471348
}
13481349
_scale = math.min(root.innerWidth / width, root.innerHeight / height);
1350+
_scale = maxScale > 1 && _scale > maxScale ? maxScale : _scale;
13491351
_scale = (settings.pixelart ? ~~_scale : _scale) || 1;
13501352
_canvas.style.width = width * _scale + "px";
13511353
_canvas.style.height = height * _scale + "px";
@@ -1995,7 +1997,7 @@
19951997
if (c = Object.assign({}, j, c), a.stat(1)) throw 'Plugin Migrate should be loaded before the "init" event';
19961998
let l = a.stat(0);
19971999
function s(t, e, r = "") {
1998-
c.warnings && console.warn(`[Migrate] warning: ${t} is removed. ` + (e ? `Use ${e} instead. ` : "") + r);
2000+
c.warnings && console.warn(`[migrate] ${t} is removed. ` + (e ? `Use ${e} instead. ` : "") + r);
19992001
}
20002002
function h(t) {
20012003
return s("seed()", "rseed()"), t && a.rseed(t), a.stat(9);
@@ -2086,47 +2088,47 @@
20862088
break;
20872089
}
20882090
}
2089-
function R(t, e) {
2091+
function L(t, e) {
20902092
s("setvar()", "def()"), u(t, e);
20912093
}
20922094
a.listen("resized", v);
20932095
function v() {
20942096
u("CX", a.W / 2), u("CY", a.H / 2);
20952097
}
20962098
v(), u("CANVAS", a.canvas());
2097-
function F(t, e) {
2099+
function R(t, e) {
20982100
if (l.autoscale) throw "resize() don't works with autoscale enabled";
20992101
s("resize()", null, "Avoid changing the canvas dimensions at runtime."), a.CANVAS.width = t, u("W", t), u("CX", t / 2), a.CANVAS.height = e, u("H", e), u("CY", e / 2), a.emit("resized", 1);
21002102
}
21012103
for (let t of ["W", "H", "T", "CX", "CY", "MX", "MY"]) a[t] != null && u(t, a[t]);
2102-
if (s("FPS", "some library to measure the FPS", "Recommendation: https://github.com/mrdoob/stats.js/"), n("FPS", ""), l.fps && a.framerate(l.fps), l.background >= 0) {
2104+
if (s("FPS", "", "but you can use our plugin to measure the fps: https://github.com/litecanvas/plugin-frame-rate-meter"), n("FPS", ""), l.fps && a.framerate(l.fps), l.background >= 0) {
21032105
let t = stat(5);
21042106
a.CANVAS.style.backgroundColor = t[~~l.background % t.length];
21052107
}
2106-
function L(t) {
2108+
function F(t) {
21072109
return s("path()", "`new Path2D`", "See https://developer.mozilla.org/en-US/docs/Web/API/Path2D"), new Path2D(t);
21082110
}
2109-
let Y = a.fill;
2110-
function z(t, e) {
2111+
let z = a.fill;
2112+
function N(t, e) {
21112113
if (e instanceof Path2D) {
21122114
s("fill(color, path)");
21132115
let r = a.stat(5), i = a.ctx();
21142116
i.fillStyle = r[~~t % r.length], a.ctx().fill(e);
2115-
} else Y(t);
2117+
} else z(t);
21162118
}
2117-
let N = a.stroke;
2118-
function X(t, e) {
2119+
let Y = a.stroke;
2120+
function H(t, e) {
21192121
if (e instanceof Path2D) {
21202122
s("stroke(color, path)");
21212123
let r = a.stat(5), i = a.ctx();
21222124
i.strokeStyle = r[~~t % r.length], a.ctx().stroke(e);
2123-
} else N(t);
2125+
} else Y(t);
21242126
}
2125-
let H = a.clip;
2127+
let X = a.clip;
21262128
function D(t) {
2127-
s("clip(path)", "clip(callback)", "E.g: `clip((ctx) => ctx.rect(0, 0, 200, 200))`"), t instanceof Path2D ? a.ctx().clip(t) : H(t);
2129+
s("clip(path)", "clip(callback)", "E.g: `clip((ctx) => ctx.rect(0, 0, 200, 200))`"), t instanceof Path2D ? a.ctx().clip(t) : X(t);
21282130
}
2129-
return { def: u, seed: h, print: M, clear: I, setfps: O, setvar: R, textstyle: b, textmetrics: E, text: y, cliprect: T, clipcirc: A, blendmode: k, transform: S, getcolor: C, mousepos: P, resize: F, path: L, fill: z, stroke: X, clip: D, colrect: _, colcirc: x };
2131+
return { def: u, seed: h, print: M, clear: I, setfps: O, setvar: L, textstyle: b, textmetrics: E, text: y, cliprect: T, clipcirc: A, blendmode: k, transform: S, getcolor: C, mousepos: P, resize: R, path: F, fill: N, stroke: H, clip: D, colrect: _, colcirc: x };
21302132
}
21312133
window.pluginMigrate = g;
21322134
})();
@@ -2213,7 +2215,7 @@
22132215
function o(e, y = {}) {
22142216
let p = e.text, f = e.textsize, b = e.textalign, d = { chars: u, first: 33, size: 8 }, n = 1, t = null, v = (a) => {
22152217
n = Math.round(a / t.size);
2216-
}, h = () => console.warn("textalign() xxx has not yet been implemented for pixel font"), g = (a, c, x, l = 3) => {
2218+
}, h = () => console.warn("textalign() has not yet been implemented for pixel font"), g = (a, c, x, l = 3) => {
22172219
let m = x.charCodeAt(0), r = t.chars[m - t.first];
22182220
if (r) for (let s = 0; s < t.size; s++) for (let i = 0; i < t.size; i++) (r[s] | 0) & 1 << i && e.rectfill(a + i * n, c + s * n, n, n, l);
22192221
}, w = (a, c, x, l = 3) => {

public/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const cacheName = "luizbills.litecanvas-editor-v1";
2-
const version = "2025.7.7.4";
2+
const version = "2025.7.8.0";
33

44
const precacheResources = [
55
"/",

0 commit comments

Comments
 (0)