示例#1
0
        public static Extent <double> Aspect(this Extent <double> extent, double targetAspect)
        {
            var currentAspect = extent.Aspect();

            if (Math.Abs(currentAspect) < Math.Abs(targetAspect))
            {
                var width = extent.Width();
                var diff  = width * (targetAspect / currentAspect - 1) / 2;
                return(Create(extent.S.X - diff, extent.S.Y, extent.E.X + diff, extent.E.Y));
            }
            else
            {
                var height = extent.Height();
                var diff   = height * (currentAspect / targetAspect - 1) / 2;
                return(Create(extent.S.X, extent.S.Y - diff, extent.E.X, extent.E.Y + diff));
            }
        }
示例#2
0
 public static double Aspect(this Extent <int> extent) => extent.Width() * 1.0 / extent.Height();
示例#3
0
 public static double Area(this Extent <int> extent) => Math.Abs(extent.Width() * extent.Height());
示例#4
0
 public static double Aspect(this Extent <double> extent) => extent.Width() / extent.Height();