Esempio n. 1
0
        public static IEnumerable <CellInfo> Plan(ScreenInfo screenInfo)
        {
            var w      = screenInfo.Size.X;
            var h      = screenInfo.Size.Y;
            var screen = Extent.Create(0, 0, w - 1, h - 1);
            var extent = screenInfo.Bounds.Aspect(screen.Aspect());

            double X(int x) => MathEx.Translate(x, 0, w - 1, extent.S.X, extent.E.X);
            double Y(int y) => MathEx.Translate(y, 0, h - 1, extent.S.Y, extent.E.Y);

            var i = (int)Math.Sqrt(screen.Area() / extent.Area()) / 4;

            return(Partition(screen, 128, 128)
                   .Select(
                       e => new CellInfo {
                Iterations = i,
                Cell = e,
                Bounds = Extent.Create(X(e.S.X), Y(e.S.Y), X(e.E.X), Y(e.E.Y))
            }));
        }
Esempio n. 2
0
        private static IEnumerable <Extent <int> > Partition(Extent <int> screen, int width, int height)
        {
            var ey = screen.E.Y;
            var ex = screen.E.X;

            var sy = screen.S.Y;

            while (sy < ey)
            {
                var sx = screen.S.X;
                while (sx < ex)
                {
                    yield return(Extent.Create(
                                     sx,
                                     sy,
                                     Math.Min(sx + width - 1, ex),
                                     Math.Min(sy + height - 1, ey)));

                    sx += width;
                }

                sy += height;
            }
        }
Esempio n. 3
0
 public IActionResult GetImage(int i, int w, int h, double sx, double sy, double ex, double ey) =>
 File(Paintbrot.Paint(i, w, h, Extent.Create(sx, sy, ex, ey)), "image/png");
Esempio n. 4
0
 public IActionResult Plan(int w, int h) =>
 Json(
     Paintbrot.Plan(
         new ScreenInfo {
     Size = Point.Create(w, h), Bounds = Extent.Create(-2.5, -1, 1, 1)
 }));