当前位置: 首页>>代码示例>>C#>>正文


C# Color32.Clone方法代码示例

本文整理汇总了C#中Color32.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Color32.Clone方法的具体用法?C# Color32.Clone怎么用?C# Color32.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color32的用法示例。


在下文中一共展示了Color32.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestConstruction

        public void TestConstruction()
        {
            // Verify construction from an int.
            Color32 color = new Color32(OpaqueBlack);
            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlack));

            // Verify construction from a bunch of RGBA bytes.
            color = new Color32(0xff, 0x00, 0x00, 0xff);
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));

            // Verify Clone
            Color32 other = new Color32(OpaqueBlue);
            color = other.Clone();
            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlue));

            // Verify parse from a string using mixed case.
            color = Color32.Parse("ff0000FF");
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));

            // Verify correct behaviour with poorly formed string data.
            //
            // Any string supplied that is less than 8 chars is filled from the front
            // with zeros (and will thus be completely transparent).

            // An fully empty string initalizes to all zeroes (transparent black).
            color = Color32.Parse(string.Empty);
            Assert.That(color.ToString(), Is.EqualTo("00000000"));

            color = Color32.Parse("ffffff");
            Assert.That(color.ToString(), Is.EqualTo("00ffffff"));

            color = Color32.Parse("ff");
            Assert.That(color.ToString(), Is.EqualTo("000000ff"));

            // Only the first eight chars are used for construction from string. Extra
            // chars at the end of the input string are ignored.
            color = Color32.Parse("aabbccddee");
            Assert.That(color.ToString(), Is.EqualTo("aabbccdd"));

            // The input string here has two valid hex values in the first eight chars.
            // ( the "a" and "c" in "Not a c") and those are the only chars that
            // won't be replaced with zeroes.
            color = Color32.Parse("Not a color value");
            Assert.That(color.ToString(), Is.EqualTo("0000a0c0"));
        }
开发者ID:karun10,项目名称:KML2SQL,代码行数:45,代码来源:Color32Test.cs


注:本文中的Color32.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。