@@ -52,6 +52,7 @@ var UI = function() {
52
52
53
53
// make checkbox
54
54
$ ( '#drawTree' ) . replaceWith ( '<input type="checkbox" id="drawTree" checked="checked" />' ) ;
55
+ $ ( '#drawFade' ) . replaceWith ( '<input type="checkbox" id="drawFade" checked="checked" />' ) ;
55
56
56
57
// collect all controls in an accordion
57
58
$ ( "#controls" ) . accordion ( { collapsible : true , active : false } ) ;
@@ -278,12 +279,18 @@ UI.prototype.colorArea = function(ctx,startX,startY,rgb,imageData){
278
279
* Fades the previous generation of individuals on the canvas
279
280
*/
280
281
UI . prototype . fade = function ( ) {
281
- var imgData = this . evoCtx . getImageData ( 0 , 0 , window . innerWidth , window . innerHeight ) ;
282
- var pix = imgData . data ;
283
- for ( var i = 0 ; i < pix . length ; i += 4 ) {
284
- pix [ i + 3 ] *= 0.9 ;
282
+ var fade = this . getBoolean ( 'drawFade' ) ;
283
+ if ( fade ) {
284
+ var imgData = this . evoCtx . getImageData ( 0 , 0 , window . innerWidth , window . innerHeight ) ;
285
+ var pix = imgData . data ;
286
+ for ( var i = 0 ; i < pix . length ; i += 4 ) {
287
+ pix [ i + 3 ] *= 0.9 ;
288
+ }
289
+ this . evoCtx . putImageData ( imgData , 0 , 0 ) ;
290
+ }
291
+ else {
292
+ this . evoCtx . clearRect ( 0 , 0 , window . innerWidth , window . innerHeight ) ;
285
293
}
286
- this . evoCtx . putImageData ( imgData , 0 , 0 ) ;
287
294
} ;
288
295
289
296
/**
0 commit comments