/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> public MainViewModel() { var clr = Colors.Red; CurrentColor = new PixelColor(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B); CurrentImage = new BitmapImage(new Uri(DefaultImageUrl, UriKind.RelativeOrAbsolute)); ImageLinks = "http://xamarin.com/"; }
public void TestGreenColorAllFormats() { var color = Color.FromRgb(0, 255, 0); var newcolor = new PixelColor(0, 255, 0); var newColorHex = PixelColor.FromHex("#00FF00"); var newColorHSL = PixelColor.FromHSL(255, 120, 1, 0.5); Assert.IsTrue(color.R == newcolor.Red, "Red is not good"); Assert.IsTrue(color.G == newcolor.Green, "Green is not good"); Assert.IsTrue(color.B == newcolor.Blue, "Blue is not good"); Assert.IsTrue(color.A == newcolor.Alpha, "Alpha is not good"); Assert.IsTrue(color.R == newColorHex.Red, "Red is not good in HEX"); Assert.IsTrue(color.G == newColorHex.Green, "Green is not good in HEX"); Assert.IsTrue(color.B == newColorHex.Blue, "Blue is not good in HEX"); Assert.IsTrue(color.A == newColorHex.Alpha, "Alpha is not good in HEX"); Assert.IsTrue(color.R == newColorHSL.Red, "Red is not good in HSL"); Assert.IsTrue(color.G == newColorHSL.Green, "Green is not good in HSL"); Assert.IsTrue(color.B == newColorHSL.Blue, "Blue is not good in HSL"); Assert.IsTrue(color.A == newColorHSL.Alpha, "Alpha is not good in HSL"); }
public void TestWrongRedArgument() { var color = System.Drawing.Color.Red; var newColor = new PixelColor(255, 257, Colors.Red.G, Colors.Red.B); }
public void TestWrongBlueArgument() { var color = System.Drawing.Color.Red; var newColor = new PixelColor(255, Colors.Red.R, Colors.Red.G, 257); }
public void TestRedColorHSL() { var color = System.Drawing.Color.Red; var newColor = new PixelColor(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B); Assert.IsTrue(color.GetHue() == newColor.Hue, "Hue is not good"); Assert.IsTrue(color.GetSaturation() == newColor.Saturation, "Saturation is not good"); Assert.IsTrue(color.GetBrightness() == newColor.Luminosity, "Luminosity is not good"); }
public void TestRedColor() { var color = Colors.Red; var newColor = new PixelColor(Colors.Red.A, Colors.Red.R, Colors.Red.G, Colors.Red.B); Assert.IsTrue(color.R == newColor.Red, "Red is not good"); Assert.IsTrue(color.G == newColor.Green, "Green is not good"); Assert.IsTrue(color.B == newColor.Blue, "Blue is not good"); Assert.IsTrue(color.A == newColor.Alpha, "Alpha is not good"); }
static PixelColor() { Empty = new PixelColor(); Transparent = new PixelColor(0, 255, 255, 255); }
/// <summary> /// Gets the pallete. /// </summary> /// <param name="ncolors">The ncolors.</param> /// <param name="factor">The factor.</param> /// <returns></returns> public PixelColor[] GetPallete(int ncolors, double factor) { var array = new PixelColor[ncolors]; for (var i = 0; i < ncolors; i ++) { var newL = Extensions.Clamp<double>(Math.Max(0, (this.GetLuminosity() - (factor*i*0.05) )),1,0); array[i] = PixelColor.FromHSL(this.a, this.GetHue(), this.GetSaturation(), newL ); } return array; }