We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Polygon Drawing

Hi, can you please guide me how to draw a polygon, and rotate it to certain angle.
Regards,

2 Replies

MF Meera Fathima Syncfusion Team May 28, 2007 04:30 AM UTC


Hello Ali,

Thank you using Essential Diagram.

If you want to draw a polygon shape node, please see the sample code snippet provided below.

private void CreatePolygon()
{
PointF[] pts = new PointF[]
{
new PointF(20, 40),
new PointF(100,60),
new PointF(100, 120),
new PointF(20,100)
};
Polygon polygon = new Polygon( pts );
this.diagram1.Model.AppendChild(polygon);
}


This is also demonstrated in the Diagram Samples\Symbol Design\Simple Flow sample. Please look into the sample's MainForm.CreateCustomPolygon() method in particular.

Thanks,
Meera


MF Meera Fathima Syncfusion Team May 28, 2007 05:07 AM UTC


Hello Ali,

Continuing with my previous update, the nodes can be rotated by using the Node.Rotate() method. For e.g. if you want to rotate the polygon to certain angle,you can do this by using polygon.Rotate(45) method.

Please see the sample code snippet that shows how to do this.

private void CreatePolygon()
{
PointF[] pts = new PointF[]
{
new PointF(20, 40),
new PointF(100,60),
new PointF(100, 120),
new PointF(20,100)
};
Polygon polygon = new Polygon( pts );
polygon.Rotate(45); // Rotates polygon to 45 degree.
this.diagram1.Model.AppendChild(polygon);
}

Thanks,
Meera.

Loader.
Live Chat Icon For mobile
Up arrow icon