public static IDisposable RotateTransform(this XGraphics gfx, Elements.Element element, XElement context, IXmlNamespaceResolver resolver) { //rotation = Math.PI * 2 * rotation / 360.0; var state = gfx.SaveState(); var rotation = element.Rotation.GetValue(context, resolver); var origin = element.RotationOrigin.GetValue(context, resolver); var frame = element.Position.GetValue(context, resolver); origin = new XPoint(origin.X * frame.Width + frame.X, origin.Y * frame.Height + frame.Y); gfx.RotateAtTransform(rotation, origin); return(state); }