Given I have a canvas that contains many shapes, lets say rectangles for now.
Each shape has a location (inches), size(inches) and rotation angle(degrees).
When
I found the answer (I have to convert al measurements to pixels to make sure it will calculate correctly):
public static bool HitTest(Rectangle bounds, float angle, Point location)
{
if (angle == 0) return bounds.Contains(location);
using (Matrix matrix = new Matrix())
{
matrix.RotateAt(angle, Center(bounds));
using (GraphicsPath path = new GraphicsPath())
{
path.AddRectangle(bounds);
path.Transform(matrix);
return path.IsVisible(location.X, location.Y);
}
}
}