Skip to content

Commit

Permalink
Merge pull request #25 from the-via/include-decal-keys
Browse files Browse the repository at this point in the history
Include decal keys when parsing KLE to render more accurately
  • Loading branch information
olivia authored Mar 7, 2023
2 parents 1c9f9f1 + b554cac commit 46631c0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@the-via/reader",
"version": "1.6.0",
"version": "1.7.0",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/the-via/reader.git"
Expand Down
10 changes: 5 additions & 5 deletions src/kle-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ export function extractGroups(
...res,
x: res.x - delta.x,
y: res.y - delta.y,
})))(calculateDelta2(zeroPivot, findPivot(results)))
.filter((r) => !r.d) // Remove decal keys
.map((r) => resultToVIAKey(r, origin, colorMap)), // Resolve key colors and normalize position using origin
})))(calculateDelta2(zeroPivot, findPivot(results))).map((r) =>
resultToVIAKey(r, origin, colorMap)
), // Resolve key colors and normalize position using origin
}),
{}
);
Expand Down Expand Up @@ -196,7 +196,7 @@ function resultToVIAKey(
delta: {x: number; y: number},
colorMap: {[x: string]: KeyColorType}
): VIAKey {
const {c, d, t, group, ...partialKey} = result;
const {c, t, group, ...partialKey} = result;
return {
...partialKey,
x: result.x - delta.x,
Expand Down Expand Up @@ -482,7 +482,7 @@ export function kleLayoutToVIALayout(kle: KLELayout): VIALayout {
const width = Math.max(...boundingBoxes.map((b) => b.xEnd)) - minX;
const height = Math.max(...boundingBoxes.map((b) => b.yEnd)) - minY;
const keys = defaultRes
.filter((k) => k.group.key === -1 && !k.d) // Remove option keys and decals
.filter((k) => k.group.key === -1) // Remove option keys
.map((k) => resultToVIAKey(k, {x: minX, y: minY}, colorMap));
const optionKeys = extractGroups(flatRes, {x: minX, y: minY}, colorMap);

Expand Down
2 changes: 1 addition & 1 deletion src/types.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export type Result = {h: number; w: number} & Formatting &
Decal &
GroupMeta;

export type VIAKey = Omit<Result, keyof Formatting | 'group' | 'd'> & {
export type VIAKey = Omit<Result, keyof Formatting | 'group'> & {
color: KeyColorType;
};

Expand Down

0 comments on commit 46631c0

Please sign in to comment.