Hi guys,

I am working on a conversion of the Mandelbrot Fractal from Java to C# and my programming skills are lacking quite a bit. I am desperately trying to improve but I have come across some errors that are stumping me. I have attached a txt file with the code I have so far and below is the segment of code I am getting errors with.

private void mandelbrot() // calculate all points
                {
                    int x, y;
                    float h, b, alt = 0.0f;

                    action = false;
                    setCursor(c1);}
                    public function setCursor;
                    float System.WriteLine("Mandelbrot-Set will be produced - please wait...");
                    //float showStatus("Mandelbrot-Set will be produced - please wait...");
                    for (int x = 0; x < x1; x += 2) 
                        for (int y = 0; y < y1; y++) 
                        {
                            h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y); // color value
                            if (h != alt)
                            {
                                b = 1.0f - h * h; // brightnes
                                ///djm added
                                ///HSBcol.fromHSB(h,0.8f,b); //convert hsb to rgb then make a Java Color
                                ///Color col = new Color(0,HSBcol.rChan,HSBcol.gChan,HSBcol.bChan);
                                ///g1.setColor(col);
                                //djm end
                                //djm added to convert to RGB from HSB

                                g1.setColor(Color.getHSBColor(h, 0.8f, b));
                                //djm test
                                Color col = Color.getHSBColor(h, 0.8f, b);
                                int red = col.getRed();
                                int green = col.getGreen();
                                int blue = col.getBlue();
                                //djm 
                                alt = h;
                            }
                            g1.drawLine(x, y, x + 1, y);
                        }
                    showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
                    setCursor(c2);
                    action = true;
        }

If anyone can offer me some advice on how to resolve some of these issues that would be great. I know there are quite a few, but if anyone can give me some tips on the best way of tackling a conversion like this or point me in the direction to resolving this, then I would really appreciate it. Thnks a lot for your time and help.

regards

Attachments
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace mb2
{
    public partial class Form1 : Form
    {

        private const int MAX = 256;      // max iterations    
        private const double SX = -2.025; // start value real
        private const double SY = -1.125; // start value imaginary
        private const double EX = 0.6;    // end value real
        private const double EY = 1.125;  // end value imaginary
        private static int x1, y1, xs, ys, xe, ye;
        private static double xstart, ystart, xende, yende, xzoom, yzoom;
        private static bool action, rectangle, finished;
        private static float xy;
        private Bitmap pictureBit;
        private Graphics g1;
        private Cursor c1, c2;
        //rf not needed private HSB HSBcol=new HSB();


        public Form1()
        {


            InitializeComponent();

            //HSBcol = new HSB();
            //setSize(640, 480);
            finished = false;
            //addMouseListener(this);
            //addMouseMotionListener(this);
            c1 = Cursors.WaitCursor;
            c2 = Cursors.Cross;
            x1 = pictureBox1.Size.Width;
            y1 = pictureBox1.Size.Height;
            xy = (float)x1 / (float)y1;
            //picture = createImage(x1, y1);
            pictureBit = new Bitmap(x1, y1);
            pictureBox1.Image = pictureBit;
            g1 = Graphics.FromImage(pictureBit);
            //g1 = picture.getGraphics();
            finished = true;

            start();
        }
        public void start()
        {
            action = false;
            rectangle = false;
            initvalues();
            xzoom = (xende - xstart) / (double)x1;
            yzoom = (yende - ystart) / (double)y1;
            mandelbrot();
        }
        private void initvalues() // reset start values
        {
            xstart = SX;
            ystart = SY;
            xende = EX;
            yende = EY;
            if ((float)((xende - xstart) / (yende - ystart)) != xy)
                xstart = xende - (yende - ystart) * (double)xy;
        }

        private void mandelbrot() // calculate all points
                {
                    int x, y;
                    float h, b, alt = 0.0f;

                    action = false;
                    setCursor(c1);}
                    public function setCursor;
                    float System.WriteLine("Mandelbrot-Set will be produced - please wait...");
                    //float showStatus("Mandelbrot-Set will be produced - please wait...");
                    for (int x = 0; x < x1; x += 2) 
                        for (int y = 0; y < y1; y++) 
                        {
                            h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y); // color value
                            if (h != alt)
                            {
                                b = 1.0f - h * h; // brightnes
                                ///djm added
                                ///HSBcol.fromHSB(h,0.8f,b); //convert hsb to rgb then make a Java Color
                                ///Color col = new Color(0,HSBcol.rChan,HSBcol.gChan,HSBcol.bChan);
                                ///g1.setColor(col);
                                //djm end
                                //djm added to convert to RGB from HSB

                                g1.setColor(Color.getHSBColor(h, 0.8f, b));
                                //djm test
                                Color col = Color.getHSBColor(h, 0.8f, b);
                                int red = col.getRed();
                                int green = col.getGreen();
                                int blue = col.getBlue();
                                //djm 
                                alt = h;
                            }
                            g1.drawLine(x, y, x + 1, y);
                        }
                    showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
                    setCursor(c2);
                    action = true;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}

Hi, thanks very much for this, I apprciate the help, I'll take a loook at the link and see what I can do.

regards

This article has been dead for over six months. Start a new discussion instead.