Click here to Skip to main content
15,885,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a question about using "GraphicsPath.AddArc".

There is no problem to draw an arc when bound rectangle is not rotated.

Path.AddArc( Center.getX(), Center.getY(), Radius, Radius, startAngle, sweepAngle );


But when the rectangle is rotated with an angle, the arc will be wrong.

How can I correctly using it?

Thanks,
Posted
Updated 22-Dec-10 22:34pm
v3

1 solution

They do not need to worry about a rotation because all transformation will be added after the path creating:

// Create a RoundedRectangle:
GraphicsPath path = RoundedRectangle.Create(20, 20, 100, 100, 15);

// Draw the created RoundedRectangle:
e.Graphics.FillPath(Brushes.Blue, path);

// Rotate it clockwise 45 degrees about its center:
Matrix matrix = new Matrix();
matrix.RotateAt(45, new Point(70,70));
path.Transform(matrix);

// Draw the rotated RoundedRectangle:
e.Graphics.FillPath(Brushes.Blue, path);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900