static void Transform(XMMatrix target, Viewport viewport, float angle, float scale, float w, float h) { using var r = new XMMatrix(); using var b = new XMMatrix(); using var s = new XMMatrix(); using var t = new XMMatrix(); r.RotationZ((float)(angle / 180 * Math.PI)); s.Scaling(scale, scale, 1.0f); t.Translation(viewport.Width / 2 - w * scale / 2, viewport.Height / 2 - h * scale / 2, 0.0f); b.Translation(-viewport.Width / 2, -viewport.Height / 2, 0.0f); b.Multiply(r); r.Set(b); b.Identity(); b.Translation(viewport.Width / 2, viewport.Height / 2, 0.0f); r.Multiply(b); s.Multiply(t); s.Multiply(r); target.Set(s); }