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


C# ColorBGRA.ToVector4方法代码示例

本文整理汇总了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();
        }
开发者ID:CjShu,项目名称:LeagueSharp.SDKEx,代码行数:68,代码来源:ColorSpectrum.cs


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