public BeginContainer ( ) : GraphicsContainer | ||
return | GraphicsContainer |
using (Graphics g = CreateGraphics()) { g.FillRectangle(Brushes.Red, 50, 50, 100, 100); RectangleF rect = new RectangleF(50, 50, 100, 100); GraphicsContainer container = g.BeginContainer(rect, rect, GraphicsUnit.Pixel); g.FillEllipse(Brushes.Green, 0, 0, 100, 100); g.EndContainer(container); }
Graphics g = Graphics.FromImage(myImage); g.DrawLine(new Pen(Color.Black), 0, 0, 100, 100); GraphicsContainer container1 = g.BeginContainer(); g.RotateTransform(45); g.DrawLine(new Pen(Color.Red), 0, 0, 100, 100); GraphicsContainer container2 = g.BeginContainer(); g.ScaleTransform(0.5f, 1); g.DrawLine(new Pen(Color.Blue), 0, 0, 200, 0); g.EndContainer(); g.EndContainer();In this example, a line is first drawn in black. Then, two containers are created and transformations are applied to them. In the first container, a rotation of 45 degrees is applied before drawing a red line. In the second container, a horizontal scaling of 0.5 is applied before drawing a blue line. The result is a line that is rotated and scaled relative to the original line. Library: `System.Drawing`