Exemplo n.º 1
0
        public static Matrix To(this MathRect source, MathRect target)
        {
            var    offset = target.BottomLeft - source.BottomLeft;
            double scaleX = target.Width / source.Width;
            double scaleY = target.Height / source.Height;
            var    result = Matrix.Identity;

            result.Translate(offset.X, offset.Y);
            result.ScaleAt(scaleX, scaleY, source.Left + offset.X, source.Bottom + offset.Y);
            return(result);
        }
Exemplo n.º 2
0
 public static Point Trim(this Point point, MathRect rect) => new Point(point.X.Trim(rect.Left.IsNaN() ? double.NegativeInfinity : rect.Left, rect.Right.IsNaN() ? double.PositiveInfinity : rect.Right), point.Y.Trim(rect.Bottom.IsNaN() ? double.NegativeInfinity : rect.Bottom, rect.Top.IsNaN() ? double.PositiveInfinity : rect.Top));
Exemplo n.º 3
0
 public static Point Center(this MathRect rect) => new Point((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);