Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Last active September 6, 2020 11:44
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 ssukhpinder/33f204f3fda8ab97326b2b06a091405d to your computer and use it in GitHub Desktop.
Save ssukhpinder/33f204f3fda8ab97326b2b06a091405d to your computer and use it in GitHub Desktop.
public static NewSwitch FromRainbow(Color color) =>
color switch
{
Color.Red => new NewSwitch(0xFF, 0x00, 0x00),
Color.Orange => new NewSwitch(0xFF, 0x7F, 0x00),
Color.Yellow => new NewSwitch(0xFF, 0xFF, 0x00),
Color.Green => new NewSwitch(0x00, 0xFF, 0x00),
Color.Blue => new NewSwitch(0x00, 0x00, 0xFF),
Color.Indigo => new NewSwitch(0x4B, 0x00, 0x82),
Color.Violet => new NewSwitch(0x94, 0x00, 0xD3),
_ => throw new ArgumentException(message: "invalid color", paramName: nameof(color)),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment