Guest User

Untitled

a guest
Jun 17th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Color harmonies:triada, complement, analogous, monochromatic
  2. int WrapColor(int colorIndex, int numWheelColors)
  3. {
  4. while(colorIndex < 0)
  5. {
  6. colorIndex += numWheelColors;
  7. }
  8.  
  9. colorIndex = colorIndex % numWheelColors;
  10. }
  11.  
  12. int GetColorWheelIndex(Color color)
  13. {
  14. if (ColorWheelArray.Contains(color))
  15. return ColorWheelArray.IndexOf(color);
  16. else
  17. throw new InvalidArgumentException("color");
  18. }
  19.  
  20. Color[] GetTriadaColors(Color color)
  21. {
  22. int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
  23. return new Color[]
  24. {
  25. color,
  26. ColorWheelArray[WrapColor(colorIndex + ColorWheelArray.Length / 3)],
  27. ColorWheelArray[WrapColor(colorIndex + 2 * ColorWheelArray.Length / 3)]
  28. };
  29. }
  30.  
  31. Color GetComplimentColor(Color color)
  32. {
  33. int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
  34. return ColorWheelArray[WrapColor(colorIndex + ColorWheelArray.Length / 2)];
  35. }
  36.  
  37. Color[] GetAnalogousColors(Color color)
  38. {
  39. int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
  40. return new Color[] { color,
  41. ColorWheelArray[WrapColor(colorIndex + 1)],
  42. ColorWheelArray[WrapColor(colorIndex + 2)] };
  43. }
Advertisement
Add Comment
Please, Sign In to add comment