|
1970 | 1970 | window.pluginMigrate = p; |
1971 | 1971 | })(); |
1972 | 1972 | (() => { |
1973 | | - function A() { |
1974 | | - let o = 0, a = true, i = document.createElement("div"), r = [], p = () => (performance || Date).now(); |
| 1973 | + function _() { |
| 1974 | + let u = 0, a = true, i = document.createElement("div"), r = [], p = () => (performance || Date).now(); |
1975 | 1975 | i.style.cssText = "position:absolute;top:0;right:0;cursor:pointer;opacity:0.8;z-index:10000", i.addEventListener("click", function(e) { |
1976 | | - e.preventDefault(), l(++o % i.children.length); |
| 1976 | + e.preventDefault(), o(++u % i.children.length); |
1977 | 1977 | }, false); |
1978 | | - function u(e, n, _, t) { |
1979 | | - let w = new P(e, n, _, i, t); |
| 1978 | + function l(e, n, v, t) { |
| 1979 | + let w = new P(e, n, v, i, t); |
1980 | 1980 | return r.push(w), w; |
1981 | 1981 | } |
1982 | | - function l(e) { |
| 1982 | + function o(e) { |
1983 | 1983 | for (let n = 0; n < i.children.length; n++) i.children[n].style.display = n === e ? "block" : "none"; |
1984 | | - o = e; |
| 1984 | + u = e; |
1985 | 1985 | } |
1986 | 1986 | function f() { |
1987 | | - o++, o >= i.children.length && (o = 0), l(o); |
| 1987 | + u++, u >= i.children.length && (u = 0), o(u); |
1988 | 1988 | } |
1989 | 1989 | function s(e = "all") { |
1990 | 1990 | if (e === "all") for (let n = 0; n < r.length; n++) r[n].reset(); |
|
1994 | 1994 | function g(e = true) { |
1995 | 1995 | a = !!e, i.style.display = a ? "" : "none"; |
1996 | 1996 | } |
1997 | | - let b = p(), h = b, y2 = 0, c = u("FPS", "#0ff", "#002"), d = u("MS", "#0f0", "#020"), m; |
1998 | | - return self.performance && self.performance.memory && (m = u("MB", "#f08", "#201")), l(0), { dom: i, addPanel: u, showPanel: l, nextPanel: f, resetPanel: s, display: g, get hidden() { |
| 1997 | + let b = p(), h = b, y2 = 0, c = l("FPS", "#0ff", "#002"), d = l("MS", "#0f0", "#020"), m; |
| 1998 | + return self.performance && self.performance.memory && (m = l("MB", "#f08", "#201")), o(0), { dom: i, addPanel: l, showPanel: o, nextPanel: f, resetPanel: s, display: g, get hidden() { |
1999 | 1999 | return !a; |
2000 | 2000 | }, begin: function() { |
2001 | 2001 | b = p(); |
|
2011 | 2011 | b = this.end(); |
2012 | 2012 | } }; |
2013 | 2013 | } |
2014 | | - function P(o, a, i, r, p = {}) { |
2015 | | - let u = Math.round, l = 1 / 0, f = 0, s = u(window.devicePixelRatio || 1), g = (p.width || 80) * s, b = 48 * s, h = 3 * s, y2 = 2 * s, c = 3 * s, d = 15 * s, m = (g - 6) * s, e = 30 * s, n = document.createElement("canvas"); |
| 2014 | + function P(u, a, i, r, p = {}) { |
| 2015 | + let l = Math.round, o = 1 / 0, f = 0, s = l(window.devicePixelRatio || 1), g = (p.width || 80) * s, b = 48 * s, h = 3 * s, y2 = 2 * s, c = 3 * s, d = 15 * s, m = (g - 6) * s, e = 30 * s, n = document.createElement("canvas"); |
2016 | 2016 | n.width = g, n.height = b; |
2017 | | - let _ = r.children.length; |
| 2017 | + let v = r.children.length; |
2018 | 2018 | r.appendChild(n); |
2019 | 2019 | let t = n.getContext("2d"); |
2020 | 2020 | t.font = "bold " + 9 * s + "px Helvetica,Arial,sans-serif", t.textBaseline = "top"; |
2021 | 2021 | function w() { |
2022 | | - t.fillStyle = i, t.fillRect(0, 0, g, b), t.fillStyle = a, t.fillText(o, h, y2), t.fillRect(c, d, m, e), t.fillStyle = i, t.globalAlpha = 0.9, t.fillRect(c, d, m, e); |
| 2022 | + t.fillStyle = i, t.fillRect(0, 0, g, b), t.fillStyle = a, t.fillText(u, h, y2), t.fillRect(c, d, m, e), t.fillStyle = i, t.globalAlpha = 0.9, t.fillRect(c, d, m, e); |
2023 | 2023 | } |
2024 | | - return w(), { id: _, dom: n, reset: w, update: function(x2, E) { |
2025 | | - l = Math.min(l, x2), f = Math.max(f, x2), t.fillStyle = i, t.globalAlpha = 1, t.fillRect(0, 0, g, d), t.fillStyle = a; |
2026 | | - let T = [u(x2), o]; |
2027 | | - p.labelBefore && T.reverse(), t.fillText(T.join(" ") + " (" + u(l) + "-" + u(f) + ")", h, y2), t.drawImage(n, c + s, d, m - s, e, c, d, m - s, e), t.fillRect(c + m - s, d, s, e), t.fillStyle = i, t.globalAlpha = 0.9, t.fillRect(c + m - s, d, s, u((1 - x2 / E) * e)); |
| 2024 | + return w(), { id: v, dom: n, reset: w, update: function(x2, E) { |
| 2025 | + o = Math.min(o, x2), f = Math.max(f, x2), t.fillStyle = i, t.globalAlpha = 1, t.fillRect(0, 0, g, d), t.fillStyle = a; |
| 2026 | + let T = [l(x2), u]; |
| 2027 | + p.labelBefore && T.reverse(), t.fillText(T.join(" ") + " (" + l(o) + "-" + l(f) + ")", h, y2), t.drawImage(n, c + s, d, m - s, e, c, d, m - s, e), t.fillRect(c + m - s, d, s, e), t.fillStyle = i, t.globalAlpha = 0.9, t.fillRect(c + m - s, d, s, l((1 - x2 / E) * e)); |
2028 | 2028 | } }; |
2029 | 2029 | } |
2030 | 2030 | var S = { hotkeyShow: "F1", hotkeyNext: "F2", css: {}, hidden: false, id: "" }; |
2031 | | - function v(o, a = {}) { |
| 2031 | + function A(u, a = {}) { |
2032 | 2032 | a = Object.assign({}, S, a); |
2033 | | - let i = o.stat(0), r = new A(), p = r.display, u = (l = true) => { |
2034 | | - console.log("display", l), a.hidden = !l, p(l), r.resetPanel(); |
| 2033 | + let i = u.stat(0), r = new _(), p = r.display, l = (o = true) => { |
| 2034 | + a.hidden = !o, p(o), r.resetPanel(); |
2035 | 2035 | }; |
2036 | 2036 | a.id && (r.dom.id = a.id); |
2037 | | - for (let [l, f] of Object.entries(a.css || {})) r.dom.style[l] = f; |
2038 | | - return o.CANVAS.parentElement.appendChild(r.dom), u(!a.hidden), i.keyboardEvents && listen("update", () => { |
2039 | | - a.hotkeyShow && o.iskeypressed(a.hotkeyShow) && u(a.hidden), a.hotkeyNext && o.iskeypressed(a.hotkeyNext) && r.nextPanel(); |
2040 | | - }), listen("before:update", (l, f = 1) => { |
| 2037 | + for (let [o, f] of Object.entries(a.css || {})) r.dom.style[o] = f; |
| 2038 | + return u.CANVAS.parentElement.appendChild(r.dom), l(!a.hidden), i.keyboardEvents && listen("update", () => { |
| 2039 | + a.hotkeyShow && u.iskeypressed(a.hotkeyShow) && l(a.hidden), a.hotkeyNext && u.iskeypressed(a.hotkeyNext) && r.nextPanel(); |
| 2040 | + }), listen("before:update", (o, f = 1) => { |
2041 | 2041 | a.hidden || f === 1 && r.begin(); |
2042 | 2042 | }), listen("after:draw", () => { |
2043 | 2043 | a.hidden || r.end(); |
2044 | | - }), r.display = u, { FPS_METER: r }; |
| 2044 | + }), r.display = l, { FPS_METER: r }; |
2045 | 2045 | } |
2046 | | - window.pluginFrameRateMeter = v; |
| 2046 | + window.pluginFrameRateMeter = A; |
2047 | 2047 | })(); |
2048 | 2048 | })(); |
2049 | 2049 | /*! @litecanvas/utils by Luiz Bills | MIT Licensed */ |
|
0 commit comments