[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 673
  • Last Modified:

Rotate shape

How can you after you place a shape (a rectangle in this case)on a form when designing the form and rotate it by 45 degrees and then 90 degrees at run time?
0
pg6111
Asked:
pg6111
1 Solution
 
mcriderCommented:
Check out this microsoft article:

HOWTO: Rotate a Bitmap Image in 90-Degree Increments
http://support.microsoft.com/support/kb/articles/Q186/2/60.ASP?LNG=ENG&SA=MSDN 
 

Cheers!
0
 
Erick37Commented:
If you need to rotate a shape by an arbitrary angle, you are probably better off using the Polygon API and translating the points according to the angle.
0
 
caraf_gCommented:
Yes.

From your other question you can glean how you can actually create the polygon with the API, so I assume that is a known quantity.

Simply refer to the points of the polygon with their carthesian coordinates wrt an origin. Each point has coordinates (x, y)

If you rotate a point through an angle Alpha wrt the origin, its new coordinates will become
(x*cos(Alpha) - y*sin(Alpha), x*sin(Alpha) + y*cos(Alpha))

(I think - check it)

Simply re-calculate all the POINTs in your polygon and redraw.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now