From fd25ee0127c4b88421723ab212af0313c20fef4b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:02:19 -0700 Subject: [PATCH] Add some doc comments --- src/browser/renderer/BoxAndBlockCharacters.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 42608295c..48645d037 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -125,6 +125,7 @@ const enum Style { } // TODO: Tweak normal and bold weights +// This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, @@ -320,18 +321,26 @@ function translateArgs(args: string[], cellWidth: number, cellHeight: number, xO } for (let x = 0; x < result.length; x += 2) { + // Translate from 0-1 to 0-cellWidth result[x] *= cellWidth; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[x] !== 0) { result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0); } + // Apply the cell's offset (ie. x*cellWidth) result[x] += xOffset; } for (let y = 1; y < result.length; y += 2) { + // Translate from 0-1 to 0-cellHeight result[y] *= cellHeight; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[y] !== 0) { result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0); } + // Apply the cell's offset (ie. x*cellHeight) result[y] += yOffset; }