コード例 #1
0
        public MandlebrotDisp()
        {
            InitializeComponent();

            int newLocX = (int)((this.pctBx_Display.Width - this.pnl_ColorEditor.Width) / 2) + this.pctBx_Display.Location.X;
            int newLocY = (int)((this.pctBx_Display.Height - this.pnl_ColorEditor.Height) / 2) + this.pctBx_Display.Location.Y;

            this.pnl_ColorEditor.Location = new Point(newLocX, newLocY);
            this.pnl_ColorEditor.Visible  = false;
            this.pnl_ColorEditor.Enabled  = false;
            this.lbl_Palette.Visible      = false;

            Plot_CenterCoord = new PointD(InitialX, InitialY);
            MaxPlotScale     = (InitialPlotWidth / pctBx_Display.Size.Width);
            PlotScale        = MaxScale;

            this.WindowState = FormWindowState.Normal;
            WindowMaximized  = false;

            PaletteManager.initializePaletteManager();
            InitializePaletteGenAdjust();
            InitializePaletteColorAdjust();
            InitializePaletteSelect();
            InitializePalettePreview();
            updateDisplay();
        }
コード例 #2
0
 private void btn_Revert_Click(object sender, EventArgs e)
 {
     SelectedColorStop = 0;
     PaletteManager.setCurrentPaletteCopy();
     ResetPaletteColorAdjust();
     InitializePaletteColorAdjust();
     PaletteColorAdjustEnter();
 }
コード例 #3
0
 private static void updatePaletteList()
 {
     cmbBx_AvailablePalettes.Items.Clear();
     for (int p = 0; p < PaletteManager.NumberOfPalettes; p++)
     {
         cmbBx_AvailablePalettes.Items.Add(PaletteManager.AvailablePalettes(p).Name);
     }
     cmbBx_AvailablePalettes.SelectedIndex = PaletteManager.IndCurrentPalette;
 }
コード例 #4
0
        private void pnlExit()
        {
            PaletteManager.setCurrentPaletteCopy();
            PaletteColorAdjustExit();
            PaletteGenAdjustExit();
            PaletteSelectExit();
            PalettePreviewExit();

            lbl_Palette.Visible = false;
        }
コード例 #5
0
        private void ProcessLines(Color[,] buffer, int x, int y, int endx, int endy, int width, double adjPlotScale, PointD firstPixelGCoord)
        {
            int   iColor;
            Color pixelColor;
            Color inMandSet = Color.Black;

            double xCoord, yCoord;
            int    dottedWidth = 16;
            double alphaDottedLine = (double)180 / 255;
            int    r, g, b;
            bool   juliaMode = false;

            for (int i = x; i < endx; i++)
            {
                for (int j = y; j < endy; j++)
                {
                    xCoord = i * adjPlotScale + firstPixelGCoord.X;
                    yCoord = firstPixelGCoord.Y - j * adjPlotScale;

                    if (juliaMode)
                    {
                        iColor     = juliaPixel(xCoord, yCoord);
                        pixelColor = (iColor >= 0) ? PaletteManager.ColorContainer(iColor) : inMandSet;
                    }
                    else
                    {
                        iColor     = mandlebrotPixel(xCoord, yCoord, (int)PaletteManager.IterationLim);
                        pixelColor = (iColor >= 0) ? PaletteManager.ColorContainer(iColor) : inMandSet;
                    }

                    if ((xCoord <= 1 * adjPlotScale && xCoord >= -1 * adjPlotScale && j % (2 * dottedWidth) >= dottedWidth) || (yCoord <= 1 * adjPlotScale && yCoord >= -1 * adjPlotScale && i % (2 * dottedWidth) >= dottedWidth))
                    {
                        r          = ((int)(alphaDottedLine * (255 - pixelColor.R) + (1 - alphaDottedLine) * pixelColor.R));
                        g          = ((int)(alphaDottedLine * (255 - pixelColor.G) + (1 - alphaDottedLine) * pixelColor.G));
                        b          = ((int)(alphaDottedLine * (255 - pixelColor.B) + (1 - alphaDottedLine) * pixelColor.B));
                        pixelColor = Color.FromArgb(r, g, b);
                    }

                    /*if (iColor == -2)
                     *  pixelColor = Color.White;
                     * else if (iColor == -1)
                     *  pixelColor = inMandSet;
                     * else
                     *  pixelColor = PaletteManager.ColorContainer(iColor);*/

                    buffer[i, j] = pixelColor;
                }
            }
        }
コード例 #6
0
        public void renderPaletteEditor()
        {
            PaletteManager.colorSetup();
            double scale = (double)PaletteManager.IterationLim / pctbx_PaletteGenEditorDisplay.Width;

            for (int x = 0; x < pctbx_PaletteGenEditorDisplay.Width; x++)
            {
                for (int y = 0; y < pctbx_PaletteGenEditorDisplay.Height; y++)
                {
                    ((Bitmap)pctbx_PaletteGenEditorDisplay.Image).SetPixel(x, y, PaletteManager.ColorContainer(((int)(scale * x)) % (int)PaletteManager.IterationLim));
                }
            }
            pctbx_PaletteGenEditorDisplay.Refresh();

            RenderPalettePreviewDisplay();
        }
コード例 #7
0
        private void btn_ColorSettings_Click(object sender, EventArgs e)
        {
            if (this.pnl_ColorEditor.Visible)
            {
                this.pnl_ColorEditor.Visible = false;
                this.pnl_ColorEditor.Enabled = false;

                PaletteManager.saveToCustomPalette();
                updatePaletteList();
                pnlExit();
                PaletteManager.colorSetup();
                updateDisplay();
            }
            else
            {
                this.pnl_ColorEditor.Visible = true;
                this.pnl_ColorEditor.Enabled = true;
                pnlEnter();
            }
        }
コード例 #8
0
        private void renderPalette()
        {
            // either dispose of the old Bitmap or simply reuse it!
            if (pctbx_PaletteDisplay.Image != null)
            {
                pctbx_PaletteDisplay.Image.Dispose();
            }

            pctbx_PaletteDisplay.Image = new Bitmap(pctbx_PaletteDisplay.Width, pctbx_PaletteDisplay.Height);

            double scale = (double)PaletteManager.IterationLim / pctbx_PaletteDisplay.Width;

            for (int x = 0; x < pctbx_PaletteDisplay.Width; x++)
            {
                for (int y = 0; y < pctbx_PaletteDisplay.Height; y++)
                {
                    ((Bitmap)pctbx_PaletteDisplay.Image).SetPixel(x, y, PaletteManager.ColorContainer(((int)(scale * x)) % (int)PaletteManager.IterationLim));
                }
            }
            pctbx_PaletteDisplay.Refresh();
        }
コード例 #9
0
        private void RenderPalettePreviewDisplay()
        {
            if (pctbx_PalettePreviewDisplay != null)
            {
                double adjPlotScale     = PlotScale * MaxPlotScale * pctBx_Display.Width / pctbx_PalettePreviewDisplay.Size.Width;
                PointD firstPixelGCoord = new PointD(
                    Plot_CenterCoord.X - 0.5d * adjPlotScale * pctbx_PalettePreviewDisplay.Size.Width,
                    Plot_CenterCoord.Y - 0.5d * adjPlotScale * pctbx_PalettePreviewDisplay.Size.Height
                    );

                int   color;
                Color inMandSet = Color.Black;
                for (int y = 0; y < pctbx_PalettePreviewDisplay.Height; y++)
                {
                    for (int x = 0; x < pctbx_PalettePreviewDisplay.Width; x++)
                    {
                        color = mandlebrotPixel(x * adjPlotScale + firstPixelGCoord.X, y * adjPlotScale + firstPixelGCoord.Y, previewIterationDepth);
                        ((Bitmap)pctbx_PalettePreviewDisplay.Image).SetPixel(x, y, color >= 0 ? PaletteManager.ColorContainer(color) : inMandSet);
                    }
                }

                pctbx_PalettePreviewDisplay.Refresh();
            }
        }
コード例 #10
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            if (pnl_ColorEditor.Visible == false)
            {
                bool parsingSuccess = true;

                double scale = MaxScale;
                if (!double.TryParse(txtbx_Scale.Text, out scale) || scale > MaxScale || scale < MinScale || double.IsNaN(scale) || double.IsInfinity(scale))
                {
                    txtbx_Scale.ForeColor = Color.Black;
                    txtbx_Scale.BackColor = Color.DarkGoldenrod;
                    parsingSuccess        = false;
                }
                else
                {
                    txtbx_Scale.ForeColor = Color.Gray;
                    txtbx_Scale.BackColor = Color.Black;
                }



                uint iterationDepth = PaletteManager.IterationLim;
                if (!uint.TryParse(txtbx_IterationDepth.Text, out iterationDepth) || iterationDepth > MaxIterationDepth || iterationDepth < MinIterationDepth)
                {
                    txtbx_IterationDepth.ForeColor = Color.Black;
                    txtbx_IterationDepth.BackColor = Color.DarkGoldenrod;
                    parsingSuccess = false;
                }
                else
                {
                    txtbx_IterationDepth.ForeColor = Color.Gray;
                    txtbx_IterationDepth.BackColor = Color.Black;
                }

                string centerText = txtbx_Center.Text;
                centerText = centerText.Replace(" ", "");
                centerText = centerText.Replace("(", "");
                centerText = centerText.Replace(")", "");
                bool centerTextValid = true;
                foreach (char c in centerText)
                {
                    switch (c)
                    {
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                    case '.':
                    case ',':
                    case '-':
                    case '+':
                    case 'E':
                    case 'e':
                        break;

                    default:
                    {
                        parsingSuccess  = false;
                        centerTextValid = false;
                        break;
                    }
                    }
                }

                string[] Coords = centerText.Split(',');
                if (Coords.Length != 2)
                {
                    centerTextValid = false;
                }


                double centerX = InitialX, centerY = InitialY;
                bool   cX = false, cY = false;
                if (centerTextValid)
                {
                    cX = double.TryParse(Coords[0], out centerX) && centerX <= 100 && centerX >= -100 && !double.IsNaN(centerX) && !double.IsInfinity(centerX);
                    cY = double.TryParse(Coords[1], out centerY) && centerY <= 100 && centerY >= -100 && !double.IsNaN(centerY) && !double.IsInfinity(centerY);
                }

                if (!centerTextValid || !cX || !cY)
                {
                    txtbx_Center.ForeColor = Color.Black;
                    txtbx_Center.BackColor = Color.DarkGoldenrod;
                    parsingSuccess         = false;
                }
                else
                {
                    txtbx_Center.ForeColor = Color.Gray;
                    txtbx_Center.BackColor = Color.Black;
                }

                if (parsingSuccess)
                {
                    Plot_CenterCoord             = new PointD(centerX, centerY);
                    PlotScale                    = scale;
                    PaletteManager.PaletteLength = (int)(((decimal)iterationDepth / PaletteManager.IterationLim) * PaletteManager.PaletteLength);
                    PaletteManager.IterationLim  = iterationDepth;
                    PaletteManager.colorSetup();
                    updateDisplay();
                }
            }
        }