Skip to content

Commit 6547f8a

Browse files
committed
update fps meter
1 parent 90558e0 commit 6547f8a

File tree

2 files changed

+60
-61
lines changed

2 files changed

+60
-61
lines changed

public/litecanvas.js

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,82 +2137,81 @@
21372137
window.pluginMigrate = v;
21382138
})();
21392139
(() => {
2140-
function _() {
2141-
let i = 0, a = true, l = document.createElement("div"), s = [], c = () => (performance || Date).now();
2142-
l.style.cssText = "position:absolute;top:0;right:0;cursor:pointer;opacity:0.8;z-index:10000", l.addEventListener("click", function(e) {
2143-
e.preventDefault(), m(++i % l.children.length);
2140+
function A(s = {}) {
2141+
let n = 0, o = true, b = s.position, r = document.createElement("div"), i = [], p = () => (performance || Date).now();
2142+
["right", "left"].includes(b) || (b = "right"), r.style.cssText = `position:absolute;top:0;${b}:0;cursor:pointer;opacity:0.8;z-index:10000`, r.addEventListener("click", function(a) {
2143+
a.preventDefault(), e(++n % r.children.length);
21442144
}, false);
2145-
function o(e, r, x, t) {
2146-
let w = new T(e, r, x, l, t);
2147-
return s.push(w), w;
2145+
function f(a, t, x, g) {
2146+
let _ = new S(a, t, x, r, g);
2147+
return i.push(_), _;
21482148
}
2149-
function m(e) {
2150-
for (let r = 0; r < l.children.length; r++) l.children[r].style.display = r === e ? "block" : "none";
2151-
i = e;
2149+
function e(a) {
2150+
for (let t = 0; t < r.children.length; t++) r.children[t].style.display = t === a ? "block" : "none";
2151+
n = a;
21522152
}
2153-
function p() {
2154-
i++, i >= l.children.length && (i = 0), m(i);
2153+
function v() {
2154+
n++, n >= r.children.length && (n = 0), e(n);
21552155
}
2156-
function n(e = "all") {
2157-
if (e === "all") for (let r = 0; r < s.length; r++) s[r].reset();
2158-
else s[e] && s[e].reset();
2159-
h = c(), y = 0;
2156+
function h(a = "all") {
2157+
if (a === "all") for (let t = 0; t < i.length; t++) i[t].reset();
2158+
else i[a] && i[a].reset();
2159+
u = p(), l = 0;
21602160
}
2161-
function b(e = true) {
2162-
a = !!e, l.style.display = a ? "" : "none";
2161+
function d(a = true) {
2162+
o = !!a, r.style.display = o ? "" : "none";
21632163
}
2164-
let v = c(), h = v, y = 0, d = o("FPS", "#0ff", "#002"), f = o("MS", "#0f0", "#020"), u;
2165-
return self.performance && self.performance.memory && (u = o("MB", "#f08", "#201")), m(0), { dom: l, addPanel: o, showPanel: m, nextPanel: p, resetPanel: n, display: b, get hidden() {
2166-
return !a;
2164+
let m = p(), u = m, l = 0, y = f("FPS", "#0ff", "#002"), w = f("MS", "#0f0", "#020"), c;
2165+
return self.performance && self.performance.memory && (c = f("MB", "#f08", "#201")), e(0), { dom: r, addPanel: f, showPanel: e, nextPanel: v, resetPanel: h, display: d, get hidden() {
2166+
return !o;
21672167
}, begin: function() {
2168-
v = c();
2168+
m = p();
21692169
}, end: function() {
2170-
y++;
2171-
let e = c();
2172-
if (f.update(e - v, 200), e >= h + 1e3 && (d.update(y * 1e3 / (e - h), 100), h = e, y = 0, u)) {
2173-
let r = performance.memory;
2174-
u.update(r.usedJSHeapSize / 1048576, r.jsHeapSizeLimit / 1048576);
2170+
l++;
2171+
let a = p();
2172+
if (w.update(a - m, 200), a >= u + 1e3 && (y.update(l * 1e3 / (a - u), 100), u = a, l = 0, c)) {
2173+
let t = performance.memory;
2174+
c.update(t.usedJSHeapSize / 1048576, t.jsHeapSizeLimit / 1048576);
21752175
}
2176-
return e;
2176+
return a;
21772177
}, update: function() {
2178-
v = this.end();
2178+
m = this.end();
21792179
} };
21802180
}
2181-
function T(i, a, l, s, c = {}) {
2182-
let o = Math.round, m = 1 / 0, p = 0, n = o(window.devicePixelRatio || 1), b = c.width || 80, v = 48, h = 3 * n, y = 2 * n, d = 3 * n, f = 15 * n, u = (b - 6) * n, e = 30 * n, r = document.createElement("canvas");
2183-
r.width = b * n, r.height = v * n, r.style.cssText = `width:${b}px;height:48px;`;
2184-
let x = s.children.length;
2185-
s.appendChild(r);
2186-
let t = r.getContext("2d");
2187-
t.font = `bold ${9 * n}px Helvetica,Arial,sans-serif`, t.textBaseline = "top";
2188-
function w() {
2189-
t.fillStyle = l, t.fillRect(0, 0, b * n, v * n), t.fillStyle = a, t.fillText(i, h, y), t.fillRect(d, f, u, e), t.fillStyle = l, t.globalAlpha = 0.9, t.fillRect(d, f, u, e);
2190-
}
2191-
return w(), { id: x, dom: r, reset: w, update: function(g, S) {
2192-
m = Math.min(m, g), p = Math.max(p, g), t.fillStyle = l, t.globalAlpha = 1, t.fillRect(0, 0, b * n, f), t.fillStyle = a;
2193-
let E = [o(g), i];
2194-
c.labelBefore && E.reverse(), t.fillText(E.join(" ") + " (" + o(m) + "-" + o(p) + ")", h, y), t.drawImage(r, d + n, f, u - n, e, d, f, u - n, e), t.fillRect(d + u - n, f, n, e), t.fillStyle = l, t.globalAlpha = 0.9, t.fillRect(d + u - n, f, n, o((1 - g / S) * e));
2181+
function S(s, n, o, b, r = {}) {
2182+
let i = Math.round, p = 1 / 0, f = 0, e = i(window.devicePixelRatio || 1), v = r.width || 80, h = 48, d = 3 * e, m = 2 * e, u = 3 * e, l = 15 * e, y = (v - 6) * e, w = 30 * e, c = document.createElement("canvas");
2183+
c.width = v * e, c.height = h * e, c.style.cssText = `width:${v}px;height:48px;`;
2184+
let a = b.children.length;
2185+
b.appendChild(c);
2186+
let t = c.getContext("2d");
2187+
t.font = `bold ${9 * e}px Helvetica,Arial,sans-serif`, t.textBaseline = "top";
2188+
function x() {
2189+
t.fillStyle = o, t.fillRect(0, 0, v * e, h * e), t.fillStyle = n, t.fillText(s, d, m), t.fillRect(u, l, y, w), t.fillStyle = o, t.globalAlpha = 0.9, t.fillRect(u, l, y, w);
2190+
}
2191+
return x(), { id: a, dom: c, reset: x, update: function(g, _) {
2192+
p = Math.min(p, g), f = Math.max(f, g), t.fillStyle = o, t.globalAlpha = 1, t.fillRect(0, 0, v * e, l), t.fillStyle = n;
2193+
let T = [i(g), s];
2194+
r.labelBefore && T.reverse(), t.fillText(T.join(" ") + " (" + i(p) + "-" + i(f) + ")", d, m), t.drawImage(c, u + e, l, y - e, w, u, l, y - e, w), t.fillRect(u + y - e, l, e, w), t.fillStyle = o, t.globalAlpha = 0.9, t.fillRect(u + y - e, l, e, i((1 - g / _) * w));
21952195
} };
21962196
}
2197-
var k = { hotkeyShow: "F1", hotkeyNext: "F2", css: {}, hidden: false, id: "" };
2198-
function A(i, a = {}) {
2199-
a = Object.assign({}, k, a);
2200-
let l = i.stat(0), s = new _(), c = s.display, o = (m = true) => {
2201-
a.hidden = !m, c(m), s.resetPanel();
2197+
var z = { hotkeyShow: "F1", hotkeyNext: "F2", css: {}, hidden: false, id: "", position: "right" };
2198+
function E(s, n = {}) {
2199+
let { hotkeyNext: o, hotkeyShow: b, id: r, position: i, css: p } = Object.assign({}, z, n), f = s.stat(0), e = new A({ position: i }), v = e.display, h = (d = true) => {
2200+
n.hidden = !d, v(d), e.resetPanel();
22022201
};
2203-
a.id && (s.dom.id = a.id);
2204-
for (let [m, p] of Object.entries(a.css || {})) s.dom.style[m] = p;
2205-
return i.canvas().parentElement.appendChild(s.dom), o(!a.hidden), l.keyboardEvents && i.listen("update", () => {
2206-
a.hotkeyShow && i.iskeypressed(a.hotkeyShow) && o(a.hidden), a.hotkeyNext && i.iskeypressed(a.hotkeyNext) && s.nextPanel();
2207-
}), i.listen("before:update", (m, p = 1) => {
2208-
a.hidden || p === 1 && s.begin();
2209-
}), i.listen("after:draw", () => {
2210-
a.hidden || s.end();
2211-
}), i.listen("quit", () => {
2212-
s.dom.remove();
2213-
}), s.display = o, { FPS_METER: s };
2202+
r && (e.dom.id = r);
2203+
for (let [d, m] of Object.entries(p || {})) e.dom.style[d] = m;
2204+
return s.canvas().parentElement.appendChild(e.dom), h(!n.hidden), f.keyboardEvents && s.listen("update", () => {
2205+
b && s.iskeypressed(b) && h(n.hidden), o && s.iskeypressed(o) && e.nextPanel();
2206+
}), s.listen("before:update", (d, m = 1) => {
2207+
n.hidden || m === 1 && e.begin();
2208+
}), s.listen("after:draw", () => {
2209+
n.hidden || e.end();
2210+
}), s.listen("quit", () => {
2211+
e.dom.remove();
2212+
}), e.display = h, { FPS_METER: e };
22142213
}
2215-
window.pluginFrameRateMeter = A;
2214+
window.pluginFrameRateMeter = E;
22162215
})();
22172216
(() => {
22182217
var S = [[24, 60, 60, 24, 24, , 24], [54, 54, , , , , ,], [54, 54, 127, 54, 127, 54, 54], [12, 62, 3, 30, 48, 31, 12], [, 99, 51, 24, 12, 102, 99], [28, 54, 28, 110, 59, 51, 110], [6, 6, 3, , , , ,], [24, 12, 6, 6, 6, 12, 24], [6, 12, 24, 24, 24, 12, 6], [, 102, 60, 255, 60, 102, ,], [, 12, 12, 63, 12, 12, ,], [, , , , , 12, 12, 6], [, , , 63, , , ,], [, , , , , 12, 12], [96, 48, 24, 12, 6, 3, 1], [62, 99, 115, 123, 111, 103, 62], [12, 14, 12, 12, 12, 12, 63], [30, 51, 48, 28, 6, 51, 63], [30, 51, 48, 28, 48, 51, 30], [56, 60, 54, 51, 127, 48, 120], [63, 3, 31, 48, 48, 51, 30], [28, 6, 3, 31, 51, 51, 30], [63, 51, 48, 24, 12, 12, 12], [30, 51, 51, 30, 51, 51, 30], [30, 51, 51, 62, 48, 24, 14], [, 12, 12, , , 12, 12], [, 12, 12, , , 12, 12, 6], [24, 12, 6, 3, 6, 12, 24], [, , 63, , , 63, ,], [6, 12, 24, 48, 24, 12, 6], [30, 51, 48, 24, 12, , 12], [62, 99, 123, 123, 123, 3, 30], [12, 30, 51, 51, 63, 51, 51], [63, 102, 102, 62, 102, 102, 63], [60, 102, 3, 3, 3, 102, 60], [31, 54, 102, 102, 102, 54, 31], [127, 70, 22, 30, 22, 70, 127], [127, 70, 22, 30, 22, 6, 15], [60, 102, 3, 3, 115, 102, 124], [51, 51, 51, 63, 51, 51, 51], [30, 12, 12, 12, 12, 12, 30], [120, 48, 48, 48, 51, 51, 30], [103, 102, 54, 30, 54, 102, 103], [15, 6, 6, 6, 70, 102, 127], [99, 119, 127, 127, 107, 99, 99], [99, 103, 111, 123, 115, 99, 99], [28, 54, 99, 99, 99, 54, 28], [63, 102, 102, 62, 6, 6, 15], [30, 51, 51, 51, 59, 30, 56], [63, 102, 102, 62, 54, 102, 103], [30, 51, 7, 14, 56, 51, 30], [63, 45, 12, 12, 12, 12, 30], [51, 51, 51, 51, 51, 51, 63], [51, 51, 51, 51, 51, 30, 12], [99, 99, 99, 107, 127, 119, 99], [99, 99, 54, 28, 28, 54, 99], [51, 51, 51, 30, 12, 12, 30], [127, 99, 49, 24, 76, 102, 127], [30, 6, 6, 6, 6, 6, 30], [3, 6, 12, 24, 48, 96, 64], [30, 24, 24, 24, 24, 24, 30], [8, 28, 54, 99, , , ,], [, , , , , , , 255], [12, 12, 24, , , , ,], [, , 30, 48, 62, 51, 110], [7, 6, 6, 62, 102, 102, 59], [, , 30, 51, 3, 51, 30], [56, 48, 48, 62, 51, 51, 110], [, , 30, 51, 63, 3, 30], [28, 54, 6, 15, 6, 6, 15], [, , 110, 51, 51, 62, 48, 31], [7, 6, 54, 110, 102, 102, 103], [12, , 14, 12, 12, 12, 30], [48, , 48, 48, 48, 51, 51, 30], [7, 6, 102, 54, 30, 54, 103], [14, 12, 12, 12, 12, 12, 30], [, , 51, 127, 127, 107, 99], [, , 31, 51, 51, 51, 51], [, , 30, 51, 51, 51, 30], [, , 59, 102, 102, 62, 6, 15], [, , 110, 51, 51, 62, 48, 120], [, , 59, 110, 102, 6, 15], [, , 62, 3, 30, 48, 31], [8, 12, 62, 12, 12, 44, 24], [, , 51, 51, 51, 51, 110], [, , 51, 51, 51, 30, 12], [, , 99, 107, 127, 127, 54], [, , 99, 54, 28, 54, 99], [, , 51, 51, 51, 62, 48, 31], [, , 63, 25, 12, 38, 63], [56, 12, 12, 7, 12, 12, 56], [24, 24, 24, , 24, 24, 24], [7, 12, 12, 56, 12, 12, 7], [110, 59, , , , , ,]], w = { id: "basic", chars: S, first: 33, w: 8 };

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.21.2";
2+
const version = "2025.7.21.3";
33

44
const precacheResources = [
55
"/",

0 commit comments

Comments
 (0)