grad({
src: ["#ffffff","#000000"], // array of colours, as many as you need
i: 10, // length of output / iterations required
accuracy: 5, // (for rgb/raw output) number of decimal places
rgb: 0, // output as rgb string
raw: 0, // output as raw rgb array
up: 0 // for multi-gradients round down by default for grouping
})
Outputs: ["ffffff", "e3e3e3", "c6c6c6", "aaaaaa", "8e8e8e", "717171", "555555", "393939", "1c1c1c", "000000"]
Name | Size (bytes) | Desc |
---|---|---|
index.min.js | 966 | full api usage |
index.no-shorthand.js | 865 | full api usage, no shorthand functionality |
index.simpleGrad.js | 566 | only able to generate single grads, no - rgb, raw or shorthand |
index.simpleMulitGrad.js | 765 | Can create multi grads, no - rgb, raw or shorthand |
* index.simpleMultiGrad-shorthand.js |
860 | Can create multi grads & use shorthand, no - rgb or raw |
*
My personal favourite
For some multi gradients, due to rounding issues, it will not be able to create the exact number of values as requested. In these situations, it will always round down, and thus produce less than requested - never more. (Usually only ever by 1 or 2)
If you 100% require atleast the number you ask for, you can add up:true
to the arguments, you'll end up probably recieving more (by 1 or 2).
["ffffff", "e3e3e3", "c6c6c6", "aaaaaa", "8e8e8e", "717171", "555555", "393939", "1c1c1c", "000000"]
["ff0000", "bf4000", "808000", "40bf00", "00ff00", "00bf40", "008080", "0040bf", "0000ff"]
Note - It cannot produce the requested length (10) in this instance.
It will always opt return an array length less than requested amount, rather than go over. (In some circumstances you might want more - just use Math.ceil, rather than Math.floor)
["ff0000", "aa5500", "55aa00", "00ff00", "00aa55", "0055aa", "0000ff", "0000aa", "000055", "000000"]
["rgb(255,255,255)", "rgb(191.25,191.25,191.25)", "rgb(127.5,127.5,127.5)", "rgb(63.75,63.75,63.75)", "rgb(0,0,0)"]
["rgb(255,255,255)", "rgb(191.3,191.3,191.3)", "rgb(127.5,127.5,127.5)", "rgb(63.8,63.8,63.8)", "rgb(0,0,0)"]
[[255, 255, 255], [191.25, 191.25, 191.25], [127.5, 127.5, 127.5], [63.75, 63.75, 63.75], [0, 0, 0]]