public DrawBezier ( |
||
pen | ||
pt1 | Point | |
pt2 | Point | |
pt3 | Point | |
pt4 | Point | |
return | void |
// Create a new Bitmap object Bitmap bmp = new Bitmap(400, 400); // Create a new Graphics object to draw on the bitmap Graphics g = Graphics.FromImage(bmp); // Set the brush and pen colors Brush brush = new SolidBrush(Color.Blue); Pen pen = new Pen(Color.Red, 3); // Draw a Bézier curve using four control points Point p1 = new Point(50, 200); Point p2 = new Point(150, 50); Point p3 = new Point(250, 350); Point p4 = new Point(350, 200); g.DrawBezier(pen, p1, p2, p3, p4); // Fill the area enclosed by the Bézier curve with a color g.FillClosedCurve(brush, new Point[] { p1, p2, p3, p4 }); // Save the bitmap to a file bmp.Save("bezier.png"); // Dispose of the Graphics object g.Dispose();In this example, we create a new Bitmap object and a Graphics object to draw on the bitmap. We then set the colors for the brush and pen, and define four control points for the Bézier curve. We call the DrawBezier method to draw the curve and the FillClosedCurve method to fill the area enclosed by the curve with a color. Finally, we save the bitmap to a file and dispose of the Graphics object. The package library used in this example is System.Drawing.
public DrawBezier ( |
||
pen | ||
pt1 | Point | |
pt2 | Point | |
pt3 | Point | |
pt4 | Point | |
return | void |