public static ScaledPolygon CreateRectangleWithPivot(float x, float y, int width, int height, float pivotX, float pivotY)
{
var points = new Point[5];
// clockwise
points[0] = new Point(0, height);
points[1] = new Point(width, height);
points[2] = new Point(width, 0);
points[3] = new Point(0, 0);
points[4] = new Point(0, height);
// Now shift over by the pivot value
for (var i = 0; i < 5; ++i)
{
points[i].X -= Math.Abs(width*pivotX);
points[i].Y -= Math.Abs(height*pivotY);
}
return new ScaledPolygon
{
X = x,
Y = y,
Points = points
};
}