Fix clearing to color

This commit is contained in:
Joshua Bell 2012-08-09 17:48:41 -04:00
parent 241e8dc76d
commit 0432f932c0

View File

@ -26,7 +26,7 @@
// Usage: // Usage:
// //
// var hires = new LoRes( element, width, height ) // var hires = new LoRes( element, width, height )
// hires.clear() // hires.clear( [color_index] )
// hires.setColor( color_index ) // hires.setColor( color_index )
// hires.plot( x, y ) // hires.plot( x, y )
// hires.plot_to( x, x ) // hires.plot_to( x, x )
@ -70,19 +70,16 @@ function HiRes(element, width, height) {
'#ffffff' // White 2 '#ffffff' // White 2
]; ];
this.clear = function(use_color) { this.clear = function(opt_color) {
var i; var i;
if (!use_color) { context.clearRect(0, 0, element.width, element.height);
context.clearRect(0, 0, element.width, element.height); pixels = [];
pixels = []; pixels.length = width * height;
pixels.length = width * height; if (arguments.length >= 1) {
} else { context.fillStyle = COLORS[opt_color];
context.fillStyle = COLORS[color];
context.fillRect(0, 0, element.width, element.height); context.fillRect(0, 0, element.width, element.height);
pixels = [];
pixels.length = width * height;
for (i = 0; i < pixels.length; i += 1) { for (i = 0; i < pixels.length; i += 1) {
pixels[i] = color; pixels[i] = opt_color;
} }
} }
}; };