コード例 #1
0
ファイル: ColorTest.cs プロジェクト: GooG2e/Ass-Loader
 public void ParseRgb()
 {
     for (var i = 0; i < 0xffff; i++)
     {
         var va = TestHelper.Random.Next(0x1000000);
         var c  = Color.Parse("&H" + Convert.ToString(va, 16).PadLeft(6, '0'));
         Assert.AreEqual("&H" + Convert.ToString(va, 16).PadLeft(8, '0'), c.ToString(), true);
     }
 }
コード例 #2
0
ファイル: ColorTest.cs プロジェクト: GooG2e/Ass-Loader
 public void ParseRgba()
 {
     for (var i = 0; i < 0xffff; i++)
     {
         var va  = TestHelper.RandomReader.ReadUInt32();
         var str = "&H" + Convert.ToString(va, 16).PadLeft(8, '0');
         var c   = Color.Parse(str);
         Assert.AreEqual(str, c.ToString(), true);
     }
 }
コード例 #3
0
ファイル: ColorTest.cs プロジェクト: GooG2e/Ass-Loader
        public void ChangeRgba()
        {
            Func <Color> raCo = () => Color.Parse("&H" + Convert.ToString(TestHelper.RandomReader.ReadUInt32(), 16).PadLeft(8, '0'));

            for (var i = 0; i < 256; i++)
            {
                var  va = (byte)i;
                var  c = raCo();
                byte r = c.Red, g = c.Green, b = c.Blue, t = c.Transparency;
                c.Red = va;
                Assert.AreEqual(va, c.Red);
                Assert.AreEqual(g, c.Green);
                Assert.AreEqual(b, c.Blue);
                Assert.AreEqual(t, c.Transparency);
                Assert.AreEqual(255, c.Transparency + c.Alpha);
            }
            for (var i = 0; i < 256; i++)
            {
                var  va = (byte)i;
                var  c = raCo();
                byte r = c.Red, g = c.Green, b = c.Blue, t = c.Transparency;
                c.Green = va;
                Assert.AreEqual(r, c.Red);
                Assert.AreEqual(va, c.Green);
                Assert.AreEqual(b, c.Blue);
                Assert.AreEqual(t, c.Transparency);
                Assert.AreEqual(255, c.Transparency + c.Alpha);
            }
            for (var i = 0; i < 256; i++)
            {
                var  va = (byte)i;
                var  c = raCo();
                byte r = c.Red, g = c.Green, b = c.Blue, t = c.Transparency;
                c.Blue = va;
                Assert.AreEqual(r, c.Red);
                Assert.AreEqual(g, c.Green);
                Assert.AreEqual(va, c.Blue);
                Assert.AreEqual(t, c.Transparency);
                Assert.AreEqual(255, c.Transparency + c.Alpha);
            }
            for (var i = 0; i < 256; i++)
            {
                var  va = (byte)i;
                var  c = raCo();
                byte r = c.Red, g = c.Green, b = c.Blue, t = c.Transparency;
                c.Transparency = va;
                Assert.AreEqual(r, c.Red);
                Assert.AreEqual(g, c.Green);
                Assert.AreEqual(b, c.Blue);
                Assert.AreEqual(va, c.Transparency);
                Assert.AreEqual(255, c.Transparency + c.Alpha);
            }
            for (var i = 0; i < 256; i++)
            {
                var  va = (byte)i;
                var  c = raCo();
                byte r = c.Red, g = c.Green, b = c.Blue, t = c.Transparency;
                c.Alpha = va;
                Assert.AreEqual(r, c.Red);
                Assert.AreEqual(g, c.Green);
                Assert.AreEqual(b, c.Blue);
                Assert.AreEqual(va, c.Alpha);
                Assert.AreEqual(255, c.Transparency + c.Alpha);
            }
        }