Example #1
0
        internal static Arc Fill(Size availableSize, double start, double end)
        {
            if (availableSize.Width == 0 ||
                double.IsNaN(availableSize.Width) ||
                availableSize.Height == 0 ||
                double.IsNaN(availableSize.Height))
            {
                return new Arc(new Point(0, 0), start, end, 0, false);
            }

            var p0 = new Point(0, 0);
            var arc = new Arc(p0, start, end, 1, false);
            var rect = new Rect();
            var ps = arc.GetPoint(start);
            rect.Union(ps);
            rect.Union(arc.GetPoint(end));
            foreach (var quadrant in arc.GetQuadrants(start, end))
            {
                rect.Union(quadrant);
            }
            var wf = availableSize.Width / rect.Width;
            var hf = availableSize.Height / rect.Height;
            var r = Math.Min(wf, hf);
            rect.Scale(r, r);
            var v = rect.FindTranslationToCenter(availableSize);
            return new Arc(p0 + v, start, end, r, false);
        }