Add Bezier to a Path

image_pdfimage_print

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

class Flower: Form
{
public static void Main()
{
Application.Run(new Flower());
}
public Flower()
{
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{

float fScale = Math.Min(cx, cy) / 200f;
grfx.TranslateTransform(cx / 2, cy / 2);
grfx.ScaleTransform(fScale, fScale);

GraphicsPath path = new GraphicsPath();

path.AddBezier(new Point( 0, 0), new Point(125, 125),
new Point(75, 15), new Point(600, 0));

for (int i = 0; i < 8; i++) { grfx.FillPath(Brushes.Red, path); grfx.DrawPath(Pens.Black, path); grfx.RotateTransform(360 / 8); } Rectangle rect = new Rectangle(-150, -150, 300, 300); grfx.FillEllipse(Brushes.Yellow, rect); grfx.DrawEllipse(Pens.Black, rect); } } [/csharp]

This entry was posted in 2D Graphics. Bookmark the permalink.