bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.08k stars 438 forks source link

Polyad colors #126

Closed jpwesterhof closed 1 year ago

jpwesterhof commented 8 years ago
jpwesterhof commented 8 years ago

I was a bit messy with my first two commits, because I copy pasted it from code I currently use. Hence the two follow up commits with fixes to these two forgotten characters (, and ;).

bgrins commented 8 years ago

Alright, sounds good. I'd rather only export triad and tetrad (and not export all the others), but then expose the new one that allows a variable number of outputs. I believe we could call it 'polyad', which is what I could find as the name for these groupings: https://en.wiktionary.org/wiki/polyad

jpwesterhof commented 8 years ago

Done

jpwesterhof commented 8 years ago

Forgot about the internals... done

thaliaarchi commented 8 years ago

This sounds like a cool idea. These need to pass arguments to _applyCombination like the other public methods. So, just make the private triad and tetrad functions call polyad with 3 or 4 as n.

triad: function() {
    return this._applyCombination(triad, arguments);
},
tetrad: function() {
    return this._applyCombination(tetrad, arguments);
},
polyad: function() {
    return this._applyCombination(polyad, arguments);
}

...

function triad(color) {
    return polyad(color, 3);
}

function tetrad(color) {
    return polyad(color, 4);
}
bgrins commented 1 year ago

Landed this in #250. Thanks @jpwesterhof and sorry for dropping this