Example #1
0
        public ComplexPoint DoCmplxAdd(ComplexPoint arg)
        {
            x += arg.x;
            y += arg.y;

            return(this);
        }
Example #2
0
        public ComplexPoint GetAbsoluteMathsCoord(ComplexPoint pixelCoord)
        {
            ComplexPoint result = new ComplexPoint(
                (convConstX2 + pixelCoord.x) / convConstX1,
                (convConstY1 - pixelCoord.y) / convConstY2);

            return(result);
        }
Example #3
0
        public ComplexPoint GetDeltaMathsCoord(ComplexPoint pixelCoord)
        {
            ComplexPoint result = new ComplexPoint(
                pixelCoord.x / convConstX1,
                pixelCoord.y / convConstY2);

            return(result);
        }
Example #4
0
        public PixelCoord GetPixelCoord(ComplexPoint cmplxPoint)
        {
            PixelCoord result = new PixelCoord();

            result.xPixel = (int)(convConstX1 * cmplxPoint.x - convConstX2);
            result.yPixel = (int)(convConstY1 - convConstY2 * cmplxPoint.y);
            return(result);
        }
Example #5
0
        public ScreenPixelManage(Bitmap graphics, ComplexPoint screenBottomLeftCorner, ComplexPoint screenTopRightCorner)
        {
            convConstX1 = graphics.Width / (screenTopRightCorner.x - screenBottomLeftCorner.x);
            convConstX2 = convConstX1 * screenBottomLeftCorner.x;

            convConstY1 = graphics.Size.Height * (1.0 + screenBottomLeftCorner.y / (screenTopRightCorner.y - screenBottomLeftCorner.y));
            convConstY2 = graphics.Size.Height / (screenTopRightCorner.y - screenBottomLeftCorner.y);
        }
Example #6
0
        public ComplexPoint DoCmplxSq()
        {
            ComplexPoint result = new ComplexPoint(0, 0);

            result.x = x * x - y * y;
            result.y = 2 * x * y;

            return(result);
        }
Example #7
0
        public ComplexPoint DoCmplxSqPlusConst(ComplexPoint arg)
        {
            ComplexPoint result = new ComplexPoint(0, 0);

            result.x  = x * x - y * y;
            result.y  = 2 * x * y;
            result.x += arg.x;
            result.y += arg.y;
            return(result);
        }
Example #8
0
        public Bitmap GetImage(int width, int height, double xMinParam, double xMaxParam, double yMinParam, double yMaxParam, int kParam, double power, int startHue, int endHue, double power2, float light)
        {
            int    kMax        = kParam;
            int    xyPixelStep = 1;
            double yMin        = yMinParam;
            double yMax        = yMaxParam;
            double xMin        = xMinParam;
            double xMax        = xMaxParam;

            Bitmap bmp = new Bitmap(width, height);

            int numColours = kMax;

            ColourTable colourTable = new ColourTable(numColours, power, power2, startHue, endHue, light);

            int    kLast = -1;
            double modulusSquared;
            Color  color;
            Color  colorLast = Color.Red;

            ComplexPoint screenBottomLeft = new ComplexPoint(xMinParam, yMinParam);
            ComplexPoint screenTopRight   = new ComplexPoint(xMaxParam, yMaxParam);

            ScreenPixelManage myPixelManager = new ScreenPixelManage(bmp, screenBottomLeft, screenTopRight);

            ComplexPoint pixelStep = new ComplexPoint(xyPixelStep, xyPixelStep);
            ComplexPoint xyStep    = myPixelManager.GetDeltaMathsCoord(pixelStep);

            int yPix = bmp.Height - 1;

            for (double y = yMinParam; y < yMaxParam; y += xyStep.y)
            {
                int xPix = 0;
                for (double x = xMinParam; x < xMaxParam; x += xyStep.x)
                {
                    ComplexPoint c  = new ComplexPoint(x, y);
                    ComplexPoint zk = new ComplexPoint(0, 0);
                    int          k  = 0;
                    do
                    {
                        zk             = zk.DoCmplxSqPlusConst(c);
                        modulusSquared = zk.DoModulusSq();
                        k++;
                    }while ((modulusSquared <= 4.0) && (k < kMax));

                    if (k == kLast)
                    {
                        color = colorLast;
                    }
                    else
                    {
                        color     = colourTable.GetColour(k);
                        colorLast = color;
                    }

                    if (k == kMax)
                    {
                        color = Color.Black;
                    }

                    if (xyPixelStep == 1)
                    {
                        if ((xPix < bmp.Width) && (yPix >= 0))
                        {
                            bmp.SetPixel(xPix, yPix, color);
                        }
                    }
                    else
                    {
                        for (int pX = 0; pX < xyPixelStep; pX++)
                        {
                            for (int pY = 0; pY < xyPixelStep; pY++)
                            {
                                if (((xPix + pX) < bmp.Width) && ((yPix - pY) >= 0))
                                {
                                    bmp.SetPixel(xPix + pX, yPix - pY, color);
                                }
                            }
                        }
                    }

                    xPix += xyPixelStep;
                }
                yPix -= xyPixelStep;
            }

            return(bmp);
        }