本文整理汇总了C#中Color.ToArgb方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToArgb方法的具体用法?C# Color.ToArgb怎么用?C# Color.ToArgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ToArgb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLine
private void DrawLine(Vector3 from, Vector3 to, Color color)
{
var vertices = new List<PositionColored>();
vertices.Add(new PositionColored(from, color.ToArgb()));
vertices.Add(new PositionColored(to, color.ToArgb()));
var buffer = vertices.ToArray();
SetTarget(Vector3.Zero);
D3D.Device.DrawUserPrimitives(PrimitiveType.LineStrip, vertices.Count - 1, buffer);
}
示例2: LinearGradientBrush
public LinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
{
Status status = GDIPlus.GdipCreateLineBrushFromRect (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject);
GDIPlus.CheckStatus (status);
rectangle = rect;
}
示例3: DrawPixel
public override void DrawPixel(int x, int y, Color color)
{
DX.DrawBox(
x*pixelWidth, y*pixelHeight,
x*pixelWidth + pixelWidth, y*pixelHeight + pixelHeight,
color.ToArgb(), 1);
}
示例4: ShouldConvertToArgb
public void ShouldConvertToArgb()
{
// 0xAARRGGBB
const int val = 0x11223344;
var color = new Color(val);
var argb = color.ToArgb();
Assert.AreEqual(val, argb);
}
示例5: DrawRectangle
public void DrawRectangle(float x, float y, float width, float height, Color color)
{
_device.Device.VertexFormat = CustomVertex.TransformedColored.Format;
color = Color.Red;
var vertex = new CustomVertex.TransformedColored[4];
vertex[0].Position = new Vector4(x, y, 0f, 0f);
vertex[0].Color = color.ToArgb();
vertex[1].Position = new Vector4(x + width, y, 0f, 0f);
vertex[1].Color = color.ToArgb();
vertex[2].Position = new Vector4(x, y + height, 0f, 0f);
vertex[2].Color = color.ToArgb();
vertex[3].Position = new Vector4(x + width, y + height, 0f, 0f);
vertex[3].Color = color.ToArgb();
_device.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertex);
}
示例6: FormatColourString
public static string FormatColourString(Color colour, ColourRepresentations format)
{
switch (format)
{
case ColourRepresentations.RGB:
return colour.R.ToString() + "," + colour.G.ToString() + "," + colour.B.ToString();
case ColourRepresentations.Hex:
return "#" + colour.ToArgb().ToString("X6");
default:
return colour.ToString();
}
}
示例7: NameAvailable
public static bool NameAvailable(string name, ListBox colList, Color col)
{
// foreach (ListItem li in colList.Items)
// if (li.Text == name)
// return false;
if (colList.Items.FindByText(name) != null)
return false;
if (colList.Items.FindByValue(col.ToArgb().ToString()) != null)
return false;
return true;
}
示例8: SetPixel
public static void SetPixel(this BitmapData bd, uint x, uint y, Color c)
{
bd.SetPixelInt(x, y, (uint)c.ToArgb());
}
示例9: SetWrapMode
public void SetWrapMode (WrapMode mode, Color color, bool clamp)
{
Status status = GDIPlus.GdipSetImageAttributesWrapMode (nativeImageAttr, mode, color.ToArgb (), clamp);
GDIPlus.CheckStatus (status);
}
示例10: SetColorKey
public void SetColorKey (Color colorLow, Color colorHigh, ColorAdjustType type)
{
Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr, type, true,
colorLow.ToArgb (), colorHigh.ToArgb ());
GDIPlus.CheckStatus (status);
}
示例11: SetFormatColor
/// <summary>
/// Establece el color de fuente actual.
/// </summary>
/// <param name="val">Color de la fuente.</param>
public void SetFormatColor(Color val)
{
if (currentFormat.Color.ToArgb() != val.ToArgb())
{
int indColor = colorTable.IndexOf(val);
if (indColor == -1)
{
colorTable.AddColor(val);
indColor = colorTable.IndexOf(val);
}
currentFormat.Color = val;
mainGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "cf", true, indColor));
}
}
示例12: AddColor
/// <summary>
/// Inserta un nuevo color en la tabla de colores.
/// </summary>
/// <param name="color">Nuevo color a insertar.</param>
public void AddColor(Color color)
{
colors.Add(color.ToArgb());
}
示例13: DrawText
/// <summary>
/// Draw some text on the screen
/// </summary>
public void DrawText(float xpos, float ypos, Color color, string text, RenderFlags flags)
{
if (text == null)
return;
// Setup renderstate
savedStateBlock.Capture();
drawTextStateBlock.Apply();
device.SetTexture(0, fontTexture);
device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
device.PixelShader = null;
device.SetStreamSource(0, vertexBuffer, 0);
// Set filter states
if ((flags & RenderFlags.Filtered) != 0) {
samplerState0.MinFilter = TextureFilter.Linear;
samplerState0.MagFilter = TextureFilter.Linear;
}
// Adjust for character spacing
xpos -= spacingPerChar;
float fStartX = xpos;
// Fill vertex buffer
int iv = 0;
int dwNumTriangles = 0;
foreach (char c in text) {
if (c == '\n') {
xpos = fStartX;
ypos += (textureCoords[0,3]-textureCoords[0,1])*textureHeight;
}
if ((c-32) < 0 || (c-32) >= 128-32)
continue;
float tx1 = textureCoords[c-32,0];
float ty1 = textureCoords[c-32,1];
float tx2 = textureCoords[c-32,2];
float ty2 = textureCoords[c-32,3];
float w = (tx2-tx1) * textureWidth / textureScale;
float h = (ty2-ty1) * textureHeight / textureScale;
int intColor = color.ToArgb();
if (c != ' ') {
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx1, ty2);
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx1, ty1);
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx2, ty2);
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx2, ty1);
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx2, ty2);
fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx1, ty1);
dwNumTriangles += 2;
if (dwNumTriangles*3 > (MaxNumfontVertices-6)) {
// Set the data for the vertexbuffer
vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles);
dwNumTriangles = 0;
iv = 0;
}
}
xpos += w - (2 * spacingPerChar);
}
// Set the data for the vertex buffer
vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard);
if (dwNumTriangles > 0)
device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles);
// Restore the modified renderstates
savedStateBlock.Apply();
}
示例14: IndexOf
/// <summary>
/// Obtiene el índice de un color determinado en la tabla.
/// </summary>
/// <param name="color">Color a consultar.</param>
/// <returns>Indice del color consultado.</returns>
public int IndexOf(Color color)
{
return colors.IndexOf(color.ToArgb());
}
示例15: Clear
public void Clear(Color color)
{
ABitmap.EraseColor(color.ToArgb());
}