本文整理汇总了C#中Microsoft.Xna.Framework.Color.ToVector4方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToVector4方法的具体用法?C# Color.ToVector4怎么用?C# Color.ToVector4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Color
的用法示例。
在下文中一共展示了Color.ToVector4方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OfColor
public static Color OfColor(Color v1, Color v2, float t)
{
if (t <= 0f)
return v1;
if (t >= 1f)
return v2;
return new Color((1f - t) * v1.ToVector4() + t * v2.ToVector4());
}
示例2: CreateVertical
public static Texture2D CreateVertical(int height, Color top, Color bottom)
{
var texture = new Texture2D(CurrentGame.SpriteBatch.GraphicsDevice, 1, height);
var bgc = new Color[height];
for (var i = 0; i < bgc.Length; i++)
{
var amount = (float) i/height;
bgc[i] = new Color(Vector4.Lerp(top.ToVector4(), bottom.ToVector4(), amount));
}
texture.SetData(bgc);
return texture;
}
示例3: CreateHorizontal
public static Texture2D CreateHorizontal(int width, Color left, Color right)
{
var texture = new Texture2D(CurrentGame.SpriteBatch.GraphicsDevice, width, 1);
var bgc = new Color[width];
for (var i = 0; i < bgc.Length; i++)
{
var amount = (float)i / width;
bgc[i] = new Color(Vector4.Lerp(left.ToVector4(), right.ToVector4(), amount));
}
texture.SetData(bgc);
return texture;
}
示例4: Create
/// <summary>
/// Creates a texture of the specified color.
/// </summary>
/// <param name="graphicsDevice"> The graphics device to use. </param>
/// <param name="width"> The width of the texture. </param>
/// <param name="height"> The height of the texture. </param>
/// <param name="color"> The color to set the texture to. </param>
/// <returns> The newly created texture. </returns>
public static Texture2D Create(GraphicsDevice graphicsDevice, int width, int height, Color color)
{
// create the rectangle texture without colors
var texture = new Texture2D(graphicsDevice, width, height);
// Create a color array for the pixels
var colors = new Color[width*height];
for (int i = 0; i < colors.Length; i++)
{
colors[i] = new Color(color.ToVector4());
}
// Set the color data for the texture
texture.SetData(colors);
return texture;
}
示例5: ToVector4Tests
public void ToVector4Tests()
{
Color c = new Color(0xFF, 0xBF, 0x7F, 0x00);
Vector4 v = c.ToVector4();
Assert.IsTrue(TestHelper.ApproximatelyEquals(1.0f, v.X), "Unexpected value for X");
Assert.IsTrue(TestHelper.ApproximatelyEquals(0.75f, v.Y), "Unexpected value for Y");
Assert.IsTrue(TestHelper.ApproximatelyEquals(0.5f, v.Z), "Unexpected value for Z");
Assert.IsTrue(TestHelper.ApproximatelyEquals(0.0f, v.W), "Unexpected value for W");
}
示例6: GetColorGradient
/// <summary>
/// Gets the color inbetween min and max at "distance". Black -> White would become gray.
/// </summary>
/// <param name="distance">0 = min, 1 = max. If null then it will be randomized.</param>
public static Color GetColorGradient(Color min, Color max, float? distance)
{
return new Color(Vector4.Lerp(min.ToVector4(), max.ToVector4(), distance ?? (float)Random.NextDouble()));
}
示例7: DrawString
/// <summary>
/// Draws a string on the screen according to absolute positioning.
/// </summary>
/// <param name="text">The text to be drawn.</param>
/// <param name="position">The text's position.</param>
/// <param name="color">The text's color.</param>
public void DrawString(String text, XNAVector2 position, XNAColor color)
{
XNAVector4 c = color.ToVector4();
Color4 drawcolor = new Color4(c.W, c.X, c.Y, c.Z);
_font.DrawString(null, text, (int)position.X, (int)position.Y, drawcolor);
}
示例8: VertexPositionNormalColor
public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color) {
Position = position;
Normal = normal;
Color = color.ToVector4();
}