public override void RenderToBuffer(MandelbrotSet set, PixelBuffer buffer)
        {
            var renderer = new ContourRenderer(this.tracer);
            Palette palette = new DefaultPalette();
            int maxCount = set.EstimateMaxCount();
            var bandMap = new LogarithmicBandMap(maxCount, 30.0);

            renderer.Render(buffer, set, bandMap, maxCount);
            buffer.ApplyPalette(palette);
        }
示例#2
0
        public override void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount)
        {
            this.sizex = buffer.SizeX;
            this.sizey = buffer.SizeY;
            this.maxCount = maxCount;
            this.bandMap = bandMap;
            this.buffer = buffer;
            this.InitializeCoordinateMap(sizex, sizey, set);
            this.NumberOfContours = 0;

            for (int i = 0; i < sizex; i++)
            {
                // Keep track of the last band and how many pixels into that band we are
                // Start crawling after we see a few pixels of the same band
                int lastBand = 0;
                int numberOfPointsFoundInBand = 0;
                int startOfBand = 0;
                bool calculated = false;
                for (int j = 0; j < sizey; j++)
                {
                    int band = GetOrCalculateBand(i, j, out calculated);
                    System.Diagnostics.Debug.Assert(band != 0); // This should only be returned for points out of range, which should be none
                    if (calculated && (band == lastBand))
                    {
                        numberOfPointsFoundInBand++;
                    }
                    else
                    {
                        if (band != lastBand)
                        {
                            startOfBand = j;
                            lastBand = band;
                        }
                        numberOfPointsFoundInBand = 1;
                    }
                    // If we are 8 or more pixels into the band, start crawling
                    if (numberOfPointsFoundInBand > 8)
                    {
                        if (this.Crawl(i, startOfBand, band))
                        {
                            this.NumberOfContours = this.NumberOfContours + 1;
                            this.FillCrawl(i, startOfBand, band);
                            this.DumpBits();
                        }
                        this.ClearSavedBits();

                        numberOfPointsFoundInBand = 0;
                    }
                }
            }
        }
示例#3
0
        public override void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount)
        {
            this.InitializeCoordinateMap(buffer.SizeX, buffer.SizeY, set);

            DoubleComplexNumber temp = new DoubleComplexNumber(0.0, 0.0);
            for (int i = 0; i < buffer.SizeX; i++)
            {
                temp.X = this.XCoordinates[i];
                for (int j = 0; j < buffer.SizeY; j++)
                {
                    temp.Y = this.YCoordinates[j];
                    int count = temp.CalculateCount(maxCount);
                    this.SetBand(buffer, bandMap, i, j, count);
                }
            }
        }
示例#4
0
        public override double Evaluate(MandelbrotSet set)
        {
            double retval = 0.0;

            // Use logarithmic band map but combine fewer bands than we will in full rendering
            var bandMap = new LogarithmicBandMap(set.EstimateMaxCount(), 55.0);

            this.Buffer.Clear();
            this.ContourRenderer.Render(this.Buffer, set, bandMap, set.EstimateMaxCount());

            // The more contours, the more interesting
            retval = this.ContourRenderer.NumberOfContours;

            var histogram = new Histogram();
            histogram.Evaluate(this.Buffer);
            int pointsInSet = histogram.GetValue(-1);

            // If at least some points in the set appear, it is more interesting
            if (pointsInSet > 0)
            {
                if ((pointsInSet == (size * size)))
                    return Double.NegativeInfinity;
                retval *= 1.6;

                // Reduce the interest if there are too many points in the set
                double r = ((double)(size * size) / pointsInSet) / 100;
                retval += r;
            }

            // The more different colors the more interesting.  Scaled so we don't get too complex.
            // Use negative to make more colors less interesting, thus reducing noisy areas
             retval += histogram.NumberOfValues / 1.0;

            // All else being equal, favor pictures of lower estimated count and thus speed
            // This is also a zoom avoidance feature
             //   retval -= set.EstimateMaxCount() / 200;

            return retval;
        }
示例#5
0
 public abstract double Evaluate(MandelbrotSet set);
 public abstract void RenderToBuffer(MandelbrotSet set, PixelBuffer buffer);
示例#7
0
 public abstract void Render(PixelBuffer buffer, MandelbrotSet set, BandMap bandMap, int maxCount);
示例#8
0
        protected virtual void InitializeCoordinateMap(int sizex, int sizey, MandelbrotSet set)
        {
            this.XCoordinates = new double[sizex];
            this.YCoordinates = new double[sizey];

            DoubleComplexNumber center = (DoubleComplexNumber)set.Center;
            double size = set.Side;
            double gapX = size / sizex;
            double gapY = size / sizey;
            double gap = Math.Min(gapX, gapY);

            double x = center.X - ((gap * sizex) / 2.0);
            double y = center.Y - ((gap * sizey) / 2.0);
            for (int i = 0; i < sizex; i++)
            {
                this.XCoordinates[i] = x;
                x += gap;
            }
            for (int i = 0; i < sizey; i++)
            {
                this.YCoordinates[i] = y;
                y += gap;
            }
        }