litecanvas 0.69.4 → 0.71.0
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/README.md +5 -5
- package/dist/dist.js +34 -28
- package/dist/dist.min.js +1 -1
- package/package.json +4 -4
- package/src/index.js +37 -29
- package/types/index.d.ts +0 -21
- package/types/types.d.ts +0 -21
package/README.md
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
# Litecanvas
|
|
4
4
|
|
|
5
|
-

|
|
5
|
+

|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
[](https://discord.com/invite/r2c3rGsvH3)
|
|
9
|
-
[](https://bills.itch.io/litecanvas)
|
|
10
|
-
|
|
11
8
|
Litecanvas is a lightweight HTML5 canvas engine suitable for small web games, prototypes, game jams, animations, creative coding, learning game programming and game design, etc.
|
|
12
9
|
|
|
13
10
|
:warning: **This project is still under development. All feedback is appreciated!** :warning:
|
|
14
11
|
|
|
12
|
+
[](https://discord.com/invite/r2c3rGsvH3)
|
|
13
|
+
[](https://bills.itch.io/litecanvas)
|
|
14
|
+
|
|
15
15
|
### Features
|
|
16
16
|
|
|
17
17
|
- **Tiny**: Only `~4KB` (minified + gzipped).
|
|
@@ -93,7 +93,7 @@ Try some demos in our playground:
|
|
|
93
93
|
- [Pong](https://litecanvas.js.org?c=eJy1Vlly20YQ%2FccpOl8ATBACuEiWYslFM5DlKkdMkUwkJpVKwcCQnAoEoIChpdiWr%2BAT%2BC%2BHyHlygVwh3TODTZYU%2F0QsDdELenm9DBMmIA%2FjCzgGf%2BA5BuAf0mdEj2vykkivEa%2BQHg01HbNSkALpKc6bMElaj6vmccHfsZZpYk3STUK8yhovpLeaWjVUmTMWIzmoQimjrGi9m%2FA1K5EcKlKwG0EOta4ICyFfX4dJyQwj4YJFYfo2LK33UuOax2J7BMMKhy3jm604gtFTZNzahrG3B9NdKbIr%2BPnd6SWU2S6NS1hnBYgtL2ETXjHSyQsmBGdFn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B1UpY6f%2FC73Is6Q%3D)
|
|
94
94
|
- [Bouncing Ball](https://litecanvas.js.org?c=eJxtUstugzAQvPMVewTiBCdtpVYpPVStSu6ReraMiSy5gIyhRUn%2BvQZvg0NzsGTveGdmH0oYqKtGGlmVkEIneLimlNgTkQDsW1Vcmn64HzTr8KpZLtvG%2Fr9%2FDAIljeCs7FgTRkFQtCUfyWQpTRjB0WNBgc%2Fd2z6LNyR7331k%2B2QTbSd2%2FEIRtNDZ42zrnBkR5sbx%2Fhlf%2FcAivajYVwy58fH%2BCu8d7hlzBGhhyvcyPHhKTxJ4raw3AVVRgMgPorFRWUA4OVtgr15gLBtOJ8%2F2EsFnoK6iK0txCsv19kaUrp4exrDXgBS4Yl%2B1p0xwTMQpo1ZkE89zl7Y%2BuPjEzs%2F99KOf%2F9LDyFwKKowC%2FtRyzb5xE7hqQjrOm0vNC6mUb3jiJGj9brYAw27YwnrHpoVpdQnHIWIlfwGU6d0i)
|
|
95
95
|
- [Scroller](https://litecanvas.js.org?c=eJxVUMFOwzAMvfcrzAEtacNIxwZDsAPSJoG0AxJIO0w7hDZdI6XN1HhQgfbvOOs22CGJ7ff8nh1rUGeq%2FlSe8SgqtnWGxtVgaoPAOPxEAJX2Xq01TKC30DZzlQZ0YE%2BNFz0itQQvXqbvzxRvlKVsORQjcSvuxFjci1SKNF1Fu38W202uUAPLsbNB6pnNn17fZlPKvPnWR8nrwwR9q%2Bs1loSWBI3k3vZqAjdSQgw5nsnnjfo6bpBZzySnoHANMKsRDAnIB3oe4VycaknSdQEEJoa5MGGyn8aGn8p0UDcEHdv99sNjw4yA9I%2BVOesCiX5kWVjnGoYYjy4pPdjx1Z6LusWwMQsXP5VYpVrWChhInpg4YLHsjwWUyUAm3tRBbcjjUhzGEZ1hENjRZ%2FwCV%2F6J0w%3D%3D)
|
|
96
|
-
- [3D
|
|
96
|
+
- [3D projection](https://litecanvas.js.org?c=eJyNVUuP2jAQvudXTA%2FVOsU8y6kt7WVXhftK7W6Ug0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4BYENOZhhTSkSuKk2YjUH5d6rxJ2z7KH65bPf%2BvfjvVfvh5dKAjaNyb3LIJtBogCnmg1zxgknSt0ypTFJU5jx9vvILwZGaYSAscTFPLj%2FBMOFSpbN0f5FyJWegsqGGzeVYZtK8lQOWyjHGw4PC9ILWgxudwdXZh6Wpt7%2Bcf3Th99%2FCeFh1muZ7cKl8JTOWRaEx%2BVNMrY8Vd8H0f4fBSyrmYI0eyVf4md0DpWK0%2BcKLS9o%2BU7QOGmEh6gdHnS9IYMxB7T0Gb0dQePtRgGiXNECKK8HyuuA8kOgY6vOqsMlrvZovbHfbOLv86H2Wtfm9b59exB8h89LMqfG66YBbe5N0vCwWxU2H3OmwP8BV89smg%3D%3D)
|
|
98
98
|
|
|
99
99
|
_See other demos in [samples](samples) folder_
|
package/dist/dist.js
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
animate: true
|
|
65
65
|
};
|
|
66
66
|
settings = Object.assign(defaults, settings);
|
|
67
|
-
let _initialized = false, _plugins = [], _canvas = settings.canvas || document.createElement("canvas"), _fullscreen = settings.fullscreen, _autoscale = settings.autoscale, _animated = settings.animate, _scale = 1, _ctx, _timeScale = 1, _lastFrame, _step, _stepMs, _accumulated = 0, _focused = true, _fontFamily = "sans-serif", _fontStyle = "", _fontSize = 32, _rng_seed = Date.now(), _global = settings.global, _events = {
|
|
67
|
+
let _initialized = false, _plugins = [], _canvas = settings.canvas || document.createElement("canvas"), _fullscreen = settings.fullscreen, _autoscale = settings.autoscale, _animated = settings.animate, _scale = 1, _ctx, _outline_fix = 0.5, _timeScale = 1, _lastFrame, _step, _stepMs, _accumulated = 0, _focused = true, _fontFamily = "sans-serif", _fontStyle = "", _fontSize = 32, _rng_seed = Date.now(), _global = settings.global, _events = {
|
|
68
68
|
init: null,
|
|
69
69
|
update: null,
|
|
70
70
|
draw: null,
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
/**
|
|
232
232
|
* Clear the game screen
|
|
233
233
|
*
|
|
234
|
-
* @param {number|null} color The background color (
|
|
234
|
+
* @param {number|null} color The background color (index) or null (for transparent)
|
|
235
235
|
*/
|
|
236
236
|
cls(color) {
|
|
237
237
|
let width = _ctx.canvas.width, height = _ctx.canvas.height;
|
|
@@ -248,12 +248,18 @@
|
|
|
248
248
|
* @param {number} y
|
|
249
249
|
* @param {number} width
|
|
250
250
|
* @param {number} height
|
|
251
|
-
* @param {number} [color=0] the color index
|
|
251
|
+
* @param {number} [color=0] the color index
|
|
252
252
|
* @param {number|number[]} [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
253
253
|
*/
|
|
254
254
|
rect(x, y, width, height, color = 0, radii = null) {
|
|
255
255
|
_ctx.beginPath();
|
|
256
|
-
_ctx[radii ? "roundRect" : "rect"](
|
|
256
|
+
_ctx[radii ? "roundRect" : "rect"](
|
|
257
|
+
~~x + _outline_fix,
|
|
258
|
+
~~y + _outline_fix,
|
|
259
|
+
~~width,
|
|
260
|
+
~~height,
|
|
261
|
+
radii
|
|
262
|
+
);
|
|
257
263
|
instance.stroke(color);
|
|
258
264
|
},
|
|
259
265
|
/**
|
|
@@ -263,12 +269,18 @@
|
|
|
263
269
|
* @param {number} y
|
|
264
270
|
* @param {number} width
|
|
265
271
|
* @param {number} height
|
|
266
|
-
* @param {number} [color=0] the color index
|
|
272
|
+
* @param {number} [color=0] the color index
|
|
267
273
|
* @param {number|number[]} [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
268
274
|
*/
|
|
269
275
|
rectfill(x, y, width, height, color = 0, radii = null) {
|
|
270
276
|
_ctx.beginPath();
|
|
271
|
-
_ctx[radii ? "roundRect" : "rect"](
|
|
277
|
+
_ctx[radii ? "roundRect" : "rect"](
|
|
278
|
+
~~x,
|
|
279
|
+
~~y,
|
|
280
|
+
~~width,
|
|
281
|
+
~~height,
|
|
282
|
+
radii
|
|
283
|
+
);
|
|
272
284
|
instance.fill(color);
|
|
273
285
|
},
|
|
274
286
|
/**
|
|
@@ -277,11 +289,17 @@
|
|
|
277
289
|
* @param {number} x
|
|
278
290
|
* @param {number} y
|
|
279
291
|
* @param {number} radius
|
|
280
|
-
* @param {number} [color=0] the color index
|
|
292
|
+
* @param {number} [color=0] the color index
|
|
281
293
|
*/
|
|
282
294
|
circ(x, y, radius, color) {
|
|
283
295
|
_ctx.beginPath();
|
|
284
|
-
_ctx.arc(
|
|
296
|
+
_ctx.arc(
|
|
297
|
+
~~x + _outline_fix,
|
|
298
|
+
~~y + _outline_fix,
|
|
299
|
+
~~radius,
|
|
300
|
+
0,
|
|
301
|
+
TWO_PI
|
|
302
|
+
);
|
|
285
303
|
instance.stroke(color);
|
|
286
304
|
},
|
|
287
305
|
/**
|
|
@@ -290,11 +308,11 @@
|
|
|
290
308
|
* @param {number} x
|
|
291
309
|
* @param {number} y
|
|
292
310
|
* @param {number} radius
|
|
293
|
-
* @param {number} [color=0] the color index
|
|
311
|
+
* @param {number} [color=0] the color index
|
|
294
312
|
*/
|
|
295
313
|
circfill(x, y, radius, color) {
|
|
296
314
|
_ctx.beginPath();
|
|
297
|
-
_ctx.arc(~~x, ~~y, radius, 0, TWO_PI);
|
|
315
|
+
_ctx.arc(~~x, ~~y, ~~radius, 0, TWO_PI);
|
|
298
316
|
instance.fill(color);
|
|
299
317
|
},
|
|
300
318
|
/**
|
|
@@ -304,12 +322,12 @@
|
|
|
304
322
|
* @param {number} y1
|
|
305
323
|
* @param {number} x2
|
|
306
324
|
* @param {number} y2
|
|
307
|
-
* @param {number} [color=0] the color index
|
|
325
|
+
* @param {number} [color=0] the color index
|
|
308
326
|
*/
|
|
309
327
|
line(x1, y1, x2, y2, color) {
|
|
310
328
|
_ctx.beginPath();
|
|
311
|
-
_ctx.moveTo(~~x1, ~~y1);
|
|
312
|
-
_ctx.lineTo(~~x2, ~~y2);
|
|
329
|
+
_ctx.moveTo(~~x1 + _outline_fix, ~~y1 + _outline_fix);
|
|
330
|
+
_ctx.lineTo(~~x2 + _outline_fix, ~~y2 + _outline_fix);
|
|
313
331
|
instance.stroke(color);
|
|
314
332
|
},
|
|
315
333
|
/**
|
|
@@ -319,7 +337,8 @@
|
|
|
319
337
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth
|
|
320
338
|
*/
|
|
321
339
|
linewidth(value) {
|
|
322
|
-
_ctx.lineWidth = value;
|
|
340
|
+
_ctx.lineWidth = ~~value;
|
|
341
|
+
_outline_fix = ~~value % 2 === 0 ? 0 : 0.5;
|
|
323
342
|
},
|
|
324
343
|
/**
|
|
325
344
|
* Sets the line dash pattern used when drawing lines
|
|
@@ -340,7 +359,7 @@
|
|
|
340
359
|
* @param {number} x
|
|
341
360
|
* @param {number} y
|
|
342
361
|
* @param {string} text the text message
|
|
343
|
-
* @param {number} [color=3] the color index
|
|
362
|
+
* @param {number} [color=3] the color index
|
|
344
363
|
*/
|
|
345
364
|
text(x, y, text, color = 3) {
|
|
346
365
|
_ctx.font = `${_fontStyle} ${_fontSize}px ${_fontFamily}`;
|
|
@@ -491,19 +510,6 @@
|
|
|
491
510
|
* @param {number} radians
|
|
492
511
|
*/
|
|
493
512
|
rotate: (radians) => _ctx.rotate(radians),
|
|
494
|
-
/**
|
|
495
|
-
* @param {number} a
|
|
496
|
-
* @param {number} b
|
|
497
|
-
* @param {number} c
|
|
498
|
-
* @param {number} d
|
|
499
|
-
* @param {number} e
|
|
500
|
-
* @param {number} f
|
|
501
|
-
* @param {boolean} [resetFirst=true] `false` to use _ctx.transform(); by default use _ctx.setTransform()
|
|
502
|
-
*
|
|
503
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform
|
|
504
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
|
|
505
|
-
*/
|
|
506
|
-
transform: (a, b, c, d, e, f, resetFirst = true) => _ctx[resetFirst ? "setTransform" : "transform"](a, b, c, d, e, f),
|
|
507
513
|
/**
|
|
508
514
|
* Sets the alpha (opacity) value to apply when drawing new shapes and images
|
|
509
515
|
*
|
package/dist/dist.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e=new AudioContext,t=(t=1,a=.05,l=220,n=0,i=0,r=.1,o=0,s=1,c=0,f=0,u=0,p=0,d=0,h=0,g=0,m=0,v=0,x=1,E=0,b=0,T=0)=>{let w=Math,y=2*w.PI,D=c*=500*y/44100/44100,H=l*=(1-a+2*a*w.random(a=[]))*y/44100,I=0,S=0,A=0,k=1,C=0,L=0,X=0,O=T<0?-1:1,z=y*O*T*2/44100,M=w.cos(z),P=w.sin,Y=P(z)/4,W=1+Y,B=-2*M/W,F=(1-Y)/W,_=(1+O*M)/2/W,R=-(O+M)/W,G=0,N=0,U=0,$=0;for(n=44100*n+9,E*=44100,i*=44100,r*=44100,v*=44100,f*=500*y/85766121e6,g*=y/44100,u*=y/44100,p*=44100,d=44100*d|0,t*=.3*(globalThis.zzfxV||1),O=n+E+i+r+v|0;A<O;a[A++]=X*t)++L%(100*m|0)||(X=o?1<o?2<o?3<o?P(I*I):w.max(w.min(w.tan(I),1),-1):1-(2*I/y%2+2)%2:1-4*w.abs(w.round(I/y)-I/y):P(I),X=(d?1-b+b*P(y*A/d):1)*(X<0?-1:1)*w.abs(X)**s*(A<n?A/n:A<n+E?1-(A-n)/E*(1-x):A<n+E+i?x:A<O-v?(O-A-v)/r*x:0),X=v?X/2+(v>A?0:(A<O-v?1:(O-A)/v)*a[A-v|0]/2/t):X,T&&(X=$=_*G+R*(G=N)+_*(N=X)-F*U-B*(U=$))),I+=(z=(l+=c+=f)*w.cos(g*S++))+z*h*P(A**5),k&&++k>p&&(l+=u,H+=u,k=0),!d||++C%d||(l=H,c=D,k=k||1);(t=e.createBuffer(1,O,44100)).getChannelData(0).set(a),(l=e.createBufferSource()).buffer=t,l.connect(e.destination),l.start()},a=["#111","#6a7799","#aec2c2","#FFF1E8","#e83b3b","#fabc20","#155fd9","#3cbcfc","#327345","#63c64d","#6c2c1f","#ac7c00"];globalThis.litecanvas=function(e={}){let l=globalThis,n=Math.PI,i=2*n,r=requestAnimationFrame,o=[],s=(e,t,a)=>{e.addEventListener(t,a,!1),o.push(()=>e.removeEventListener(t,a,!1))};e=Object.assign({fps:60,fullscreen:!0,width:null,height:null,autoscale:!0,pixelart:!1,antialias:!1,canvas:null,global:!0,loop:null,pauseOnBlur:!0,tapEvents:!0,keyboardEvents:!0,animate:!0},e);let c=!1,f=[],u=e.canvas||document.createElement("canvas"),p=e.fullscreen,d=e.autoscale,h=e.animate,g=1,m,v=1,
|
|
1
|
+
(()=>{var e=new AudioContext,t=(t=1,a=.05,l=220,n=0,i=0,r=.1,o=0,s=1,c=0,f=0,u=0,p=0,d=0,h=0,g=0,m=0,v=0,x=1,E=0,b=0,T=0)=>{let w=Math,y=2*w.PI,D=c*=500*y/44100/44100,H=l*=(1-a+2*a*w.random(a=[]))*y/44100,I=0,S=0,A=0,k=1,C=0,L=0,X=0,O=T<0?-1:1,z=y*O*T*2/44100,M=w.cos(z),P=w.sin,Y=P(z)/4,W=1+Y,B=-2*M/W,F=(1-Y)/W,_=(1+O*M)/2/W,R=-(O+M)/W,G=0,N=0,U=0,$=0;for(n=44100*n+9,E*=44100,i*=44100,r*=44100,v*=44100,f*=500*y/85766121e6,g*=y/44100,u*=y/44100,p*=44100,d=44100*d|0,t*=.3*(globalThis.zzfxV||1),O=n+E+i+r+v|0;A<O;a[A++]=X*t)++L%(100*m|0)||(X=o?1<o?2<o?3<o?P(I*I):w.max(w.min(w.tan(I),1),-1):1-(2*I/y%2+2)%2:1-4*w.abs(w.round(I/y)-I/y):P(I),X=(d?1-b+b*P(y*A/d):1)*(X<0?-1:1)*w.abs(X)**s*(A<n?A/n:A<n+E?1-(A-n)/E*(1-x):A<n+E+i?x:A<O-v?(O-A-v)/r*x:0),X=v?X/2+(v>A?0:(A<O-v?1:(O-A)/v)*a[A-v|0]/2/t):X,T&&(X=$=_*G+R*(G=N)+_*(N=X)-F*U-B*(U=$))),I+=(z=(l+=c+=f)*w.cos(g*S++))+z*h*P(A**5),k&&++k>p&&(l+=u,H+=u,k=0),!d||++C%d||(l=H,c=D,k=k||1);(t=e.createBuffer(1,O,44100)).getChannelData(0).set(a),(l=e.createBufferSource()).buffer=t,l.connect(e.destination),l.start()},a=["#111","#6a7799","#aec2c2","#FFF1E8","#e83b3b","#fabc20","#155fd9","#3cbcfc","#327345","#63c64d","#6c2c1f","#ac7c00"];globalThis.litecanvas=function(e={}){let l=globalThis,n=Math.PI,i=2*n,r=requestAnimationFrame,o=[],s=(e,t,a)=>{e.addEventListener(t,a,!1),o.push(()=>e.removeEventListener(t,a,!1))};e=Object.assign({fps:60,fullscreen:!0,width:null,height:null,autoscale:!0,pixelart:!1,antialias:!1,canvas:null,global:!0,loop:null,pauseOnBlur:!0,tapEvents:!0,keyboardEvents:!0,animate:!0},e);let c=!1,f=[],u=e.canvas||document.createElement("canvas"),p=e.fullscreen,d=e.autoscale,h=e.animate,g=1,m,v=.5,x=1,E,b,T,w=0,y=!0,D="sans-serif",H="",I=32,S=Date.now(),A=e.global,k={init:null,update:null,draw:null,resized:null,tap:null,untap:null,tapping:null,tapped:null},C={settings:Object.assign({},e),colors:a},L={WIDTH:e.width,HEIGHT:e.height||e.width,CANVAS:null,ELAPSED:0,CENTERX:0,CENTERY:0,MOUSEX:-1,MOUSEY:-1,DEFAULT_SFX:[.5,,1675,,.06,.2,1,1.8,,,637,.06],PI:n,TWO_PI:i,HALF_PI:.5*n,lerp:(e,t,a)=>e+a*(t-e),deg2rad:e=>n/180*e,rad2deg:e=>180/n*e,clamp:(e,t,a)=>e<t?t:e>a?a:e,wrap:(e,t,a)=>e-(a-t)*Math.floor((e-t)/(a-t)),map(e,t,a,l,n,i){let r=(e-t)/(a-t)*(n-l)+l;return i?L.clamp(r,l,n):r},norm:(e,t,a)=>L.map(e,t,a,0,1),rand:(e=0,t=1)=>(S=(1664525*S+0x3c6ef35f)%0x100000000)/0x100000000*(t-e)+e,randi:(e=0,t=1)=>Math.floor(L.rand(e,t+1)),seed:e=>null==e?S:S=~~e,cls(e){let t=m.canvas.width,a=m.canvas.height;null==e?m.clearRect(0,0,t,a):L.rectfill(0,0,t,a,e)},rect(e,t,a,l,n=0,i=null){m.beginPath(),m[i?"roundRect":"rect"](~~e+v,~~t+v,~~a,~~l,i),L.stroke(n)},rectfill(e,t,a,l,n=0,i=null){m.beginPath(),m[i?"roundRect":"rect"](~~e,~~t,~~a,~~l,i),L.fill(n)},circ(e,t,a,l){m.beginPath(),m.arc(~~e+v,~~t+v,~~a,0,i),L.stroke(l)},circfill(e,t,a,l){m.beginPath(),m.arc(~~e,~~t,~~a,0,i),L.fill(l)},line(e,t,a,l,n){m.beginPath(),m.moveTo(~~e+v,~~t+v),m.lineTo(~~a+v,~~l+v),L.stroke(n)},linewidth(e){m.lineWidth=~~e,v=.5*(~~e%2!=0)},linedash(e,t=0){m.setLineDash(e),m.lineDashOffset=t},text(e,t,a,l=3){m.font=`${H} ${I}px ${D}`,m.fillStyle=L.getcolor(l),m.fillText(a,~~e,~~t)},textfont(e){D=e},textsize(e){I=e},textstyle(e){H=e||""},textalign(e,t){e&&(m.textAlign=e),t&&(m.textBaseline=t)},textmetrics(e,t=I){m.font=`${H} ${t}px ${D}`;let a=m.measureText(e);return a.height=a.actualBoundingBoxAscent+a.actualBoundingBoxDescent,a},image(e,t,a){m.drawImage(a,~~e,~~t)},paint(e,t,a,l={}){let n=l.canvas||new OffscreenCanvas(1,1),i=l.scale||1,r=m;if(n.width=e*i,n.height=t*i,(m=n.getContext("2d")).scale(i,i),a.push){let e=0,t=0;for(let l of(m.imageSmoothingEnabled=!1,a)){for(let a of l)" "!==a&&"."!==a&&L.rectfill(e,t,1,1,parseInt(a,16)),e++;t++,e=0}}else a(m);return m=r,n},ctx:e=>(e&&(m=e),m),push:()=>m.save(),pop:()=>m.restore(),translate:(e,t)=>m.translate(~~e,~~t),scale:(e,t)=>m.scale(e,t||e),rotate:e=>m.rotate(e),alpha(e){m.globalAlpha=L.clamp(e,0,1)},path:e=>new Path2D(e),fill(e,t){m.fillStyle=L.getcolor(e),t?m.fill(t):m.fill()},stroke(e,t){m.strokeStyle=L.getcolor(e),t?m.stroke(t):m.stroke()},clip(e){m.clip(e)},sfx:(e,a=0,n=1)=>!(l.zzfxV<=0)&&(!navigator.userActivation||!!navigator.userActivation.hasBeenActive)&&(e=e||L.DEFAULT_SFX,(a>0||1!==n)&&((e=e.slice())[0]=n*(e[0]||1),e[10]=~~e[10]+a),t.apply(0,e),e),volume(e){l.zzfxV=+e},colrect:(e,t,a,l,n,i,r,o)=>e<n+r&&e+a>n&&t<i+o&&t+l>i,colcirc:(e,t,a,l,n,i)=>(l-e)**2+(n-t)**2<=(a+i)**2,use(e,t={}){c?P(e,t):f.push([e,t])},listen:(e,t)=>(k[e]=k[e]||new Set,k[e].add(t),()=>k[e].delete(t)),emit(e,t,a,l,n){M("before:"+e,t,a,l,n),M(e,t,a,l,n),M("after:"+e,t,a,l,n)},getcolor:e=>a[~~e%a.length],setvar(e,t){L[e]=t,A&&(l[e]=t)},resize(e,t){L.setvar("WIDTH",u.width=e),L.setvar("HEIGHT",u.height=t||e),z()},timescale(e){x=e},setfps(e){T=1e3*(b=1/e),w=0},quit(){for(let e of(L.emit("quit"),o))e();if(y=k=!1,A){for(let e in L)delete l[e];delete l.__litecanvas}}};for(let e of["sin","cos","atan2","hypot","tan","abs","ceil","round","floor","trunc","min","max","pow","sqrt","sign","exp"])L[e]=Math[e];function X(){c=!0;let t=e.loop?e.loop:l;for(let e in k)t[e]&&L.listen(e,t[e]);for(let[e,t]of f)P(e,t);if((p||d)&&s(l,"resize",z),z(),e.tapEvents){let e=(e,t)=>[(e-u.offsetLeft)/g,(t-u.offsetTop)/g],t=new Map,a=(e,a,l)=>{let n={x:a,y:l,startX:a,startY:l,ts:performance.now()};return t.set(e,n),n},n=(e,l,n)=>{let i=t.get(e)||a(e);i.x=l,i.y=n},i=e=>e&&performance.now()-e.ts<=200,r=!1;s(u,"mousedown",t=>{t.preventDefault();let[l,n]=e(t.pageX,t.pageY);L.emit("tap",l,n,0),a(0,l,n),r=!0}),s(u,"mousemove",t=>{t.preventDefault();let[a,l]=e(t.pageX,t.pageY);L.setvar("MOUSEX",a),L.setvar("MOUSEY",l),r&&(L.emit("tapping",a,l,0),n(0,a,l))}),s(u,"mouseup",a=>{a.preventDefault();let l=t.get(0),[n,o]=e(a.pageX,a.pageY);i(l)&&L.emit("tapped",l.startX,l.startY,0),L.emit("untap",n,o,0),t.delete(0),r=!1}),s(u,"touchstart",t=>{for(let l of(t.preventDefault(),t.changedTouches)){let[t,n]=e(l.pageX,l.pageY);L.emit("tap",t,n,l.identifier+1),a(l.identifier+1,t,n)}}),s(u,"touchmove",t=>{for(let a of(t.preventDefault(),t.changedTouches)){let[t,l]=e(a.pageX,a.pageY);L.emit("tapping",t,l,a.identifier+1),n(a.identifier+1,t,l)}});let o=e=>{e.preventDefault();let a=[];if(e.targetTouches.length>0)for(let t of e.targetTouches)a.push(t.identifier+1);for(let[e,l]of t)a.includes(e)||(i(l)&&L.emit("tapped",l.startX,l.startY,e),L.emit("untap",l.x,l.y,e),t.delete(e))};s(u,"touchend",o),s(u,"touchcancel",o),s(l,"blur",()=>{for(let[e,a]of(r=!1,t))L.emit("untap",a.x,a.y,e),t.delete(e)})}if(e.keyboardEvents){let e=new Set;L.setvar("iskeydown",t=>"any"===t?e.size>0:e.has(t.toLowerCase())),s(l,"keydown",t=>{e.add(t.key.toLowerCase())}),s(l,"keyup",t=>{e.delete(t.key.toLowerCase())}),s(l,"blur",()=>e.clear())}e.pauseOnBlur&&(s(l,"blur",()=>{y=!1}),s(l,"focus",()=>{y=!0,r(O)})),L.setfps(e.fps),L.emit("init",L),E=performance.now(),r(O)}function O(e){let t=!h,a=e-E;for(w+=a>100?T:a,E=e;w>=T;)L.emit("update",b*x),L.setvar("ELAPSED",L.ELAPSED+b*x),w-=T,t=!0;t&&(L.textalign("start","top"),L.emit("draw")),y&&h&&r(O)}function z(){let t=l.innerWidth,a=l.innerHeight,n=u.style;n.display="block",p?(n.position="absolute",n.inset=0,L.setvar("WIDTH",u.width=t),L.setvar("HEIGHT",u.height=a)):d&&(n.margin="auto",g=Math.min(t/L.WIDTH,a/L.HEIGHT),g=(e.pixelart?~~g:g)||1,n.width=L.WIDTH*g+"px",n.height=L.HEIGHT*g+"px"),L.setvar("CENTERX",L.WIDTH/2),L.setvar("CENTERY",L.HEIGHT/2),(!e.antialias||e.pixelart)&&(m.imageSmoothingEnabled=!1,u.style.imageRendering="pixelated"),L.emit("resized",g),h||r(O)}function M(e,t,a,l,n){if(k[e])for(let i of k[e])i(t,a,l,n)}function P(e,t){let a=e(L,C,t);if("object"==typeof a)for(let e of Object.keys(a))L.setvar(e,a[e])}if(A){if(l.__litecanvas)throw"global litecanvas already instantiated";Object.assign(l,L),l.__litecanvas=L}return u="string"==typeof u?document.querySelector(u):u,L.setvar("CANVAS",u),m=u.getContext("2d"),s(u,"click",()=>l.focus()),L.WIDTH>0&&(p=!1),u.style="",u.width=L.WIDTH,u.height=L.HEIGHT||L.WIDTH,u.parentNode||document.body.appendChild(u),"loading"===document.readyState?s(l,"DOMContentLoaded",()=>r(X)):r(X),L}})();
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litecanvas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.0",
|
|
4
4
|
"description": "Lightweight HTML5 canvas engine suitable for small games and animations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Luiz Bills <luizbills@pm.me>",
|
|
7
7
|
"contributors": [],
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@swc/core": "^1.
|
|
10
|
-
"ava": "^6.
|
|
11
|
-
"esbuild": "^0.24.
|
|
9
|
+
"@swc/core": "^1.10.15",
|
|
10
|
+
"ava": "^6.2.0",
|
|
11
|
+
"esbuild": "^0.24.2",
|
|
12
12
|
"prettier": "^3.4.2"
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://litecanvas.github.io/about.html",
|
package/src/index.js
CHANGED
|
@@ -60,6 +60,8 @@ export default function litecanvas(settings = {}) {
|
|
|
60
60
|
/** @type {CanvasRenderingContext2D} */
|
|
61
61
|
_ctx,
|
|
62
62
|
/** @type {number} */
|
|
63
|
+
_outline_fix = 0.5,
|
|
64
|
+
/** @type {number} */
|
|
63
65
|
_timeScale = 1,
|
|
64
66
|
/** @type {number} */
|
|
65
67
|
_lastFrame,
|
|
@@ -286,7 +288,7 @@ export default function litecanvas(settings = {}) {
|
|
|
286
288
|
/**
|
|
287
289
|
* Clear the game screen
|
|
288
290
|
*
|
|
289
|
-
* @param {number|null} color The background color (
|
|
291
|
+
* @param {number|null} color The background color (index) or null (for transparent)
|
|
290
292
|
*/
|
|
291
293
|
cls(color) {
|
|
292
294
|
let width = _ctx.canvas.width,
|
|
@@ -305,12 +307,18 @@ export default function litecanvas(settings = {}) {
|
|
|
305
307
|
* @param {number} y
|
|
306
308
|
* @param {number} width
|
|
307
309
|
* @param {number} height
|
|
308
|
-
* @param {number} [color=0] the color index
|
|
310
|
+
* @param {number} [color=0] the color index
|
|
309
311
|
* @param {number|number[]} [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
310
312
|
*/
|
|
311
313
|
rect(x, y, width, height, color = 0, radii = null) {
|
|
312
314
|
_ctx.beginPath()
|
|
313
|
-
_ctx[radii ? 'roundRect' : 'rect'](
|
|
315
|
+
_ctx[radii ? 'roundRect' : 'rect'](
|
|
316
|
+
~~x + _outline_fix,
|
|
317
|
+
~~y + _outline_fix,
|
|
318
|
+
~~width,
|
|
319
|
+
~~height,
|
|
320
|
+
radii
|
|
321
|
+
)
|
|
314
322
|
instance.stroke(color)
|
|
315
323
|
},
|
|
316
324
|
|
|
@@ -321,12 +329,18 @@ export default function litecanvas(settings = {}) {
|
|
|
321
329
|
* @param {number} y
|
|
322
330
|
* @param {number} width
|
|
323
331
|
* @param {number} height
|
|
324
|
-
* @param {number} [color=0] the color index
|
|
332
|
+
* @param {number} [color=0] the color index
|
|
325
333
|
* @param {number|number[]} [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
326
334
|
*/
|
|
327
335
|
rectfill(x, y, width, height, color = 0, radii = null) {
|
|
328
336
|
_ctx.beginPath()
|
|
329
|
-
_ctx[radii ? 'roundRect' : 'rect'](
|
|
337
|
+
_ctx[radii ? 'roundRect' : 'rect'](
|
|
338
|
+
~~x,
|
|
339
|
+
~~y,
|
|
340
|
+
~~width,
|
|
341
|
+
~~height,
|
|
342
|
+
radii
|
|
343
|
+
)
|
|
330
344
|
instance.fill(color)
|
|
331
345
|
},
|
|
332
346
|
|
|
@@ -336,11 +350,17 @@ export default function litecanvas(settings = {}) {
|
|
|
336
350
|
* @param {number} x
|
|
337
351
|
* @param {number} y
|
|
338
352
|
* @param {number} radius
|
|
339
|
-
* @param {number} [color=0] the color index
|
|
353
|
+
* @param {number} [color=0] the color index
|
|
340
354
|
*/
|
|
341
355
|
circ(x, y, radius, color) {
|
|
342
356
|
_ctx.beginPath()
|
|
343
|
-
_ctx.arc(
|
|
357
|
+
_ctx.arc(
|
|
358
|
+
~~x + _outline_fix,
|
|
359
|
+
~~y + _outline_fix,
|
|
360
|
+
~~radius,
|
|
361
|
+
0,
|
|
362
|
+
TWO_PI
|
|
363
|
+
)
|
|
344
364
|
instance.stroke(color)
|
|
345
365
|
},
|
|
346
366
|
|
|
@@ -350,11 +370,11 @@ export default function litecanvas(settings = {}) {
|
|
|
350
370
|
* @param {number} x
|
|
351
371
|
* @param {number} y
|
|
352
372
|
* @param {number} radius
|
|
353
|
-
* @param {number} [color=0] the color index
|
|
373
|
+
* @param {number} [color=0] the color index
|
|
354
374
|
*/
|
|
355
375
|
circfill(x, y, radius, color) {
|
|
356
376
|
_ctx.beginPath()
|
|
357
|
-
_ctx.arc(~~x, ~~y, radius, 0, TWO_PI)
|
|
377
|
+
_ctx.arc(~~x, ~~y, ~~radius, 0, TWO_PI)
|
|
358
378
|
instance.fill(color)
|
|
359
379
|
},
|
|
360
380
|
|
|
@@ -365,12 +385,14 @@ export default function litecanvas(settings = {}) {
|
|
|
365
385
|
* @param {number} y1
|
|
366
386
|
* @param {number} x2
|
|
367
387
|
* @param {number} y2
|
|
368
|
-
* @param {number} [color=0] the color index
|
|
388
|
+
* @param {number} [color=0] the color index
|
|
369
389
|
*/
|
|
370
390
|
line(x1, y1, x2, y2, color) {
|
|
371
391
|
_ctx.beginPath()
|
|
372
|
-
_ctx.moveTo(~~x1, ~~y1)
|
|
373
|
-
_ctx.lineTo(~~x2, ~~y2)
|
|
392
|
+
_ctx.moveTo(~~x1 + _outline_fix, ~~y1 + _outline_fix)
|
|
393
|
+
_ctx.lineTo(~~x2 + _outline_fix, ~~y2 + _outline_fix)
|
|
394
|
+
// _ctx.moveTo(~~x1, ~~y1)
|
|
395
|
+
// _ctx.lineTo(~~x2, ~~y2)
|
|
374
396
|
instance.stroke(color)
|
|
375
397
|
},
|
|
376
398
|
|
|
@@ -381,7 +403,8 @@ export default function litecanvas(settings = {}) {
|
|
|
381
403
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth
|
|
382
404
|
*/
|
|
383
405
|
linewidth(value) {
|
|
384
|
-
_ctx.lineWidth = value
|
|
406
|
+
_ctx.lineWidth = ~~value
|
|
407
|
+
_outline_fix = ~~value % 2 === 0 ? 0 : 0.5
|
|
385
408
|
},
|
|
386
409
|
|
|
387
410
|
/**
|
|
@@ -404,7 +427,7 @@ export default function litecanvas(settings = {}) {
|
|
|
404
427
|
* @param {number} x
|
|
405
428
|
* @param {number} y
|
|
406
429
|
* @param {string} text the text message
|
|
407
|
-
* @param {number} [color=3] the color index
|
|
430
|
+
* @param {number} [color=3] the color index
|
|
408
431
|
*/
|
|
409
432
|
text(x, y, text, color = 3) {
|
|
410
433
|
_ctx.font = `${_fontStyle} ${_fontSize}px ${_fontFamily}`
|
|
@@ -584,21 +607,6 @@ export default function litecanvas(settings = {}) {
|
|
|
584
607
|
*/
|
|
585
608
|
rotate: (radians) => _ctx.rotate(radians),
|
|
586
609
|
|
|
587
|
-
/**
|
|
588
|
-
* @param {number} a
|
|
589
|
-
* @param {number} b
|
|
590
|
-
* @param {number} c
|
|
591
|
-
* @param {number} d
|
|
592
|
-
* @param {number} e
|
|
593
|
-
* @param {number} f
|
|
594
|
-
* @param {boolean} [resetFirst=true] `false` to use _ctx.transform(); by default use _ctx.setTransform()
|
|
595
|
-
*
|
|
596
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform
|
|
597
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
|
|
598
|
-
*/
|
|
599
|
-
transform: (a, b, c, d, e, f, resetFirst = true) =>
|
|
600
|
-
_ctx[resetFirst ? 'setTransform' : 'transform'](a, b, c, d, e, f),
|
|
601
|
-
|
|
602
610
|
/**
|
|
603
611
|
* Sets the alpha (opacity) value to apply when drawing new shapes and images
|
|
604
612
|
*
|
package/types/index.d.ts
CHANGED
|
@@ -429,27 +429,6 @@ declare global {
|
|
|
429
429
|
* @param radians
|
|
430
430
|
*/
|
|
431
431
|
function rotate(radians: number): void
|
|
432
|
-
/**
|
|
433
|
-
* @param a
|
|
434
|
-
* @param b
|
|
435
|
-
* @param c
|
|
436
|
-
* @param d
|
|
437
|
-
* @param e
|
|
438
|
-
* @param f
|
|
439
|
-
* @param [resetFirst=true] `false` to use _ctx.transform(); by default use _ctx.setTransform()
|
|
440
|
-
*
|
|
441
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform
|
|
442
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
|
|
443
|
-
*/
|
|
444
|
-
function transform(
|
|
445
|
-
a: number,
|
|
446
|
-
b: number,
|
|
447
|
-
c: number,
|
|
448
|
-
d: number,
|
|
449
|
-
e: number,
|
|
450
|
-
f: number,
|
|
451
|
-
resetFirst?: boolean
|
|
452
|
-
): void
|
|
453
432
|
/**
|
|
454
433
|
* Sets the alpha (transparency) value to apply when drawing new shapes and images
|
|
455
434
|
*
|
package/types/types.d.ts
CHANGED
|
@@ -407,27 +407,6 @@ type LitecanvasInstance = {
|
|
|
407
407
|
* @param radians
|
|
408
408
|
*/
|
|
409
409
|
rotate(radians: number): void
|
|
410
|
-
/**
|
|
411
|
-
* @param a
|
|
412
|
-
* @param b
|
|
413
|
-
* @param c
|
|
414
|
-
* @param d
|
|
415
|
-
* @param e
|
|
416
|
-
* @param f
|
|
417
|
-
* @param [resetFirst=true] `false` to use _ctx.transform(); by default use _ctx.setTransform()
|
|
418
|
-
*
|
|
419
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform
|
|
420
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
|
|
421
|
-
*/
|
|
422
|
-
transform(
|
|
423
|
-
a: number,
|
|
424
|
-
b: number,
|
|
425
|
-
c: number,
|
|
426
|
-
d: number,
|
|
427
|
-
e: number,
|
|
428
|
-
f: number,
|
|
429
|
-
resetFirst?: boolean
|
|
430
|
-
): void
|
|
431
410
|
/**
|
|
432
411
|
* Sets the alpha (transparency) value to apply when drawing new shapes and images
|
|
433
412
|
*
|