public void MvxColorRGBAndAlphaConstructorTests() { var tests = new uint[,] { { 0, 0, 0, 0 }, { 0XFF, 0, 0, 0xFF }, { 0xFF00, 0, 0xFF, 0 }, { 0xFF0000, 0xFF, 0, 0 }, { 0xFF000000, 0, 0, 0 }, { 0x12345678, 0x34, 0x56, 0x78 }, { 0xFFFFFFFF, 0xFF, 0xFF, 0xFF }, }; for (var i = 0; i < tests.GetUpperBound(0); i++) { for (uint alpha = 0; alpha < 256; alpha++) { var c = new MvxColor((int)tests[i, 0], (int)alpha); Assert.AreEqual(alpha, c.A); Assert.AreEqual(tests[i, 1], c.R); Assert.AreEqual(tests[i, 2], c.G); Assert.AreEqual(tests[i, 3], c.B); var argb = (tests[i, 0] & 0x00FFFFFF) | ((alpha & 0xFF) << 24); Assert.AreEqual(argb, (uint)c.ARGB); } } }
public void FillRectangle(int fromX, int fromY, int toX, int toY, MvxColor color) { for (var y = fromY; y < toY; y++) { var offset = y * Width; for (var x = fromX; x < toX; x++) { Pixels[x + offset] = color.ARGB; } } }
public void MvxColorSimpleConstructorTests() { var tests = new uint[,] { { 0, 0, 0, 0, 0 }, { 0XFF, 0, 0, 0, 0xFF }, { 0xFF00, 0, 0, 0xFF, 0 }, { 0xFF0000, 0, 0xFF, 0, 0 }, { 0xFF000000, 0xFF, 0, 0, 0 }, { 0x12345678, 0x12, 0x34, 0x56, 0x78 }, { 0xFFFFFFFF, 0xFF, 0xFF, 0xFF, 0xFF }, }; for (var i = 0; i < tests.GetUpperBound(0); i++) { var c = new MvxColor((int)tests[i, 0]); Assert.AreEqual(tests[i, 1], c.A); Assert.AreEqual(tests[i, 2], c.R); Assert.AreEqual(tests[i, 3], c.G); Assert.AreEqual(tests[i, 4], c.B); Assert.AreEqual(tests[i, 0], (uint)c.ARGB); } }
public ColorCellViewModel(string name, string state) : base(name, state) { var colors = state.Replace(" ", "").Split(','); int h = 0; int s = 0; int v = 0; if (Int32.TryParse(colors[0], out h) && Int32.TryParse(colors[1], out s) && Int32.TryParse(colors[2], out v)) { double hDouble = h; double sDouble = (double)s / 100; double vDouble = (double)v / 100; int r = 0; int g = 0; int b = 0; HsvToRgb(hDouble, sDouble, vDouble, out r, out g, out b); _color = new MvxColor(r, g, b); } }
public global::Android.Graphics.Color ToAndroidColor(MvxColor mvxColor) { return new global::Android.Graphics.Color(mvxColor.R, mvxColor.G, mvxColor.B, mvxColor.A); }
public object ToNative(MvxColor mvxColor) { return ToAndroidColor(mvxColor); }
public static UIColor ToUIColor(MvxColor mvxColor) { return new UIColor(mvxColor.R / 255.0f, mvxColor.G / 255.0f, mvxColor.B / 255.0f, mvxColor.A / 255.0f); }
public object ToNative(MvxColor mvxColor) { return ToUIColor(mvxColor); }
private void SetPixel(double x, double y, MvxColor color) { _bitmap.FillRectangle((int)(x * SCALE_UP), (int)(y * SCALE_UP), (int)((x + 1) * SCALE_UP), (int)((y + 1) * SCALE_UP), color); }
public void MvxColorComponentConstructorTests() { var tests = new uint[,] { { 0, 0, 0, 0 }, { 0, 0, 0, 0xFF }, { 0, 0, 0xFF, 0 }, { 0, 0xFF, 0, 0 }, { 0xFF, 0, 0, 0 }, { 0x12, 0x34, 0x56, 0x78 }, { 0xFF, 0xFF, 0xFF, 0xFF }, }; for (var i = 0; i < tests.GetUpperBound(0); i++) { var c = new MvxColor((int)tests[i, 1], (int)tests[i, 2], (int)tests[i, 3], (int)tests[i, 0]); Assert.AreEqual(tests[i, 0], c.A); Assert.AreEqual(tests[i, 1], c.R); Assert.AreEqual(tests[i, 2], c.G); Assert.AreEqual(tests[i, 3], c.B); var argb = tests[i, 0] & 0xFF; argb <<= 8; argb |= (tests[i, 1] & 0xFF); argb <<= 8; argb |= (tests[i, 2] & 0xFF); argb <<= 8; argb |= (tests[i, 3] & 0xFF); Assert.AreEqual(argb, (uint)c.ARGB); } }
public object ToNative(MvxColor mvxColor) { var color = mvxColor.ToNativeColor(); return new SolidColorBrush(color); }
private void UpdateColor() { Color = new MvxColor(Red, Green, Blue); }
public static System.Windows.Media.Color ToNativeColor(MvxColor mvxColor) { return System.Windows.Media.Color.FromArgb((byte)mvxColor.A, (byte)mvxColor.R, (byte)mvxColor.G, (byte)mvxColor.B); }
public object ToNative(MvxColor mvxColor) { return new WrappedColor(mvxColor); }
public WrappedColor(MvxColor color) { Color = color; }