@litecanvas/plugin-migrate 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.js +2 -1
- package/package.json +1 -1
- package/src/index.js +1 -1
package/dist/dist.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
(()=>{var x=(s,c,h,m,n,r,b,f)=>s<n+b&&s+h>n&&c<r+f&&c+m>r;var _=(s,c,h,m,n,r)=>(m-s)*(m-s)+(n-c)*(n-c)<=(h+r)*(h+r);var At=2*Math.PI;var ge=Math.PI/2;var j={warnings:!0};function v(s,c={}){c=Object.assign({},j,c);let h=s.stat(1),m={def:u,seed:b,print:N,clear:
|
|
1
|
+
(()=>{var x=(s,c,h,m,n,r,b,f)=>s<n+b&&s+h>n&&c<r+f&&c+m>r;var _=(s,c,h,m,n,r)=>(m-s)*(m-s)+(n-c)*(n-c)<=(h+r)*(h+r);var At=2*Math.PI;var ge=Math.PI/2;var j={warnings:!0};function v(s,c={}){c=Object.assign({},j,c);let h=s.stat(1),m={def:u,seed:b,print:N,clear:I,setfps:S,setvar:R,textstyle:w,textmetrics:E,cliprect:M,clipcirc:T,blendmode:A,transform:k,getcolor:y,mousepos:P,resize:C,path:L,fill:Y,stroke:F,clip:X,paint:W,colrect:x,colcirc:_};if(h)throw'Plugin Migrate should be loaded before the "init" event';let n=s.stat(0);function r(t,e,a=""){c.warnings&&console.warn(`[litecanvas/migrate] ${t} is removed. `+(e?`Use ${e} instead. `:"")+a)}function b(t){return r("seed()","rseed()"),t&&s.rseed(t),s.stat(9)}let f="";function w(t){r("textstyle()","the 5th param of text()"),f=t}function N(t,e,a,i){r("print()","text()"),s.text(t,e,a,i)}function E(t,e){r("textmetrics()","ctx().measureText()");let a=s.ctx(),i=s.stat(10),l=s.stat(11);a.font=`${f||""} ${~~(e||i)}px ${l}`;let p=a.measureText(t);return p.height=p.actualBoundingBoxAscent+p.actualBoundingBoxDescent,p}function M(t,e,a,i){r("cliprect()","clip()");let l=s.ctx();l.beginPath(),l.rect(t,e,a,i),l.clip()}function T(t,e,a){r("clipcirc()","clip()");let i=s.ctx();i.beginPath(),i.arc(t,e,a,0,s.TWO_PI),i.clip()}function y(t){r("getcolor()","stat(5)");let e=stat(5);return e[~~t%e.length]}function A(t){r("blendmode()","ctx().globalCompositeOperation");let e=s.ctx();e.globalCompositeOperation=t}function I(t){r("clear()","cls()"),s.cls(t)}function k(t,e,a,i,l,p,B=!0){return r("transform()","ctx().setTransform() or ctx().transform()"),s.ctx()[B?"setTransform":"transform"](t,e,a,i,l,p)}function P(){return r("mousepos()","MX and MY"),[MX,MY]}function S(t){r("setfps()","framerate()"),s.framerate(t)}let o=s.def;function u(t,e){switch(t){case"W":case"WIDTH":o("W",e),o("WIDTH",e);break;case"H":case"HEIGHT":o("H",e),o("HEIGHT",e);break;case"T":case"ELAPSED":o("T",e),o("ELAPSED",e);break;case"CX":case"CENTERX":o("CX",e),o("CENTERX",e);break;case"CY":case"CENTERY":o("CY",e),o("CENTERY",e);break;case"MX":case"MOUSEX":o("MX",e),o("MOUSEX",e);break;case"MY":case"MOUSEY":o("MY",e),o("MOUSEY",e);break;default:o(t,e);break}}function R(t,e){r("setvar()","def()"),u(t,e)}s.listen("resized",g);function g(){u("CX",s.W/2),u("CY",s.H/2)}g(),u("CANVAS",s.canvas());function C(t,e){if(n.autoscale)throw"resize() don't works with autoscale enabled";r("resize()",null,"Avoid changing the canvas dimensions at runtime."),s.CANVAS.width=t,u("W",t),s.CANVAS.height=e,u("H",e),s.emit("resized",1)}for(let t of["W","H","T","CX","CY","MX","MY"])s[t]!=null&&u(t,s[t]);if(r("FPS","","but you can use our plugin to measure the fps: https://github.com/litecanvas/plugin-frame-rate-meter"),o("FPS",""),n.fps&&s.framerate(n.fps),n.background!=null){r('"background" option',"You must update your canvas CSS");let t=s.listen("before:draw",()=>{s.canvas().style.background=y(~~n.background),t()})}function L(t){return r("path()","`new Path2D()`","See https://developer.mozilla.org/en-US/docs/Web/API/Path2D"),new Path2D(t)}let z=s.fill;function Y(t,e){if(e instanceof Path2D){r("fill(color, path)");let a=s.stat(5),i=s.ctx();i.fillStyle=a[~~t%a.length],s.ctx().fill(e)}else z(t)}let O=s.stroke;function F(t,e){if(e instanceof Path2D){r("stroke(color, path)");let a=s.stat(5),i=s.ctx();i.strokeStyle=a[~~t%a.length],s.ctx().stroke(e)}else O(t)}let D=s.clip;function X(t){r("clip(path)","clip(callback)","E.g: `clip((ctx) => ctx.rect(0, 0, 200, 200))`"),t instanceof Path2D?s.ctx().clip(t):D(t)}n.antialias&&r('"antialias" option','"pixelart" option'),n.pixelart===!1&&r('"pixelart" option'),n.animate===!1&&r('"animate" option',"pause() in the of your draw()");let H=s.paint;function W(t,e,a,i){let l=a;return s.spr&&Array.isArray(a)&&(l=()=>{s.spr(0,0,a.join(`
|
|
2
|
+
`))}),H(t,e,l,i)}let d=s.spr;return d&&d.length===3&&(m.spr=function(t,e,a,i,l){Number.isFinite(a)&&a>0?(r("spr() width and height","spr(x, y, pixels)"),d(t,e,l)):d(t,e,a)}),m}window.pluginMigrate=v;})();
|
|
2
3
|
/*! Migrate for litecanvas by Luiz Bills | MIT Licensed */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litecanvas/plugin-migrate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Sometimes upgrading litecanvas to a new version can be a lot of work. This plugin makes this easier, by restoring the Litecanvas APIs that were removed in newer versions, and additionally shows warnings in the browser console when removed and/or deprecated APIs are used.",
|
|
5
5
|
"author": "Luiz Bills <luizbills@pm.me>",
|
|
6
6
|
"license": "MIT",
|
package/src/index.js
CHANGED
|
@@ -310,7 +310,7 @@ export default function plugin(engine, config = {}) {
|
|
|
310
310
|
let cb = data
|
|
311
311
|
if (engine.spr && Array.isArray(data)) {
|
|
312
312
|
cb = () => {
|
|
313
|
-
engine.spr(0, 0, data.join("")
|
|
313
|
+
engine.spr(0, 0, data.join("\n"))
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
return _core_paint(w, h, cb, options)
|