@@ -364,15 +364,18 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
364364
365365 get fillStyle ( ) {
366366 this . log ( 'fillStyle' ) ;
367- switch ( this . context . getFillStyle ( ) . getStyleType ( ) ) {
368- case CanvasColorStyleType . Color :
369- const color = this . context . getFillStyle ( ) as com . github . triniwiz . canvas . TNSColor ;
370- return color . getColor ( ) ;
371- case CanvasColorStyleType . Gradient :
372- return CanvasGradient . fromNative ( this . context . getFillStyle ( ) ) ;
373- case CanvasColorStyleType . Pattern :
374- return new CanvasPattern ( this . context . getFillStyle ( ) ) ;
367+ if ( this . context ) {
368+ switch ( this . context . getFillStyle ( ) . getStyleType ( ) ) {
369+ case com . github . triniwiz . canvas . TNSColorStyleType . Color :
370+ const color = this . context . getFillStyle ( ) as com . github . triniwiz . canvas . TNSColor ;
371+ return color . getColor ( ) ;
372+ case com . github . triniwiz . canvas . TNSColorStyleType . Gradient :
373+ return CanvasGradient . fromNative ( this . context . getFillStyle ( ) ) ;
374+ case com . github . triniwiz . canvas . TNSColorStyleType . Pattern :
375+ return new CanvasPattern ( this . context . getFillStyle ( ) ) ;
376+ }
375377 }
378+ return 'black' ;
376379 }
377380
378381 set fillStyle ( color : string | CanvasGradient | CanvasPattern ) {
@@ -390,6 +393,23 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
390393 }
391394 }
392395
396+
397+
398+ get filter ( ) : string {
399+ this . log ( 'get filter' ) ;
400+ //@ts -ignore
401+ return this . context . getFilter ( ) ;
402+ }
403+
404+ set filter ( value : string ) {
405+ this . log ( 'set filter' , value ) ;
406+ if ( this . context ) {
407+ //@ts -ignore
408+ this . context . setFilter ( value ) ;
409+ }
410+ }
411+
412+
393413 get strokeStyle ( ) {
394414 this . log ( 'strokeStyle' ) ;
395415 switch ( this . context . getStrokeStyle ( ) . getStyleType ( ) ) {
@@ -491,9 +511,11 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
491511 this . log ( 'clip value:' , ...args ) ;
492512 this . _ensureLayoutBeforeDraw ( ) ;
493513 if ( typeof args [ 0 ] === 'string' ) {
494- this . context . clip ( args [ 0 ] ) ;
514+ const rule = this . _fillRuleFromString ( args [ 0 ] ) ;
515+ this . context . clip ( rule ) ;
495516 } else if ( args [ 0 ] instanceof Path2D && typeof args [ 1 ] === 'string' ) {
496- this . context . clip ( args [ 0 ] . native , args [ 1 ] ) ;
517+ const rule = this . _fillRuleFromString ( args [ 1 ] ) ;
518+ this . context . clip ( args [ 0 ] . native , rule ) ;
497519 } else if ( args [ 0 ] instanceof Path2D ) {
498520 this . context . clip ( args [ 0 ] . native ) ;
499521 } else {
@@ -710,6 +732,7 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
710732 ) ;
711733 }
712734
735+
713736 fill ( ) : void ;
714737
715738 fill ( fillRule : string ) : void ;
@@ -720,9 +743,11 @@ export class CanvasRenderingContext2D extends CanvasRenderingContext2DBase {
720743 this . log ( 'fill value:' , ...args ) ;
721744 this . _ensureLayoutBeforeDraw ( ) ;
722745 if ( typeof args [ 0 ] === 'string' ) {
723- this . context . fill ( args [ 0 ] ) ;
746+ const rule = this . _fillRuleFromString ( args [ 0 ] ) ;
747+ this . context . fill ( rule ) ;
724748 } else if ( args [ 0 ] instanceof Path2D && typeof args [ 1 ] === 'string' ) {
725- this . context . fill ( args [ 0 ] . native , args [ 1 ] ) ;
749+ const rule = this . _fillRuleFromString ( args [ 1 ] ) ;
750+ this . context . fill ( args [ 0 ] . native , rule ) ;
726751 } else if ( args [ 0 ] instanceof Path2D ) {
727752 this . context . fill ( args [ 0 ] . native ) ;
728753 } else {
0 commit comments