@litecanvas/plugin-migrate 0.10.0 → 0.10.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 +1 -1
- package/package.json +1 -1
- package/src/index.js +3 -3
package/dist/dist.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{var _=(e,l,c,m,o,h,b,g)=>e<o+b&&e+c>o&&l<h+g&&l+m>h;var y=(e,l,c,m,o,h)=>(m-e)*(m-e)+(o-l)*(o-l)<=(c+h)*(c+h);var Wt=2*Math.PI;var v=(e,l,c,m=Math.sin)=>e+(m(c)+1)/2*(l-e);var Ts=Math.PI/2;var et={warnings:!0};function w(e,l={}){if(e.stat(1))throw'Plugin Migrate should be loaded before the "init" event';l=Object.assign({},et,l);let m={def:p,seed:h,print:T,clear:C,setfps:O,setvar:X,textstyle:g,textmetrics:k,cliprect:F,clipcirc:S,blendmode:R,transform:L,getcolor:E,mousepos:Y,path:H,fill:D,stroke:z,clip:Z,paint:$,colrect:(...t)=>(x("colrect()"),_(...t)),colcirc:(...t)=>(x("colrect()"),y(...t)),wave:(...t)=>(x("wave()"),v(...t))};e.TWO_PI
|
|
1
|
+
(()=>{var _=(e,l,c,m,o,h,b,g)=>e<o+b&&e+c>o&&l<h+g&&l+m>h;var y=(e,l,c,m,o,h)=>(m-e)*(m-e)+(o-l)*(o-l)<=(c+h)*(c+h);var Wt=2*Math.PI;var v=(e,l,c,m=Math.sin)=>e+(m(c)+1)/2*(l-e);var Ts=Math.PI/2;var et={warnings:!0};function w(e,l={}){if(e.stat(1))throw'Plugin Migrate should be loaded before the "init" event';l=Object.assign({},et,l);let m={def:p,seed:h,print:T,clear:C,setfps:O,setvar:X,textstyle:g,textmetrics:k,cliprect:F,clipcirc:S,blendmode:R,transform:L,getcolor:E,mousepos:Y,path:H,fill:D,stroke:z,clip:Z,paint:$,colrect:(...t)=>(x("colrect()"),_(...t)),colcirc:(...t)=>(x("colrect()"),y(...t)),wave:(...t)=>(x("wave()"),v(...t))};e.def("TWO_PI",e.PI*2),e.def("HALF_PI",e.PI/2);let o=e.stat(0);function h(t){return a("seed()","rseed()"),t&&e.rseed(t),e.stat(9)}let b="";function g(t){a("textstyle()","the 5th param of text()"),b=t}function T(t,s,r,n){a("print()","text()"),e.text(t,s,r,n)}function k(t,s){a("textmetrics()","ctx().measureText()");let r=e.ctx(),n=e.stat(10),u=e.stat(11);r.font=`${b||""} ${~~(s||n)}px ${u}`;let f=r.measureText(t);return f.height=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent,f}function F(t,s,r,n){a("cliprect()","clip()");let u=e.ctx();u.beginPath(),u.rect(t,s,r,n),u.clip()}function S(t,s,r){a("clipcirc()","clip()");let n=e.ctx();n.beginPath(),n.arc(t,s,r,0,e.TWO_PI),n.clip()}function E(t){a("getcolor()","stat(5)");let s=stat(5);return s[~~t%s.length]}function R(t){a("blendmode()","ctx().globalCompositeOperation");let s=e.ctx();s.globalCompositeOperation=t}function C(t){a("clear()","cls()"),e.cls(t)}function L(t,s,r,n,u,f,q=!0){return a("transform()","ctx().setTransform() or ctx().transform()"),e.ctx()[q?"setTransform":"transform"](t,s,r,n,u,f)}function Y(){return a("mousepos()","MX and MY"),[MX,MY]}function O(t){a("setfps()","framerate()"),e.framerate(t)}let i=e.def;function p(t,s){switch(t){case"W":case"WIDTH":i("W",s),i("WIDTH",s);break;case"H":case"HEIGHT":i("H",s),i("HEIGHT",s);break;case"T":case"ELAPSED":i("T",s),i("ELAPSED",s);break;case"CX":case"CENTERX":i("CX",s),i("CENTERX",s);break;case"CY":case"CENTERY":i("CY",s),i("CENTERY",s);break;case"MX":case"MOUSEX":i("MX",s),i("MOUSEX",s);break;case"MY":case"MOUSEY":i("MY",s),i("MOUSEY",s);break;default:i(t,s);break}}function X(t,s){a("setvar()","def()"),p(t,s)}e.listen("resized",M);function M(){p("CX",e.W/2),p("CY",e.H/2)}M(),p("CANVAS",e.canvas());for(let t of["W","H","T","CX","CY","MX","MY"])e[t]!=null&&p(t,e[t]);a("FPS","","but you can use our plugin to measure the fps: https://github.com/litecanvas/plugin-frame-rate-meter"),i("FPS",""),o.fps&&e.framerate(o.fps),o.background!=null&&(a('"background" option',"You must update your canvas CSS"),e.listen("after:init",()=>{e.canvas().style.background=E(~~o.background)}));function H(t){return a("path()","`new Path2D()`","See https://developer.mozilla.org/en-US/docs/Web/API/Path2D"),new Path2D(t)}let B=e.fill;function D(t,s){if(s instanceof Path2D){a("fill(color, path)");let r=e.stat(5),n=e.ctx();n.fillStyle=r[~~t%r.length],e.ctx().fill(s)}else B(t)}let W=e.stroke;function z(t,s){if(s instanceof Path2D){a("stroke(color, path)");let r=e.stat(5),n=e.ctx();n.strokeStyle=r[~~t%r.length],e.ctx().stroke(s)}else W(t)}let U=e.clip;function Z(t){a("clip(path)","clip(callback)","E.g: `clip((ctx) => ctx.rect(0, 0, 200, 200))`"),t instanceof Path2D?e.ctx().clip(t):U(t)}o.antialias&&a('"antialias" option','"pixelart" option'),o.pixelart===!1&&a('"pixelart" option'),o.animate===!1&&a('"animate" option',"pause() in the of your draw()");let V=e.paint;function $(t,s,r,n){let u=r;return e.spr&&Array.isArray(r)&&(u=()=>{e.spr(0,0,r.join(`
|
|
2
2
|
`))}),V(t,s,u,n)}let d=e.spr;d&&d.length===3&&(m.spr=function(t,s,r,n,u){Number.isFinite(r)&&r>0?(a("spr() width and height","spr(x, y, pixels)"),d(t,s,u)):d(t,s,r)});let j=e.listen,I=e.unlisten;I&&(m.listen=(t,s)=>(j(t,s),()=>{P("listen() not returns a function anymore. Please use unlisten(event, callback) instead."),I(t,s)}));let A=e.ispaused;A&&(m.paused=()=>(a("paused()","ispaused()"),A()));function P(t){l.warnings&&console.warn(`[litecanvas/migrate] ${t}`)}function a(t,s,r=""){P(`${t} is removed. `+(s?`Please use ${s} instead. `:"")+r)}function x(t,s="function"){a(t,`This ${s} was moved to @litecanvas/utils package.`)}return m}window.pluginMigrate=w;})();
|
|
3
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.10.
|
|
3
|
+
"version": "0.10.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
|
@@ -57,9 +57,9 @@ export default function plugin(engine, config = {}) {
|
|
|
57
57
|
},
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// restore
|
|
61
|
-
engine.TWO_PI
|
|
62
|
-
engine.HALF_PI
|
|
60
|
+
// restore old PI constants
|
|
61
|
+
engine.def("TWO_PI", engine.PI * 2)
|
|
62
|
+
engine.def("HALF_PI", engine.PI / 2)
|
|
63
63
|
|
|
64
64
|
/** @type {LitecanvasOptions} */
|
|
65
65
|
const settings = engine.stat(0)
|