From 4cbfd86db033b3af80d8a58c33cbf2d2f9c25616 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 10 Jul 2022 05:44:44 -0700 Subject: [PATCH] Make corder box chars more round Fixes #3894 --- src/browser/renderer/CustomGlyphs.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 968a877d..fcb0ba8d 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -179,11 +179,17 @@ const enum Style { BOLD = 3 } +/** + * @param xp The percentage of 15% of the x axis. + * @param yp The percentage of 15% of the x axis on the y axis. + */ +type DrawFunctionDefinition = (xp: number, yp: number) => string; + /** * This contains the definitions of all box drawing characters in the format of SVG paths (ie. the * svg d attribute). */ -export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { +export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | DrawFunctionDefinition } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -319,10 +325,10 @@ export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL }, // Curved - '╭': { [Style.NORMAL]: 'C.5,1,.5,.5,1,.5' }, - '╮': { [Style.NORMAL]: 'C.5,1,.5,.5,0,.5' }, - '╯': { [Style.NORMAL]: 'C.5,0,.5,.5,0,.5' }, - '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' } + '╭': { [Style.NORMAL]: (xp, yp) => `M.5,1 L.5,${.5 + (yp / .15 * .5)} C.5,${.5 + (yp / .15 * .5)},.5,.5,1,.5` }, + '╮': { [Style.NORMAL]: (xp, yp) => `M.5,1 L.5,${.5 + (yp / .15 * .5)} C.5,${.5 + (yp / .15 * .5)},.5,.5,0,.5` }, + '╯': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 - (yp / .15 * .5)} C.5,${.5 - (yp / .15 * .5)},.5,.5,0,.5` }, + '╰': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 - (yp / .15 * .5)} C.5,${.5 - (yp / .15 * .5)},.5,.5,1,.5` } }; interface IVectorShape {