Color.FromArgb (int r, int g, int b) : Color « System.Drawing « C# / C Sharp by API






Color.FromArgb (int r, int g, int b)

  
using System;
using System.Drawing;
using System.Windows.Forms; 

public class ColorChips : Form {
  public ColorChips() {
    Size = new Size(300,300);
    Text = "Color Chips";
  }

  protected override void OnPaint(PaintEventArgs e)   {
    Graphics g = e.Graphics;
    int h = DisplayRectangle.Height;
    int w = DisplayRectangle.Width;
    Random r = new Random();

    for (int i = 0; i < 10; i++){
      for (int j = 0; j < 10; j++) {
        Color color = Color.FromArgb (r.Next(256), r.Next(256), r.Next(256));
        Brush brush = new SolidBrush(color); 
        g.FillRectangle(brush, i*w/10, j*h/10, w/10, h/10);
      } 
    }  
    base.OnPaint(e);
  }
  static void Main() {
    Application.Run(new ColorChips());
  }
} 

   
    
  








Related examples in the same category

1.Color.AliceBlue
2.Color.Chocolate
3.Color.FromArgb(100, Color.Blue)
4.Color.FromArgb(77, color.R, color.G, color.B)
5.Color.FromKnownColor
6.Color.FromName
7.Color.LightGray
8.Color.Tomato
9.Color.White