From bc45702f20959d282a548990fa21db7821a92300 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Thu, 14 May 2026 21:53:42 -0400 Subject: [PATCH] Fix an error that can break the canvas when importing or resetting a character --- module/canvas/placeables/token.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/canvas/placeables/token.mjs b/module/canvas/placeables/token.mjs index 77c178d6..01419abe 100644 --- a/module/canvas/placeables/token.mjs +++ b/module/canvas/placeables/token.mjs @@ -262,10 +262,10 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token { const fillColor = number === 0 ? foundry.utils.Color.fromRGB([1, 0, 0]) : foundry.utils.Color.fromString('#0032b1'); - // Draw the bar - const widthUnit = bw / data.max; + // Draw the bar (accounting for possible floating point numbers) + const widthUnit = bw / Math.ceil(data.max); bar.clear().lineStyle(s, 0x000000, 1.0); - const sections = [...Array(data.max).keys()]; + const sections = [...Array(Math.ceil(data.max)).keys()]; for (let mark of sections) { const x = mark * widthUnit; const marked = mark + 1 <= data.value;