diff --git a/src/lib/components/layout/KeyText.svelte b/src/lib/components/layout/KeyText.svelte index 45c9b2be..37eb5a82 100644 --- a/src/lib/components/layout/KeyText.svelte +++ b/src/lib/components/layout/KeyText.svelte @@ -30,7 +30,10 @@ (title ?? id ?? `0x${code.toString(16)}`) + (variant === "left" ? " (left)" : variant === "right" ? " (right)" : "")} {@const isActive = layer === $activeLayer} - {@const direction = [(middle[0] - margin * 3) / position[0], (middle[1] - margin * 3) / position[1]]} + {@const direction = [ + Math.sign(middle[0]) * (Math.abs(middle[0]) - margin * 3) * position[0], + Math.sign(middle[1]) * (Math.abs(middle[1]) - margin * 3) * position[1], + ]} {@const hasIcon = !dynamicMapping && !!icon} diff --git a/src/lib/components/layout/KeyboardKey.svelte b/src/lib/components/layout/KeyboardKey.svelte index 6e1bc436..6814441c 100644 --- a/src/lib/components/layout/KeyboardKey.svelte +++ b/src/lib/components/layout/KeyboardKey.svelte @@ -42,23 +42,30 @@ {@const r2 = r1 - sizeY + innerMargin * 2} {@const p2 = r2 - innerMargin} {@const multiplier = 1.25} - - - - + + {@const rotateRad = (key.rotate + 45) * (Math.PI / 180)} + {@const rotX = Math.round((Math.abs(Math.cos(rotateRad - Math.PI / 2)) + Number.EPSILON) * 100) / 100} + {@const rotY = Math.round((Math.abs(Math.sin(rotateRad - Math.PI / 2)) + Number.EPSILON) * 100) / 100} + + {@const rc = r1 - (r1 - r2) / 2} + {@const middleX = Math.cos(rotateRad) * rc} + {@const middleY = Math.sin(rotateRad) * rc} + + {/if} @@ -71,6 +78,7 @@ transform-box: fill-box; } + path, g { transform-origin: top left; transform-box: fill-box;