-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hex): rename createToPoint() to hexToPoint() and make it accept …
…a hex This was (also) done to improve performance and have a simpler interface
- Loading branch information
1 parent
9a9b4a9
commit 4227737
Showing
4 changed files
with
15 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Hex, Orientation, Point } from '../types' | ||
|
||
export const hexToPoint = ({ orientation, dimensions: { xRadius, yRadius }, q, r }: Hex) => | ||
orientation === Orientation.POINTY | ||
? ({ | ||
x: xRadius * Math.sqrt(3) * (q + r / 2), | ||
y: ((yRadius * 3) / 2) * r, | ||
} as Point) | ||
: ({ | ||
x: ((xRadius * 3) / 2) * q, | ||
y: yRadius * Math.sqrt(3) * (r + q / 2), | ||
} as Point) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.