Round coords when adding point

This commit is contained in:
Wuzzy 2023-10-27 18:41:03 +02:00
parent 1079a13836
commit 6d58284119

View File

@ -1452,8 +1452,8 @@ function updatePointWhenDragged(pointID) {
if (points[i].id === dragDropPointID) { if (points[i].id === dragDropPointID) {
selectedPoint = points[i]; selectedPoint = points[i];
let [newHeat, newHumidity] = canvasPixelCoordsToBiomeCoords(event.offsetX, event.offsetY); let [newHeat, newHumidity] = canvasPixelCoordsToBiomeCoords(event.offsetX, event.offsetY);
selectedPoint.heat = newHeat; selectedPoint.heat = Math.round(newHeat);
selectedPoint.humidity = newHumidity; selectedPoint.humidity = Math.round(newHumidity);
draw(true); draw(true);
updateWidgetStates(); updateWidgetStates();
let [elemID, elem] = getSelectedBiomeIDAndElement(); let [elemID, elem] = getSelectedBiomeIDAndElement();
@ -1763,6 +1763,8 @@ voronoiCanvas.ondblclick = function(event) {
return; return;
} }
let [he, hu] = canvasPixelCoordsToBiomeCoords(event.offsetX, event.offsetY); let [he, hu] = canvasPixelCoordsToBiomeCoords(event.offsetX, event.offsetY);
he = Math.round(he);
hu = Math.round(hu);
addBiome({name: generateBiomeName(lastBiomeID), heat:he, humidity: hu, min_y:MIN_Y_DEFAULT, max_y:MAX_Y_DEFAULT}); addBiome({name: generateBiomeName(lastBiomeID), heat:he, humidity: hu, min_y:MIN_Y_DEFAULT, max_y:MAX_Y_DEFAULT});
} }
voronoiCanvas.onmouseup = function(event) { voronoiCanvas.onmouseup = function(event) {