💹 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 ch = String.fromCharCode(chars[index]);
let fg = to_color(chars[index + 1]);
let bg = chars[index + 2] === 0 ? null : to_color(chars[index + 2]);
if (ch !== " ") {
let fg = to_color(chars[index + 1]);
let bg = chars[index + 2] === 0 ? null : to_color(chars[index + 2]);
if (bg) {
ctx.fillStyle = `rgba(${bg.join(",")})`;
ctx.fillRect(
@ -126,13 +126,16 @@ function draw() {
}
}
ctx.fillStyle = inside ? "#606060" : "#404040";
ctx.fillRect(
Math.round(x2 + tile_size / 2) - zoom_factor,
Math.round(y2 + tile_size / 2) - zoom_factor,
Math.max(zoom_factor, 2.0),
Math.max(zoom_factor, 2.0)
);
if (inside || width < 100 && height < 100) {
ctx.fillStyle = inside ? "#505050" : "#303030";
ctx.fillRect(
Math.round(x2 + tile_size / 2) - zoom_factor,
Math.round(y2 + tile_size / 2) - zoom_factor,
zoom_factor,
zoom_factor
);
}
}
}
}

Loading…
Cancel
Save