Skip to content

Instantly share code, notes, and snippets.

@mattparker
Created November 6, 2012 17:27
Show Gist options
  • Save mattparker/4026185 to your computer and use it in GitHub Desktop.
Save mattparker/4026185 to your computer and use it in GitHub Desktop.
idea for kb refactor of Y.Color.Harmony
/**
Generates a series of colors from startColor at various offsets
@protected
@method _getOffsetAndFinish
@param {String} startColor Start color
@param {Array} arrOffsets Array of colors
@param {String} [to]
@returns {Array} Of offsetted and finished colors
**/
_getOffsetAndFinish: function (startColor, arrOffsets, to) {
var ret = [],
i = 0,
c0 = Harmony._start(startColor),
to = to || Color.findType(startColor);
for (;i < arrOffsets.length; i = i + 1) {
ret.push(Harmony.finish(Harmony.getOffset(c0, {h: arrOffset[i]})), to);
}
return ret;
}
// so something like getTriad becomes something like
// ie quite a lot smaller kb wise
getTriad: function (str, to) {
return Harmony._getOffsetAndFinish(str, [0, TRIAD_OFFSET, -TRIAD_OFFSET], to);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment