|
1987 | 1987 | }; |
1988 | 1988 | var _ = (a, c, m, l, s, h, f, b) => (o(isFinite(a), "colrect: 1st param must be a number"), o(isFinite(c), "colrect: 2nd param must be a number"), o(isFinite(m), "colrect: 3rd param must be a number"), o(isFinite(l), "colrect: 4th param must be a number"), o(isFinite(s), "colrect: 5th param must be a number"), o(isFinite(h), "colrect: 6th param must be a number"), o(isFinite(f), "colrect: 7th param must be a number"), o(isFinite(b), "colrect: 8th param must be a number"), a < s + f && a + m > s && c < h + b && c + l > h); |
1989 | 1989 | var x = (a, c, m, l, s, h) => (o(isFinite(a), "colcirc: 1st param must be a number"), o(isFinite(c), "colcirc: 2nd param must be a number"), o(isFinite(m), "colcirc: 3rd param must be a number"), o(isFinite(l), "colcirc: 4th param must be a number"), o(isFinite(s), "colcirc: 5th param must be a number"), o(isFinite(h), "colcirc: 6th param must be a number"), (l - a) * (l - a) + (s - c) * (s - c) <= (m + h) * (m + h)); |
1990 | | - var Et = 2 * Math.PI; |
1991 | | - var he = Math.PI / 2; |
1992 | | - var $ = 4, fe = 1 << $, V = 8, de = 1 << V; |
1993 | | - var j = { warnings: true }; |
| 1990 | + var wt = 2 * Math.PI; |
| 1991 | + var oe = Math.PI / 2; |
| 1992 | + var Z = { warnings: true }; |
1994 | 1993 | function g(a, c = {}) { |
1995 | | - if (c = Object.assign({}, j, c), a.stat(1)) throw 'Plugin Migrate should be loaded before the "init" event'; |
| 1994 | + if (c = Object.assign({}, Z, c), a.stat(1)) throw 'Plugin Migrate should be loaded before the "init" event'; |
1996 | 1995 | let l = a.stat(0); |
1997 | 1996 | function s(t, e, r = "") { |
1998 | | - c.warnings && console.warn(`[migrate] ${t} is removed. ` + (e ? `Use ${e} instead. ` : "") + r); |
| 1997 | + c.warnings && console.warn(`[litecanvas/migrate] ${t} is removed. ` + (e ? `Use ${e} instead. ` : "") + r); |
1999 | 1998 | } |
2000 | 1999 | function h(t) { |
2001 | 2000 | return s("seed()", "rseed()"), t && a.rseed(t), a.stat(9); |
|
2005 | 2004 | s("textstyle()", "the 5th param of text()"), f = t; |
2006 | 2005 | } |
2007 | 2006 | let w = a.text; |
2008 | | - function y(t, e, r, i = 3, p = f) { |
| 2007 | + function v(t, e, r, i = 3, p = f) { |
2009 | 2008 | w(t, e, r, i, p); |
2010 | 2009 | } |
2011 | | - function M(t, e, r, i) { |
2012 | | - s("print()", "text()"), y(t, e, r, i); |
| 2010 | + function E(t, e, r, i) { |
| 2011 | + s("print()", "text()"), v(t, e, r, i); |
2013 | 2012 | } |
2014 | | - function E(t, e) { |
| 2013 | + function M(t, e) { |
2015 | 2014 | s("textmetrics()", "ctx().measureText()"); |
2016 | 2015 | let r = a.ctx(), i = a.stat(10), p = a.stat(11); |
2017 | 2016 | r.font = `${f || ""} ${~~(e || i)}px ${p}`; |
2018 | 2017 | let d = r.measureText(t); |
2019 | 2018 | return d.height = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent, d; |
2020 | 2019 | } |
2021 | | - function T(t, e, r, i) { |
| 2020 | + function I(t, e, r, i) { |
2022 | 2021 | s("cliprect()", "clip()"); |
2023 | 2022 | let p = a.ctx(); |
2024 | 2023 | p.beginPath(), p.rect(t, e, r, i), p.clip(); |
|
2028 | 2027 | let i = a.ctx(); |
2029 | 2028 | i.beginPath(), i.arc(t, e, r, 0, a.TWO_PI), i.clip(); |
2030 | 2029 | } |
2031 | | - function C(t) { |
| 2030 | + function T(t) { |
2032 | 2031 | s("getcolor()", "stat(5)"); |
2033 | 2032 | let e = stat(5); |
2034 | 2033 | return e[~~t % e.length]; |
2035 | 2034 | } |
2036 | | - function k(t) { |
| 2035 | + function P(t) { |
2037 | 2036 | s("blendmode()", "ctx().globalCompositeOperation"); |
2038 | 2037 | let e = a.ctx(); |
2039 | 2038 | e.globalCompositeOperation = t; |
2040 | 2039 | } |
2041 | | - function I(t) { |
| 2040 | + function R(t) { |
2042 | 2041 | s("clear()", "cls()"), a.cls(t); |
2043 | 2042 | } |
2044 | | - function S(t, e, r, i, p, d, B = true) { |
2045 | | - return s("transform()", "ctx().setTransform() or ctx().transform()"), a.ctx()[B ? "setTransform" : "transform"](t, e, r, i, p, d); |
| 2043 | + function C(t, e, r, i, p, d, D = true) { |
| 2044 | + return s("transform()", "ctx().setTransform() or ctx().transform()"), a.ctx()[D ? "setTransform" : "transform"](t, e, r, i, p, d); |
2046 | 2045 | } |
2047 | | - function P() { |
| 2046 | + function S() { |
2048 | 2047 | return s("mousepos()", "MX and MY"), [MX, MY]; |
2049 | 2048 | } |
2050 | | - function O(t) { |
| 2049 | + function k(t) { |
2051 | 2050 | s("setfps()", "framerate()"), a.framerate(t); |
2052 | 2051 | } |
2053 | 2052 | let n = a.def; |
|
2089 | 2088 | function L(t, e) { |
2090 | 2089 | s("setvar()", "def()"), u(t, e); |
2091 | 2090 | } |
2092 | | - a.listen("resized", v); |
2093 | | - function v() { |
| 2091 | + a.listen("resized", y); |
| 2092 | + function y() { |
2094 | 2093 | u("CX", a.W / 2), u("CY", a.H / 2); |
2095 | 2094 | } |
2096 | | - v(), u("CANVAS", a.canvas()); |
2097 | | - function R(t, e) { |
| 2095 | + y(), u("CANVAS", a.canvas()); |
| 2096 | + function N(t, e) { |
2098 | 2097 | if (l.autoscale) throw "resize() don't works with autoscale enabled"; |
2099 | 2098 | 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); |
2100 | 2099 | } |
|
2103 | 2102 | let t = stat(5); |
2104 | 2103 | a.CANVAS.style.backgroundColor = t[~~l.background % t.length]; |
2105 | 2104 | } |
2106 | | - function F(t) { |
| 2105 | + function O(t) { |
2107 | 2106 | return s("path()", "`new Path2D`", "See https://developer.mozilla.org/en-US/docs/Web/API/Path2D"), new Path2D(t); |
2108 | 2107 | } |
2109 | 2108 | let z = a.fill; |
2110 | | - function N(t, e) { |
| 2109 | + function F(t, e) { |
2111 | 2110 | if (e instanceof Path2D) { |
2112 | 2111 | s("fill(color, path)"); |
2113 | 2112 | let r = a.stat(5), i = a.ctx(); |
|
2122 | 2121 | i.strokeStyle = r[~~t % r.length], a.ctx().stroke(e); |
2123 | 2122 | } else Y(t); |
2124 | 2123 | } |
2125 | | - let X = a.clip; |
2126 | | - 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) : X(t); |
| 2124 | + let W = a.clip; |
| 2125 | + function B(t) { |
| 2126 | + s("clip(path)", "clip(callback)", "E.g: `clip((ctx) => ctx.rect(0, 0, 200, 200))`"), t instanceof Path2D ? a.ctx().clip(t) : W(t); |
2128 | 2127 | } |
2129 | | - 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 }; |
| 2128 | + return l.antialias && s('"antialias" option', '"pixelart" option'), { def: u, seed: h, print: E, clear: R, setfps: k, setvar: L, textstyle: b, textmetrics: M, text: v, cliprect: I, clipcirc: A, blendmode: P, transform: C, getcolor: T, mousepos: S, resize: N, path: O, fill: F, stroke: H, clip: B, colrect: _, colcirc: x }; |
2130 | 2129 | } |
2131 | 2130 | window.pluginMigrate = g; |
2132 | 2131 | })(); |
|
2249 | 2248 | })(); |
2250 | 2249 | /*! @litecanvas/utils by Luiz Bills | MIT Licensed */ |
2251 | 2250 | /*! Asset Loader plugin for litecanvas by Luiz Bills | MIT Licensed */ |
2252 | | -/*! pluginMigrate for litecanvas by Luiz Bills | MIT Licensed */ |
| 2251 | +/*! Migrate for litecanvas by Luiz Bills | MIT Licensed */ |
2253 | 2252 | /*! pluginFrameRateMeter for litecanvas by Luiz Bills | MIT Licensed */ |
2254 | 2253 | /*! Plugin Pixel Font for litecanvas by Luiz Bills | MIT Licensed */ |
0 commit comments