Skip to content

Instantly share code, notes, and snippets.

@cyrilmottier
Created June 25, 2018 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrilmottier/1f828ef09092efaec553cc0e199334a7 to your computer and use it in GitHub Desktop.
Save cyrilmottier/1f828ef09092efaec553cc0e199334a7 to your computer and use it in GitHub Desktop.
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()
stops[i * 2 + 1] = (i + 1) / colorCount.toFloat()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment