Last active
December 30, 2016 17:09
-
-
Save dannycabrera/e1478e745389e66e812b8fab19f068f5 to your computer and use it in GitHub Desktop.
Random pastel color generator
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
using System; | |
using UIKit; | |
// based on http://blog.functionalfun.net/2008/07/random-pastel-colour-generator.html | |
public static UIColor RandomColor () | |
{ | |
Random random = new Random (); | |
// to create lighter colors: | |
// take a random integer between 0 & 128 (rather than between 0 and 255) | |
// and then add 127 to make the color lighter | |
int red = random.Next (128) + 127; | |
int green = random.Next (128) + 127; | |
int blue = random.Next (128) + 127; | |
// make color opaque | |
return UIColor.FromRGBA(red, green, blue, 255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment