本文整理匯總了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);
}