當前位置: 首頁>>代碼示例>>C#>>正文


C# Color.ToArgb方法代碼示例

本文整理匯總了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);
        }
開發者ID:alex-v-odesk,項目名稱:IceFlake,代碼行數:13,代碼來源:DebugScript.cs

示例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;
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:7,代碼來源:LinearGradientBrush.cs

示例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);
 }
開發者ID:oxyflour,項目名稱:old-repos,代碼行數:7,代碼來源:canvas.cs

示例4: ShouldConvertToArgb

 public void ShouldConvertToArgb()
 {
     // 0xAARRGGBB
     const int val = 0x11223344;
     var color = new Color(val);
     var argb = color.ToArgb();
     Assert.AreEqual(val, argb);
 }
開發者ID:remy22,項目名稱:TriEngine,代碼行數:8,代碼來源:ColorTests.cs

示例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);
        }
開發者ID:Rewtek,項目名稱:GameLibrary,代碼行數:17,代碼來源:GemoetryRenderer.cs

示例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();
     }
 }
開發者ID:tdwright,項目名稱:ColourPickerComponents,代碼行數:12,代碼來源:ColourHandler.cs

示例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;
    }
開發者ID:kbridgeman1,項目名稱:CMPE2300,代碼行數:14,代碼來源:Processing.cs

示例8: SetPixel

 public static void SetPixel(this BitmapData bd, uint x, uint y, Color c)
 {
     bd.SetPixelInt(x, y, (uint)c.ToArgb());
 }
開發者ID:Jaex,項目名稱:Terraria-API,代碼行數:4,代碼來源:BitmapDataEx.cs

示例9: SetWrapMode

		public void SetWrapMode (WrapMode mode, Color color, bool clamp)
		{
			Status status = GDIPlus.GdipSetImageAttributesWrapMode (nativeImageAttr, mode, color.ToArgb (), clamp);
    			GDIPlus.CheckStatus (status);
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:5,代碼來源:ImageAttributes.cs

示例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);
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:6,代碼來源:ImageAttributes.cs

示例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));
                }
            }
開發者ID:Bartizan,項目名稱:nrtftree,代碼行數:20,代碼來源:RtfDocument.cs

示例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());
 }
開發者ID:mnibecker,項目名稱:nrtftree,代碼行數:8,代碼來源:RtfColorTable.cs

示例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();
    }
開發者ID:timdetering,項目名稱:BeginningNetGameProgramming,代碼行數:77,代碼來源:d3dfont.cs

示例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());
 }
開發者ID:mnibecker,項目名稱:nrtftree,代碼行數:9,代碼來源:RtfColorTable.cs

示例15: Clear

 public void Clear(Color color)
 {
     ABitmap.EraseColor(color.ToArgb());
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:4,代碼來源:Bitmap.cs


注:本文中的Color.ToArgb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。