Create two color instances with different alpha components
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle);
Color c1 = Color.FromArgb(100, Color.Blue);
Color c2 = Color.FromArgb(50, Color.Green);
g.FillEllipse(Brushes.Red, 20, 20, 80, 80);
g.FillRectangle(new SolidBrush(c1), 60, 80, 60, 60);
Point[] pa = new Point[] {
new Point(150, 40),
new Point(90, 40),
new Point(90, 120)};
g.FillPolygon(new SolidBrush(c2), pa);
}
public static void Main() {
Application.Run(new Form1());
}
}
Related examples in the same category