💹 Optimize draw()

main
Shad Amethyst 2 years ago
parent c560655f1f
commit be94e01bad
Signed by: amethyst
GPG Key ID: D970C8DD1D6DEE36

@ -96,10 +96,10 @@ function draw() {
let index = 3 * (width * (y - from_y) + x - from_x); let index = 3 * (width * (y - from_y) + x - from_x);
let ch = String.fromCharCode(chars[index]); let ch = String.fromCharCode(chars[index]);
if (ch !== " ") {
let fg = to_color(chars[index + 1]); let fg = to_color(chars[index + 1]);
let bg = chars[index + 2] === 0 ? null : to_color(chars[index + 2]); let bg = chars[index + 2] === 0 ? null : to_color(chars[index + 2]);
if (ch !== " ") {
if (bg) { if (bg) {
ctx.fillStyle = `rgba(${bg.join(",")})`; ctx.fillStyle = `rgba(${bg.join(",")})`;
ctx.fillRect( ctx.fillRect(
@ -126,16 +126,19 @@ function draw() {
} }
} }
ctx.fillStyle = inside ? "#606060" : "#404040"; if (inside || width < 100 && height < 100) {
ctx.fillStyle = inside ? "#505050" : "#303030";
ctx.fillRect( ctx.fillRect(
Math.round(x2 + tile_size / 2) - zoom_factor, Math.round(x2 + tile_size / 2) - zoom_factor,
Math.round(y2 + tile_size / 2) - zoom_factor, Math.round(y2 + tile_size / 2) - zoom_factor,
Math.max(zoom_factor, 2.0), zoom_factor,
Math.max(zoom_factor, 2.0) zoom_factor
); );
} }
} }
} }
}
} }
function resize() { function resize() {

Loading…
Cancel
Save