UNPKG

consonance

Version:
47 lines (36 loc) 1.32 kB
Turns a mess of font sizes into a nice consistent scale. ## Usage Pass in an array of your current font sizes, and some options to generate a [modular scale](https://github.com/jxnblk/simple-modular-scale). ```js var consonance = require('consonance'); var input = [10, 15, 17, 22, 23, 24, 34, 37, 47, 50, 68, 74]; var options = { base: 16, ratios: [3/2, 4/3], length: 8 } consonance(input, options); ``` Alternatively, provide own typographic scale as an array of pixel sizes. ```js var consonance = require('consonance'); var input = [10, 15, 17, 22, 23, 24, 34, 37, 47, 50, 68, 74]; var scale = [10, 16, 24, 36, 48, 72]; consonance(input, scale); ``` Consonance returns an array of objects containing the "input" and what we transformed it to. **WIP** - data structure might change before 1.0.0. ```json [ { "input": 10, "output": 10, "i": 0 }, { "input": 15, "output": 16, "i": 1 }, { "input": 17, "output": 16, "i": 2 }, { "input": 22, "output": 24, "i": 3 }, { "input": 23, "output": 24, "i": 4 }, { "input": 24, "output": 24, "i": 5 }, { "input": 34, "output": 36, "i": 6 }, { "input": 37, "output": 36, "i": 7 }, { "input": 47, "output": 48, "i": 8 }, { "input": 50, "output": 48, "i": 9 }, { "input": 68, "output": 72, "i": 10 }, { "input": 74, "output": 72, "i": 11 } ] ```