本文整理汇总了C#中Color32.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Color32.ToString方法的具体用法?C# Color32.ToString怎么用?C# Color32.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color32
的用法示例。
在下文中一共展示了Color32.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"));
}
示例2: SerializesToHexWithoutAlpha
public void SerializesToHexWithoutAlpha()
{
var color32 = new Color32(Color.Chartreuse);
var hex = color32.ToString();
Assert.AreEqual("#7FFF00", hex);
}