Created
June 25, 2017 16:40
-
-
Save behreajj/6e5a819c1f67f9546389417d3687f575 to your computer and use it in GitHub Desktop.
Color Gradients 2-1
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
class ColorStop implements Comparable<ColorStop> { | |
float percent; | |
color clr; | |
ColorStop(float prc, float v1, float v2, float v3) { | |
this(prc, color(v1, v2, v3)); | |
} | |
ColorStop(float prc, float v1, float v2, float v3, float al) { | |
this(prc, color(v1, v2, v3, al)); | |
} | |
ColorStop(float prc, color c) { | |
percent = prc < 0 ? 0 : prc > 1 ? 1 : prc; | |
clr = c; | |
} | |
String toString() { | |
return nf(percent, 0, 3) + " 0x" + hex(clr); | |
} | |
int compareTo(ColorStop cs) { | |
return percent > cs.percent ? 1 : percent < cs.percent ? -1 : 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment