本文整理汇总了C#中Color.ToColor4方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToColor4方法的具体用法?C# Color.ToColor4怎么用?C# Color.ToColor4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ToColor4方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldConvertToColor4
public void ShouldConvertToColor4()
{
var color = new Color(0.1f, 0.2f, 0.3f, 0.4f);
var color4 = color.ToColor4();
Assert.AreEqual(color.R, color4.R, "Red component mismatch!");
Assert.AreEqual(color.G, color4.G, "Green component mismatch!");
Assert.AreEqual(color.B, color4.B, "Blue component mismatch!");
Assert.AreEqual(color.A, color4.A, "Alpha component mismatch!");
}
示例2: ShouldReturnValidArgbValue
public void ShouldReturnValidArgbValue()
{
var color = new Color(0.1f, 0.2f, 0.3f, 0.4f);
var color4 = color.ToColor4();
var argb = color4.ToArgb();
var expected =
(uint) (color4.A * byte.MaxValue) << 24 |
(uint) (color4.R * byte.MaxValue) << 16 |
(uint) (color4.G * byte.MaxValue) << 8 |
(uint) (color4.B * byte.MaxValue);
Assert.AreEqual(unchecked((int) expected), argb);
}
示例3: DrawLine
public void DrawLine(DVector3 pos0, DVector3 pos1, Color color)
{
lines.Add(new Gis.CartPoint {
X = pos0.X,
Y = pos0.Y,
Z = pos0.Z,
Tex0 = Vector4.Zero,
Color = color.ToColor4()
});
lines.Add(new Gis.CartPoint {
X = pos1.X,
Y = pos1.Y,
Z = pos1.Z,
Tex0 = Vector4.Zero,
Color = color.ToColor4()
});
isDirty = true;
}
示例4: VertexPosColTex
public VertexPosColTex(Vector4 position, Color color, TextureCoordinate textureCoordinate)
: this(position, color.ToColor4(), textureCoordinate)
{
}
示例5: Clear
public override void Clear(Color color)
{
_renderTarget.Clear(color.ToColor4());
TextBackgroundColor = color;
}
示例6: SetClipRectangle
/// <summary>
///
/// </summary>
/// <param name="index"></param>
/// <param name="rectangle"></param>
public void SetClipRectangle ( int index, Rectangle rectangle, Color color )
{
if (index<0 || index>=MaxSpriteFrames) {
throw new ArgumentOutOfRangeException("index", "must be greater or equal to zero and less than MaxClipRectangles (" + MaxSpriteFrames.ToString() + ")");
}
var rect = new RectangleF( rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height );
var color4 = color.ToColor4();
framesData[ index ] = new SpriteFrame( rect, color4 );
dirty = true;
}
示例7: InitPlotter
private void InitPlotter(Vector.FxVectorF vec, PlotType plotType, Color color)
{
// init the lists
listPlotsGeometry = new List<PlotGeometry>();
// set the position and the size of the element
this.Position = new Vector.FxVector2f(0);
this.Size = new Vector.FxVector2f(750, 500);
// add the vector to the list
PlotGeometry plot = new PlotGeometry();
plot.OrigVectorY = vec;
plot.Color = color.ToColor4();
plot.Type = plotType;
plot.StepType = XStepType.ZeroToMax;
// add the plot to the list
listPlotsGeometry.Add(plot);
// set the origin position
{
float max = vec.Max();
float min = vec.Min();
float orig_y = Size.Y / 2;
if(max >0 && min<0)
{
orig_y = Size.Y * (min / (max - min));
}
if(max >0 && min >= 0)
{
orig_y = -min;
}
if(max <=0 && min <0)
{
orig_y = Size.Y + max;
}
OriginPosition = new Vector.FxVector2f(5, orig_y);
}
// allocate scale
_scale = new Vector.FxVector2f(1.0f);
// fit the plots to the view
FitPlots();
// set the x_step base on the size of vec and the width
X_Space = this.Size.x / vec.Size;
// init format
_TextFormat = new TextElementFormat();
_TextFormat.familyName = "Calibri";
_TextFormat.weight = SharpDX.DirectWrite.FontWeight.Black;
_TextFormat.fontStyle = SharpDX.DirectWrite.FontStyle.Normal;
_TextFormat.fontStretch = SharpDX.DirectWrite.FontStretch.Normal;
_TextFormat.fontSize = 8.0f;
// init toolstrip
InitToolStrips();
}