Skip to content

Commit

Permalink
Slightly change background caching
Browse files Browse the repository at this point in the history
  • Loading branch information
iseau395 committed Oct 16, 2023
1 parent c3a7628 commit 91c6219
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib/map/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const game: Promise<Game> = new Promise<Game>(async (resolve) => {

export const path = new Path();

export const cache_scale = 3.5;
export const cache_scale = 3;
const bg_cache = document.createElement("canvas");
bg_cache.width = field_side * inch_pixel_ratio * cache_scale;
bg_cache.height = field_side * inch_pixel_ratio * cache_scale;
Expand Down Expand Up @@ -141,13 +141,11 @@ export async function draw_field_bg(ctx: CanvasRenderingContext2D) {
init_load = true;
}

ctx.save();
ctx.translate(field_x, field_y);
ctx.scale(field_scale / cache_scale, field_scale / cache_scale);

ctx.drawImage(bg_cache, 0, 0);

ctx.restore();
ctx.drawImage(bg_cache,
field_x, field_y,
field_side * inch_pixel_ratio * field_scale,
field_side * inch_pixel_ratio * field_scale
);
}

export function draw_field(fg_ctx: CanvasRenderingContext2D, bg_ctx: CanvasRenderingContext2D, draw_background: boolean) {
Expand Down

0 comments on commit 91c6219

Please sign in to comment.