Drawing functionality described in this topic is out of date. If you want to learn how to draw lines and curves using the new drawing engine in Graphics Mill, read the Graphics. Drawing Images and Geometric Shapes article.
The article describes how to draw lines and curves in Graphics Mill. Drawing functionality in Graphics Mill is presented by the Graphics class, which supports the drawing of the following line types:
To manage lines and curves appearance use a Pen class instance. For more information see the Pens and Brushes topic.
The following code draws a line, a polyline, and a Bezier curve as shown in the image:
using (var bitmap = new Bitmap(185, 145, PixelFormat.Format24bppRgb, RgbColor.White))
{
using (Graphics graphics = bitmap.GetGraphics())
{
//Draw line
var pen = new Pen(RgbColor.Red, 5);
graphics.DrawLine(pen, 10, 10, 100, 60);
//Draw polyline
pen.Color = RgbColor.LawnGreen;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
pen.Width = 2;
System.Drawing.Point[] points1 = {
new System.Drawing.Point(20, 30), new System.Drawing.Point(50, 2),
new System.Drawing.Point(180, 30), new System.Drawing.Point(80, 140)
};
graphics.DrawLines(pen, points1);
//Draw beizer
pen.Color = RgbColor.Blue;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
System.Drawing.Point[] points2 = {
new System.Drawing.Point(5, 5), new System.Drawing.Point(20, 150),
new System.Drawing.Point(165, 80), new System.Drawing.Point(175, 10)
};
graphics.DrawBeziers(pen, points2);
}
bitmap.Save(@"Images\Output\lines.png");
}
You might notice that methods described above are similar to methods of the System.Drawing.Graphics class. If you rewrite the previous code in order to use the System.Drawing.Graphics class, instead of Aurigma.GraphicsMill.Drawing.Graphics, and the method calls remain untouched, the result will be as follows:
using (var bitmap = new Bitmap(185, 145, PixelFormat.Format24bppRgb, RgbColor.White))
{
using (System.Drawing.Graphics graphics = bitmap.GetGdiPlusGraphics())
{
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//Draw line
var pen = new System.Drawing.Pen(System.Drawing.Color.Red, 5);
graphics.DrawLine(pen, 10, 10, 100, 60);
//Draw polyline
pen.Color = System.Drawing.Color.FromArgb(150, System.Drawing.Color.LawnGreen);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
pen.Width = 2;
System.Drawing.Point[] points1 = {
new System.Drawing.Point(20, 30), new System.Drawing.Point(50, 2),
new System.Drawing.Point(180, 30), new System.Drawing.Point(80, 140)
};
graphics.DrawLines(pen, points1);
//Draw beizer
pen.Color = System.Drawing.Color.Blue;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
System.Drawing.Point[] points2 = {
new System.Drawing.Point(5, 5), new System.Drawing.Point(20, 150),
new System.Drawing.Point(165, 80), new System.Drawing.Point(175, 10)
};
graphics.DrawBeziers(pen, points2);
}
bitmap.Save(@"Images\Output\lines.png");
}
Each class, Aurigma.GraphicsMill.Drawing.Graphics and System.Drawing.Graphics, have their own highs and lows. We recommend that you read the AdvancedDrawing.Graphics vs Drawing.Graphics vs System.Drawing.Graphics topic before making a decision on which class to use.