Skip to content

Instantly share code, notes, and snippets.

@hjerpbakk
Created February 15, 2015 18:37
Show Gist options
  • Save hjerpbakk/3467666fb70140c01479 to your computer and use it in GitHub Desktop.
Save hjerpbakk/3467666fb70140c01479 to your computer and use it in GitHub Desktop.
Get the color given a ratio between a start and end color. From: http://www.hjerpbakk.com/blog/2015/2/15/gradient-colors-on-ios
public static UIColor ColorForRatio(float[] startColor, float[] endColor, float colorRatio) {
return UIColor.FromRGB(startColor[0] + (endColor[0] - startColor[0]) * colorRatio,
startColor[1] + (endColor[1] - startColor[1]) * colorRatio,
startColor[2] + (endColor[2] - startColor[2]) * colorRatio);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment