Last active
April 25, 2020 15:24
-
-
Save cosminpopescu14/86fdffdc92c9234796513b850771b277 to your computer and use it in GitHub Desktop.
Generate a rgb color from a hashcode
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
using System; | |
using System.Data.SqlClient; | |
using System.Drawing; | |
using System.Linq; | |
using HashcodeToColor; | |
namespace HashcodeToColor | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var source = ToHexColor("Employee".ToCharArray().Select(it => { return (int)it; }).Sum()); | |
var color = (Color)new ColorConverter().ConvertFromString($"#{source}"); | |
Console.WriteLine($"color is {color.GetHue()}"); | |
Console.ReadLine(); | |
} | |
static string ToHexColor(int i) | |
{ | |
return ((i >> 24) & 0xFF).ToHex() | |
+ ((i >> 16) & 0xFF).ToHex() | |
+ ((i >> 8) & 0xFF).ToHex() | |
+ (i & 0xFF).ToHex(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment