Fix flickering of point texts on resize

This commit is contained in:
Wuzzy 2024-12-07 17:03:48 +01:00
parent 217caf532b
commit e6ed706163

View File

@ -427,17 +427,17 @@ function putPointName(context, point) {
if (he < limit_heat_min || he > limit_heat_max || hu < limit_humidity_min || hu > limit_humidity_max) { if (he < limit_heat_min || he > limit_heat_max || hu < limit_humidity_min || hu > limit_humidity_max) {
return; return;
} }
let heat_range = limit_heat_max - limit_heat_min;
let humidity_range = limit_humidity_max - limit_humidity_min;
let [x, y] = biomeCoordsToCanvasPixelCoords(he, hu); let [x, y] = biomeCoordsToCanvasPixelCoords(he, hu);
let w = voronoiCanvas.width; if (he > (limit_heat_min + heat_range/2)) {
let h = voronoiCanvas.height;
if (x > w/2) {
context.textAlign = "right"; context.textAlign = "right";
x = x-5; x = x-5;
} else { } else {
context.textAlign = "left"; context.textAlign = "left";
x = x+5; x = x+5;
} }
if (y < h/2) { if (hu > (limit_humidity_min + humidity_range/2)) {
context.textBaseline = "top"; context.textBaseline = "top";
} else { } else {
context.textBaseline = "alphabetic"; context.textBaseline = "alphabetic";