Skip to content

Instantly share code, notes, and snippets.

@rodrigovidal
Created April 10, 2011 21:29
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 rodrigovidal/912739 to your computer and use it in GitHub Desktop.
Save rodrigovidal/912739 to your computer and use it in GitHub Desktop.
public class Color
{
private readonly int red;
private readonly int green;
private readonly int blue;
public Color(int red, int green, int blue)
{
this.red = red;
this.green = green;
this.blue = blue;
}
public Color MixColor(Color color)
{
var newRed = CalculateComponent(this.red, color.red);
var newGreen = CalculateComponent(this.red, color.green);
var newBlue = CalculateComponent(this.red, color.blue);
return new Color(newRed, newGreen, newBlue);
}
private int CalculateComponent(int oldColor, int newColor)
{
return (oldColor + newColor)/2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment