本文整理汇总了C#中ColorBGRA.ToVector4方法的典型用法代码示例。如果您正苦于以下问题:C# ColorBGRA.ToVector4方法的具体用法?C# ColorBGRA.ToVector4怎么用?C# ColorBGRA.ToVector4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorBGRA
的用法示例。
在下文中一共展示了ColorBGRA.ToVector4方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GradientRect
/// <summary>
/// Draws a Gradient.
/// </summary>
/// <param name="x">Position X</param>
/// <param name="y">Position Y</param>
/// <param name="width">Width</param>
/// <param name="height">Height</param>
/// <param name="startCol">Starting Color</param>
/// <param name="endCol">Ending Color</param>
/// <param name="orientation">Orientation</param>
public void GradientRect(
float x,
float y,
float width,
float height,
ColorBGRA startCol,
ColorBGRA endCol,
Orientation orientation)
{
var vertices = new VertexBuffer(
Drawing.Direct3DDevice,
SharpDX.Utilities.SizeOf<Vector4>() * 2 * 4,
Usage.WriteOnly,
VertexFormat.Diffuse | VertexFormat.PositionRhw,
Pool.Default);
vertices.Lock(0, 0, LockFlags.None)
.WriteRange(
new[]
{
new Vector4(x, y, 0f, 1.0f), startCol.ToVector4(), new Vector4(x + width, y, 0f, 1.0f),
orientation == Orientation.Vertical ? endCol.ToVector4() : startCol.ToVector4(),
new Vector4(x, y + height, 0f, 1.0f),
orientation == Orientation.Vertical ? startCol.ToVector4() : endCol.ToVector4(),
new Vector4(x + width, y + height, 0f, 1.0f), endCol.ToVector4()
});
vertices.Unlock();
VertexElement[] vertexElements =
{
new VertexElement(
0,
0,
DeclarationType.Float4,
DeclarationMethod.Default,
DeclarationUsage.Position,
0),
new VertexElement(
0,
16,
DeclarationType.Float4,
DeclarationMethod.Default,
DeclarationUsage.Color,
0),
VertexElement.VertexDeclarationEnd
};
var vertexDeclaration = new VertexDeclaration(Drawing.Direct3DDevice, vertexElements);
var olddec = Drawing.Direct3DDevice.VertexDeclaration;
Drawing.Direct3DDevice.SetStreamSource(0, vertices, 0, SharpDX.Utilities.SizeOf<Vector4>() * 2);
Drawing.Direct3DDevice.VertexDeclaration = vertexDeclaration;
Drawing.Direct3DDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
Drawing.Direct3DDevice.VertexDeclaration = olddec;
vertexDeclaration.Dispose();
vertices.Dispose();
}