From 0432f932c0c8a61e997f36649631d03f9f21237a Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 9 Aug 2012 17:48:41 -0400 Subject: [PATCH] Fix clearing to color --- hires.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hires.js b/hires.js index 4659d7d..da2bc80 100644 --- a/hires.js +++ b/hires.js @@ -26,7 +26,7 @@ // Usage: // // var hires = new LoRes( element, width, height ) -// hires.clear() +// hires.clear( [color_index] ) // hires.setColor( color_index ) // hires.plot( x, y ) // hires.plot_to( x, x ) @@ -70,19 +70,16 @@ function HiRes(element, width, height) { '#ffffff' // White 2 ]; - this.clear = function(use_color) { + this.clear = function(opt_color) { var i; - if (!use_color) { - context.clearRect(0, 0, element.width, element.height); - pixels = []; - pixels.length = width * height; - } else { - context.fillStyle = COLORS[color]; + context.clearRect(0, 0, element.width, element.height); + pixels = []; + pixels.length = width * height; + if (arguments.length >= 1) { + context.fillStyle = COLORS[opt_color]; context.fillRect(0, 0, element.width, element.height); - pixels = []; - pixels.length = width * height; for (i = 0; i < pixels.length; i += 1) { - pixels[i] = color; + pixels[i] = opt_color; } } };