Last active
June 25, 2017 17:17
-
-
Save behreajj/736d6ce5d3007a91a40dbecce67d3f25 to your computer and use it in GitHub Desktop.
Color Gradients 2-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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