public void ScaleAt(float scaleX, float scaleY, Vex.Point center) { scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX; scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY; Matrix tm = TransformMatrix.Clone(); tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append); Matrix itm = tm.Clone(); itm.Invert(); foreach (uint id in list) { DesignInstance inst = instanceManager[id]; using (Matrix ms = inst.GetMatrix().SysMatrix()) { ms.Translate(-center.X, -center.Y, MatrixOrder.Append); ms.Multiply(itm, MatrixOrder.Append); ms.Scale(scaleX, scaleY, MatrixOrder.Append); ms.Multiply(tm, MatrixOrder.Append); ms.Translate(center.X, center.Y, MatrixOrder.Append); inst.SetMatrix(ms.VexMatrix()); } } tm.Dispose(); itm.Dispose(); transformMatrix.ScaleAt(scaleX, scaleY, center.SysPointF()); isDirty = true; MainForm.CurrentStage.InvalidateTransformedSelection(); }
public PointF[] GetTransformedPoints(Matrix globalMatrix) { Vex.Rectangle tb = UntransformedBounds; PointF[] pts = tb.SysPointFs(); using (Matrix m = TransformMatrix.Clone()) { m.Multiply(globalMatrix, MatrixOrder.Append); m.TransformPoints(pts); } return(pts); }
public void DrawScaled(Graphics g, float scaleX, float scaleY, Vex.Point center) { Matrix m = g.Transform; scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX; scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY; Matrix tm = TransformMatrix.Clone(); tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append); Matrix itm = tm.Clone(); itm.Invert(); foreach (uint id in list) { DesignInstance inst = instanceManager[id]; using (Matrix ms = inst.GetMatrix().SysMatrix()) { ms.Translate(-center.X, -center.Y, MatrixOrder.Append); ms.Multiply(itm, MatrixOrder.Append); ms.Scale(scaleX, scaleY, MatrixOrder.Append); ms.Multiply(tm, MatrixOrder.Append); ms.Translate(center.X, center.Y, MatrixOrder.Append); ms.Multiply(m, MatrixOrder.Append); g.Transform = ms; inst.DrawOutlineIntoRaw(g, 0, 0); } } tm.Dispose(); itm.Dispose(); g.Transform = m; }