mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2025-05-15 15:38:13 +00:00
Fix clearing to color
This commit is contained in:
parent
241e8dc76d
commit
0432f932c0
19
hires.js
19
hires.js
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user