Skip to content

Instantly share code, notes, and snippets.

@patridge
Last active August 23, 2018 15:52

Revisions

  1. patridge revised this gist Apr 11, 2014. No changes.
  2. patridge created this gist Apr 11, 2014.
    24 changes: 24 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    // Xamarin.iOS (using MonoTouch.UIKit;)
    static Random rand = new Random();
    public static UIColor GetRandomColor() {
    int hue = rand.Next(255);
    UIColor color = UIColor.FromHSB(
    (hue / 255.0f),
    1.0f,
    1.0f);
    return color;
    }

    // Xamarin.Android (using Android.Graphics;)
    static Random rand = new Random();
    public static Color GetRandomColor() {
    int hue = rand.Next(255);
    Color color = Color.HSVToColor(
    new[] {
    hue,
    1.0f,
    1.0f,
    }
    );
    return color;
    }