本文整理汇总了C#中Gradient.GetColors方法的典型用法代码示例。如果您正苦于以下问题:C# Gradient.GetColors方法的具体用法?C# Gradient.GetColors怎么用?C# Gradient.GetColors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gradient
的用法示例。
在下文中一共展示了Gradient.GetColors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateVerticalGradient
/// <summary>
/// Creates a 1 pixel wide vertical gradient texture using the provided <see cref="GradientStop"/> array.
/// </summary>
/// <param name="device"><see cref="Microsoft.Xna.Framework.Graphics.GraphicsDevice"/> instance to use.</param>
/// <param name="gradientStops">Array of <see cref="GradientStop"/> instances to use when generating the gradient.</param>
/// <param name="height">Height of the generated texture in pixels.</param>
/// <returns>A texture 1 pixel wide and the height specified.</returns>
public static Texture2D CreateVerticalGradient(GraphicsDevice device, Gradient gradient, int height)
{
Texture2D texture = new Texture2D(device, 1, height, false, SurfaceFormat.Color);
Color[] colors = gradient.GetColors(height);
texture.SetData<Color>(colors);
return texture;
}
示例2: CreateHorizontalGradient
/// <summary>
/// Creates a 1 pixel high horizontal gradient texture using the provided <see cref="GradientStop"/> array.
/// </summary>
/// <param name="device"><see cref="Microsoft.Xna.Framework.Graphics.GraphicsDevice"/> instance to use.</param>
/// <param name="gradientStops">Array of <see cref="GradientStop"/> instances to use when generating the gradient.</param>
/// <param name="width">Width of the generated texture in pixels.</param>
/// <returns>A texture with the width specified and 1 pixel high.</returns>
public static Texture2D CreateHorizontalGradient(GraphicsDevice device, Gradient gradient, int width)
{
Texture2D texture = new Texture2D(device, width, 1, false, SurfaceFormat.Color);
Color[] colors = gradient.GetColors(width);
texture.SetData<Color>(colors);
return texture;
}
示例3: Initialize
/// <summary>
/// Initilize various objects
/// </summary>
protected override void Initialize()
{
_keyboardManager = new KeyboardManager(this);
Components.Add(_keyboardManager);
_keyboardManager.AddListener(this);
_mouseManager = new MouseManager(this);
Components.Add(_mouseManager);
_mouseManager.AddListener(this);
//_camera = new CameraFirstPerson(this, 45, 0.01f, 100.0f);
_camera = new CameraTrackBall(this, 45, 0.01f, 100.0f);
_camera.Position = new Vector3(0, 0, 5);
Components.Add(_camera);
createVolumeRaycaster();
_gradEditor = new GradientEditor();
_gradient = new Gradient();
GradientSegment seg = new GradientSegment();
seg.Left = 0.0f;
seg.Middle = 0.5f;
seg.Right = 1.0f;
seg.LeftColor = new Vector4(1, 0, 0, 1.0f);
seg.RightColor = new Vector4(1, 0, 0, 1.0f);
seg.ColType = GradientSegment.ColorType.HSV_CCW;
_gradient.AddSegment(seg);
//seg.LookUpTable = palette.Colors;
//_gradient.AddSegment(seg);
//seg = new GradientSegment();
//seg.Left = 0;
//seg.Middle = 0.333f/2.0f;
//seg.Right = 0.333f;
//seg.LeftColor = ColorHelper.HsvToRgb(0, 1, 0, 1.0f);
//seg.RightColor = ColorHelper.HsvToRgb(0, 1, 0.8f, 1.0f);
//seg.ColType = GradientSegment.ColorType.HSV_CW;
//_gradient.AddSegment(seg);
//seg = new GradientSegment();
//seg.Left = 0.333f;
//seg.Middle = 0.333f+(1.0f-0.333f) / 2.0f;
//seg.Right = 1.0f;
//seg.LeftColor = ColorHelper.HsvToRgb(0, 1, 0.8f, 1.0f);
//seg.RightColor = ColorHelper.HsvToRgb(0.25f * 360.0f, 0, 1.0f, 1);
//seg.ColType = GradientSegment.ColorType.HSV_CW;
//_gradient.AddSegment(seg);
_gradEditor.Gradient = _gradient;
Color[] cols = _gradient.GetColors(256);
_vrc.TransferFunction = cols;
TransferFunction tf = new TransferFunction();
tf.Colors = cols;
tf.preIntegrate();
_vrc.TransferFunctionPreInt = tf;
_gradEditor.Show();
VolumeRaycasterSettings raySettings = new VolumeRaycasterSettings(_vrc);
raySettings.Show();
base.Initialize();
}