@@ -20,27 +20,13 @@ export default class PixelRenderer extends BaseRenderer {
2020 }
2121
2222 createImageData ( rectangle ) {
23- this . rectangle = rectangle
24- ? rectangle
25- : new Rectangle ( 0 , 0 , this . element . width , this . element . height ) ;
26- this . imageData = this . context . createImageData (
27- this . rectangle . width ,
28- this . rectangle . height
29- ) ;
30- this . context . putImageData (
31- this . imageData ,
32- this . rectangle . x ,
33- this . rectangle . y
34- ) ;
23+ this . rectangle = rectangle ? rectangle : new Rectangle ( 0 , 0 , this . element . width , this . element . height ) ;
24+ this . imageData = this . context . createImageData ( this . rectangle . width , this . rectangle . height ) ;
25+ this . context . putImageData ( this . imageData , this . rectangle . x , this . rectangle . y ) ;
3526 }
3627
3728 onProtonUpdate ( ) {
38- this . context . clearRect (
39- this . rectangle . x ,
40- this . rectangle . y ,
41- this . rectangle . width ,
42- this . rectangle . height
43- ) ;
29+ this . context . clearRect ( this . rectangle . x , this . rectangle . y , this . rectangle . width , this . rectangle . height ) ;
4430 this . imageData = this . context . getImageData (
4531 this . rectangle . x ,
4632 this . rectangle . y ,
@@ -50,11 +36,7 @@ export default class PixelRenderer extends BaseRenderer {
5036 }
5137
5238 onProtonUpdateAfter ( ) {
53- this . context . putImageData (
54- this . imageData ,
55- this . rectangle . x ,
56- this . rectangle . y
57- ) ;
39+ this . context . putImageData ( this . imageData , this . rectangle . x , this . rectangle . y ) ;
5840 }
5941
6042 onParticleCreated ( particle ) { }
@@ -63,20 +45,18 @@ export default class PixelRenderer extends BaseRenderer {
6345 if ( this . imageData ) {
6446 this . setPixel (
6547 this . imageData ,
66- Math . floor ( particle . p . x - this . rectangle . x ) ,
67- Math . floor ( particle . p . y - this . rectangle . y ) ,
48+ ( particle . p . x - this . rectangle . x ) >> 0 ,
49+ ( particle . p . y - this . rectangle . y ) >> 0 ,
6850 particle
6951 ) ;
7052 }
7153 }
7254
7355 setPixel ( imagedata , x , y , particle ) {
7456 const rgb = particle . rgb ;
75- if ( x < 0 || x > this . element . width || y < 0 || y > this . elementwidth )
76- return ;
57+ if ( x < 0 || x > this . element . width || y < 0 || y > this . elementwidth ) return ;
7758
7859 const i = ( ( y >> 0 ) * imagedata . width + ( x >> 0 ) ) * 4 ;
79-
8060 imagedata . data [ i ] = rgb . r ;
8161 imagedata . data [ i + 1 ] = rgb . g ;
8262 imagedata . data [ i + 2 ] = rgb . b ;
0 commit comments