@@ -603,17 +603,31 @@ export const Util = {
603603 }
604604
605605 const c = this . createCanvasElement ( ) ;
606- c . width = 1 ;
607- c . height = 1 ;
606+ c . width = 10 ;
607+ c . height = 10 ;
608608 const ctx = c . getContext ( '2d' , {
609609 willReadFrequently : true ,
610610 } ) as CanvasRenderingContext2D ;
611- ctx . clearRect ( 0 , 0 , 1 , 1 ) ;
612- ctx . fillStyle = 'rgba(255,0,255,1)' ; // clear #FF00FF, no alpha
613- ctx . fillRect ( 0 , 0 , 1 , 1 ) ;
614- const d = ctx . getImageData ( 0 , 0 , 1 , 1 ) . data ;
615- const exact = d [ 0 ] === 255 && d [ 1 ] === 0 && d [ 2 ] === 255 && d [ 3 ] === 255 ;
616- _isCanvasFarblingActive = ! exact ;
611+ ctx . clearRect ( 0 , 0 , 10 , 10 ) ;
612+
613+ ctx . fillStyle = '#282828' ; // 40, 40, 40
614+ ctx . fillRect ( 0 , 0 , 10 , 10 ) ;
615+
616+ const d = ctx . getImageData ( 0 , 0 , 10 , 10 ) . data ;
617+ let isFarbling = false ;
618+ for ( let i = 0 ; i < 100 ; i ++ ) {
619+ if (
620+ d [ i * 4 ] !== 40 ||
621+ d [ i * 4 + 1 ] !== 40 ||
622+ d [ i * 4 + 2 ] !== 40 ||
623+ d [ i * 4 + 3 ] !== 255
624+ ) {
625+ isFarbling = true ;
626+ break ;
627+ }
628+ }
629+
630+ _isCanvasFarblingActive = isFarbling ;
617631 this . releaseCanvas ( c ) ;
618632 return _isCanvasFarblingActive ;
619633 } ,
0 commit comments