@@ -33,7 +33,6 @@ export default function litecanvas(settings = {}) {
3333 height : null ,
3434 autoscale : true ,
3535 pixelart : false ,
36- antialias : false ,
3736 canvas : null ,
3837 global : true ,
3938 loop : null ,
@@ -945,7 +944,7 @@ export default function litecanvas(settings = {}) {
945944 DEV: assert ( isNumber ( volumeFactor ) , '[litecanvas] sfx() 3rd param must be a number' )
946945
947946 if (
948- root . zzfxV <= 0 ||
947+ ! root . zzfxV ||
949948 ( navigator . userActivation && ! navigator . userActivation . hasBeenActive )
950949 ) {
951950 return false
@@ -972,7 +971,10 @@ export default function litecanvas(settings = {}) {
972971 * @param {number } value
973972 */
974973 volume ( value ) {
975- DEV: assert ( isNumber ( value ) , '[litecanvas] volume() 1st param must be a number' )
974+ DEV: assert (
975+ isNumber ( value ) && value >= 0 ,
976+ '[litecanvas] volume() 1st param must be a positive number or zero'
977+ )
976978
977979 root . zzfxV = value
978980 } ,
@@ -1564,7 +1566,7 @@ export default function litecanvas(settings = {}) {
15641566
15651567 _ctx = _canvas . getContext ( '2d' )
15661568
1567- on ( _canvas , 'click' , ( ) => root . focus ( ) )
1569+ on ( _canvas , 'click' , ( ) => focus ( ) )
15681570
15691571 /** @ts -ignore */
15701572 _canvas . style = ''
@@ -1592,8 +1594,8 @@ export default function litecanvas(settings = {}) {
15921594 '[litecanvas] litecanvas() option "width" is required when the option "height" is defined'
15931595 )
15941596
1595- const width = settings . width || root . innerWidth ,
1596- height = settings . height || settings . width || root . innerHeight
1597+ const width = settings . width > 0 ? settings . width : innerWidth ,
1598+ height = settings . width > 0 ? settings . height || settings . width : innerHeight
15971599
15981600 instance . def ( 'W' , width )
15991601 instance . def ( 'H' , height )
@@ -1608,29 +1610,30 @@ export default function litecanvas(settings = {}) {
16081610 _canvas . style . margin = 'auto'
16091611 }
16101612
1611- _scale = math . min ( root . innerWidth / width , root . innerHeight / height )
1613+ _scale = math . min ( innerWidth / width , innerHeight / height )
16121614 _scale = maxScale > 1 && _scale > maxScale ? maxScale : _scale
1613- _scale = ( settings . pixelart ? ~ ~ _scale : _scale ) || 1
16141615
16151616 _canvas . style . width = width * _scale + 'px'
16161617 _canvas . style . height = height * _scale + 'px'
16171618 }
16181619
1619- // restore canvas image rendering properties
1620- if ( ! settings . antialias || settings . pixelart ) {
1620+ // set canvas image rendering properties
1621+ if ( settings . pixelart ) {
16211622 _ctx . imageSmoothingEnabled = false
16221623 _canvas . style . imageRendering = 'pixelated'
16231624 }
16241625
1625- // reset the default text align and baseline
1626+ // set the default text align and baseline
16261627 instance . textalign ( 'start' , 'top' )
16271628
16281629 // trigger "resized" event
1630+ // note: not triggered before the "init" event
16291631 instance . emit ( 'resized' , _scale )
16301632
1633+ // paint a temporary background
16311634 instance . cls ( 0 )
16321635
1633- // force redraw
1636+ // force redraw when the canvas is not animated
16341637 if ( ! settings . animate ) {
16351638 raf ( drawFrame )
16361639 }
0 commit comments