Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active June 25, 2017 17:17
Show Gist options
  • Save behreajj/736d6ce5d3007a91a40dbecce67d3f25 to your computer and use it in GitHub Desktop.
Save behreajj/736d6ce5d3007a91a40dbecce67d3f25 to your computer and use it in GitHub Desktop.
Color Gradients 2-5
Gradient(ColorStop... cs) {
int sz = cs.length;
for (int i = 0; i < sz; ++i) {
colors.add(cs[i]);
}
if (sz > 1) {
java.util.Collections.sort(colors);
removeDuplicates();
}
}
void removeDuplicates() {
for (int sz = colors.size(), i = sz - 1; i > 0; --i) {
if (colors.get(i).approximates(colors.get(i - 1), TOLERANCE)) {
println(colors.get(i) + " removed.");
colors.remove(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment