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


C# Color.ToVector4方法代码示例

本文整理汇总了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());
 }
开发者ID:vkd,项目名称:Ctrl-Space,代码行数:8,代码来源:Lerp.cs

示例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;
        }
开发者ID:JimmyBoh,项目名称:BrewmasterEngine,代码行数:13,代码来源:Gradient.cs

示例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;
        }
开发者ID:JimmyBoh,项目名称:BrewmasterEngine,代码行数:13,代码来源:Gradient.cs

示例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;
        }
开发者ID:numberoverzero,项目名称:XNA-Engine,代码行数:25,代码来源:ColorTextureGenerator.cs

示例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");
        }
开发者ID:kiichi7,项目名称:monoxna,代码行数:10,代码来源:ColorTests.cs

示例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()));
 }
开发者ID:Skippeh,项目名称:Sidescroller,代码行数:8,代码来源:Utility.cs

示例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);
        }
开发者ID:JustinHughart,项目名称:SIXFONT,代码行数:14,代码来源:SlimDXFont.cs

示例8: VertexPositionNormalColor

 public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color) {
     Position = position;
     Normal = normal;
     Color = color.ToVector4();
 }
开发者ID:phcs93,项目名称:God,代码行数:5,代码来源:VertexPositionNormalColor.cs


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