Created
April 10, 2011 21:29
-
-
Save rodrigovidal/912739 to your computer and use it in GitHub Desktop.
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
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