Created
June 25, 2018 16:55
-
-
Save cyrilmottier/fba31e86155a9506d38a0053738a8fe7 to your computer and use it in GitHub Desktop.
This file contains 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
val colorCount = RAINBOW_COLORS.size | |
val colors = IntArray(colorCount * 2) | |
val stops = FloatArray(colorCount * 2) | |
for (i in 0 until colorCount) { | |
colors[i * 2] = ContextCompat.getColor(context, RAINBOW_COLORS[i]) | |
colors[i * 2 + 1] = colors[i * 2] | |
stops[i * 2] = (i / colorCount.toFloat() + RAINBOW_EPSILON).coerceAtLeast(0f) | |
stops[i * 2 + 1] = ((i + 1) / colorCount.toFloat() - RAINBOW_EPSILON).coerceAtMost(1f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment