Last active
July 11, 2022 11:16
-
-
Save tol-is/c97ac60e465811043881820e1b7945db to your computer and use it in GitHub Desktop.
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
export const carbonScale = (params = {}) => { | |
const { | |
length = 20, | |
minSize = 10, | |
intervals = 4, | |
increment = 2, | |
transform = v => v | |
} = params; | |
const getSize = count => { | |
if (count <= 1) { | |
return minSize; | |
} | |
return ( | |
getSize(count - 1) + Math.floor((count - 2) / intervals + 1) * increment | |
); | |
}; | |
return Array.from({ length: length }, (_, i) => getSize(i + 1)).map( | |
transform | |
); | |
}; | |
const scale = carbonScale(); | |
console.log(scale); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment