@@ -68,17 +68,13 @@ p5.Renderer2D.prototype.background = function(...args) {
6868 }
6969 }
7070 this . drawingContext . restore ( ) ;
71-
72- this . _pixelsState . _pixelsDirty = true ;
7371} ;
7472
7573p5 . Renderer2D . prototype . clear = function ( ) {
7674 this . drawingContext . save ( ) ;
7775 this . resetMatrix ( ) ;
7876 this . drawingContext . clearRect ( 0 , 0 , this . width , this . height ) ;
7977 this . drawingContext . restore ( ) ;
80-
81- this . _pixelsState . _pixelsDirty = true ;
8278} ;
8379
8480p5 . Renderer2D . prototype . fill = function ( ...args ) {
@@ -180,8 +176,6 @@ p5.Renderer2D.prototype.image = function(
180176 throw e ;
181177 }
182178 }
183-
184- this . _pixelsState . _pixelsDirty = true ;
185179} ;
186180
187181p5 . Renderer2D . prototype . _getTintedImageCanvas = function ( img ) {
@@ -258,15 +252,9 @@ p5.Renderer2D.prototype.blend = function(...args) {
258252
259253// x,y are canvas-relative (pre-scaled by _pixelDensity)
260254p5 . Renderer2D . prototype . _getPixel = function ( x , y ) {
261- const pixelsState = this . _pixelsState ;
262255 let imageData , index ;
263- if ( pixelsState . _pixelsDirty ) {
264- imageData = this . drawingContext . getImageData ( x , y , 1 , 1 ) . data ;
265- index = 0 ;
266- } else {
267- imageData = pixelsState . pixels ;
268- index = ( Math . floor ( x ) + Math . floor ( y ) * this . canvas . width ) * 4 ;
269- }
256+ imageData = this . drawingContext . getImageData ( x , y , 1 , 1 ) . data ;
257+ index = 0 ;
270258 return [
271259 imageData [ index + 0 ] ,
272260 imageData [ index + 1 ] ,
@@ -277,8 +265,6 @@ p5.Renderer2D.prototype._getPixel = function(x, y) {
277265
278266p5 . Renderer2D . prototype . loadPixels = function ( ) {
279267 const pixelsState = this . _pixelsState ; // if called by p5.Image
280- if ( ! pixelsState . _pixelsDirty ) return ;
281- pixelsState . _pixelsDirty = false ;
282268
283269 const pd = pixelsState . _pixelDensity ;
284270 const w = this . width * pd ;
@@ -304,7 +290,6 @@ p5.Renderer2D.prototype.set = function(x, y, imgOrCol) {
304290 ) ;
305291 this . drawingContext . drawImage ( imgOrCol . canvas , x , y ) ;
306292 this . drawingContext . restore ( ) ;
307- pixelsState . _pixelsDirty = true ;
308293 } else {
309294 let r = 0 ,
310295 g = 0 ,
@@ -316,7 +301,7 @@ p5.Renderer2D.prototype.set = function(x, y, imgOrCol) {
316301 pixelsState . _pixelDensity *
317302 ( this . width * pixelsState . _pixelDensity ) +
318303 x * pixelsState . _pixelDensity ) ;
319- if ( ! pixelsState . imageData || pixelsState . _pixelsDirty ) {
304+ if ( ! pixelsState . imageData ) {
320305 pixelsState . loadPixels . call ( pixelsState ) ;
321306 }
322307 if ( typeof imgOrCol === 'number' ) {
@@ -391,10 +376,6 @@ p5.Renderer2D.prototype.updatePixels = function(x, y, w, h) {
391376 }
392377
393378 this . drawingContext . putImageData ( pixelsState . imageData , x , y , 0 , 0 , w , h ) ;
394-
395- if ( x !== 0 || y !== 0 || w !== this . width || h !== this . height ) {
396- pixelsState . _pixelsDirty = true ;
397- }
398379} ;
399380
400381//////////////////////////////////////////////
@@ -479,7 +460,6 @@ p5.Renderer2D.prototype.arc = function(x, y, w, h, start, stop, mode) {
479460 }
480461 ctx . closePath ( ) ;
481462 ctx . fill ( ) ;
482- this . _pixelsState . _pixelsDirty = true ;
483463 }
484464
485465 // Stroke curves
@@ -501,7 +481,6 @@ p5.Renderer2D.prototype.arc = function(x, y, w, h, start, stop, mode) {
501481 ctx . closePath ( ) ;
502482 }
503483 ctx . stroke ( ) ;
504- this . _pixelsState . _pixelsDirty = true ;
505484 }
506485 return this ;
507486} ;
@@ -544,11 +523,9 @@ p5.Renderer2D.prototype.ellipse = function(args) {
544523 ctx . closePath ( ) ;
545524 if ( doFill ) {
546525 ctx . fill ( ) ;
547- this . _pixelsState . _pixelsDirty = true ;
548526 }
549527 if ( doStroke ) {
550528 ctx . stroke ( ) ;
551- this . _pixelsState . _pixelsDirty = true ;
552529 }
553530} ;
554531
@@ -563,7 +540,6 @@ p5.Renderer2D.prototype.line = function(x1, y1, x2, y2) {
563540 ctx . moveTo ( x1 , y1 ) ;
564541 ctx . lineTo ( x2 , y2 ) ;
565542 ctx . stroke ( ) ;
566- this . _pixelsState . _pixelsDirty = true ;
567543 return this ;
568544} ;
569545
@@ -588,7 +564,6 @@ p5.Renderer2D.prototype.point = function(x, y) {
588564 ctx . fillRect ( x , y , 1 , 1 ) ;
589565 }
590566 this . _setFill ( f ) ;
591- this . _pixelsState . _pixelsDirty = true ;
592567} ;
593568
594569p5 . Renderer2D . prototype . quad = function ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) {
@@ -616,7 +591,6 @@ p5.Renderer2D.prototype.quad = function(x1, y1, x2, y2, x3, y3, x4, y4) {
616591 if ( doStroke ) {
617592 ctx . stroke ( ) ;
618593 }
619- this . _pixelsState . _pixelsDirty = true ;
620594 return this ;
621595} ;
622596
@@ -706,7 +680,6 @@ p5.Renderer2D.prototype.rect = function(args) {
706680 if ( this . _doStroke ) {
707681 ctx . stroke ( ) ;
708682 }
709- this . _pixelsState . _pixelsDirty = true ;
710683 return this ;
711684} ;
712685
@@ -736,11 +709,9 @@ p5.Renderer2D.prototype.triangle = function(args) {
736709 ctx . closePath ( ) ;
737710 if ( doFill ) {
738711 ctx . fill ( ) ;
739- this . _pixelsState . _pixelsDirty = true ;
740712 }
741713 if ( doStroke ) {
742714 ctx . stroke ( ) ;
743- this . _pixelsState . _pixelsDirty = true ;
744715 }
745716} ;
746717
@@ -1000,7 +971,6 @@ p5.Renderer2D.prototype.endShape = function(
1000971 vertices . pop ( ) ;
1001972 }
1002973
1003- this . _pixelsState . _pixelsDirty = true ;
1004974 return this ;
1005975} ;
1006976//////////////////////////////////////////////
@@ -1102,8 +1072,6 @@ p5.Renderer2D.prototype._doFillStrokeClose = function(closeShape) {
11021072 if ( this . _doStroke ) {
11031073 this . drawingContext . stroke ( ) ;
11041074 }
1105-
1106- this . _pixelsState . _pixelsDirty = true ;
11071075} ;
11081076
11091077//////////////////////////////////////////////
@@ -1200,8 +1168,6 @@ p5.Renderer2D.prototype._renderText = function(p, line, x, y, maxY) {
12001168 }
12011169
12021170 p . pop ( ) ;
1203-
1204- this . _pixelsState . _pixelsDirty = true ;
12051171 return p ;
12061172} ;
12071173
0 commit comments