LinearGradientBrush Using C#
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Drawing.Drawing2D;
using
System.Drawing.Text;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
graphics1
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
}
private
void button1_Click(object
sender, EventArgs e)
{
Rectangle
myGradientRectangle = new Rectangle(10, 10, 150, 150);
using
(Graphics myGradientGraphic = this.CreateGraphics())
{
using
(LinearGradientBrush myGradientBrush = new LinearGradientBrush(myGradientRectangle,
Color.Red, Color.Blue,
System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal))
{
myGradientGraphic.FillEllipse(myGradientBrush, 50, 10, 150, 150);
}
}
}
private
void button2_Click(object
sender, EventArgs e)
{
Rectangle
myGradientRectangle = new Rectangle(10, 10, 75, 75);
Graphics
g=this.CreateGraphics();
LinearGradientBrush
myGradientBrush = new LinearGradientBrush(myGradientRectangle,
Color.Red, Color.Blue,
LinearGradientMode.ForwardDiagonal);
g.FillEllipse(myGradientBrush, 200,
10, 150, 150);
}
}
}
No comments:
Post a Comment