|
|
[C#]
void DrawRectangle(Pen pen, double x, double y, double width, double height);
void DrawRectangle(Pen pen, RectangleF rect);
[Visual Basic]
Sub DrawRectangle(pen As Pen, x As Double, y As Double, width As Double, height As Double)
Sub DrawRectangle(pen As Pen, rect As RectangleF)
|
|
|
|
The following code draws an outline of a rectangle, then paints
another rectangle within it and finally paints and outlines another
rectangle within that.
[C#]
using (Bitmap bm = new Bitmap(180, 180)) {
using (Graphics gr = Graphics.FromImage(bm)) {
gr.DrawRectangle(new Pen(Color.Black), new RectangleF(20, 20, 160, 160));
gr.FillRectangle(Brushes.Plum, new RectangleF(40, 40, 120, 120));
gr.DrawRectangle(new Pen(Color.Red), new RectangleF(60, 60, 80, 80));
gr.FillRectangle(Brushes.DarkOrchid, new RectangleF(60, 60, 80, 80));
}
bm.Save(Server.MapPath("IG8_Graphics_DrawRectangle.png"));
}

IG8_Graphics_DrawRectangle.png
|