Created
March 29, 2020 12:30
-
-
Save fmal/42fe7713ca7193ea2450c0dd9427c455 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Get the type size for the given step | |
* @param {number} step | |
* @returns {number} | |
*/ | |
export function getTypeSize(step) { | |
if (step <= 1) { | |
return 12; | |
} | |
// Yn = Yn-1 + {FLOOR[(n - 2) / 4] + 1} * 2 | |
return getTypeSize(step - 1) + Math.floor((step - 2) / 4 + 1) * 2; | |
} | |
/** | |
* The default type scale for 23 steps. Inlined as an array here through running | |
* the follow step: | |
* | |
* > Array.from({ length: 23 }, (_, i) => getTypeSize(i + 1)) | |
*/ | |
export const scale = [ | |
12, | |
14, | |
16, | |
18, | |
20, | |
24, | |
28, | |
32, | |
36, | |
42, | |
48, | |
54, | |
60, | |
68, | |
76, | |
84, | |
92, | |
102, | |
112, | |
122, | |
132, | |
144, | |
156, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment