@@ -16,14 +16,9 @@ export class Eyedropper {
1616 }
1717
1818 const canvas = BB . canvas ( 1 , 1 ) ;
19- const ctx = BB . ctx ( canvas , { willReadFrequently : true } ) ;
19+ const ctx = BB . ctx ( canvas ) ;
2020 ctx . imageSmoothingEnabled = false ;
2121
22- const layerCanvas = BB . canvas ( 1 , 1 ) ;
23- const layerCtx = BB . ctx ( layerCanvas ) ;
24- layerCtx . imageSmoothingEnabled = false ;
25- const imageData = new ImageData ( 1 , 1 ) ;
26-
2722 const tilesX = Math . ceil ( composed . size . width / HISTORY_TILE_SIZE ) ;
2823 const tileCol = Math . floor ( x / HISTORY_TILE_SIZE ) ;
2924 const tileRow = Math . floor ( y / HISTORY_TILE_SIZE ) ;
@@ -44,6 +39,7 @@ export class Eyedropper {
4439 return ;
4540 }
4641 const tile = layer . tiles [ tileIndex ] ;
42+ let fillStyle = '' ;
4743 if ( tile instanceof ImageData ) {
4844 let tileWidth = HISTORY_TILE_SIZE ;
4945 if ( composed . size . width % HISTORY_TILE_SIZE !== 0 && tileCol === tilesX - 1 ) {
@@ -52,20 +48,24 @@ export class Eyedropper {
5248 const pixelIndex =
5349 ( y % HISTORY_TILE_SIZE ) * tileWidth + ( x % HISTORY_TILE_SIZE ) ;
5450
55- imageData . data [ 0 ] = tile . data [ pixelIndex * 4 ] ;
56- imageData . data [ 1 ] = tile . data [ pixelIndex * 4 + 1 ] ;
57- imageData . data [ 2 ] = tile . data [ pixelIndex * 4 + 2 ] ;
58- imageData . data [ 3 ] = tile . data [ pixelIndex * 4 + 3 ] ;
59- layerCtx . putImageData ( imageData , 0 , 0 ) ;
51+ if ( tile . data [ pixelIndex * 4 + 3 ] === 0 ) {
52+ return ;
53+ }
54+
55+ fillStyle = BB . ColorConverter . toRgbaStr ( {
56+ r : tile . data [ pixelIndex * 4 ] ,
57+ g : tile . data [ pixelIndex * 4 + 1 ] ,
58+ b : tile . data [ pixelIndex * 4 + 2 ] ,
59+ a : tile . data [ pixelIndex * 4 + 3 ] ,
60+ } ) ;
6061 } else {
61- layerCtx . clearRect ( 0 , 0 , 1 , 1 ) ;
62- layerCtx . fillStyle = tile . fill ;
63- layerCtx . fillRect ( 0 , 0 , 1 , 1 ) ;
62+ fillStyle = tile . fill ;
6463 }
6564
65+ ctx . fillStyle = fillStyle ;
6666 ctx . globalAlpha = layer . opacity ;
6767 ctx . globalCompositeOperation = layer . mixModeStr ;
68- ctx . drawImage ( layerCanvas , 0 , 0 ) ;
68+ ctx . fillRect ( 0 , 0 , 1 , 1 ) ;
6969 } ) ;
7070
7171 const imData = ctx . getImageData ( 0 , 0 , 1 , 1 ) ;
0 commit comments