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;
using System.Drawing.Drawing2D;




/* 
 * @(#)fractal.java - Fractal Program Mandelbrot Set 
 * www.eckhard-roessel.de
 * Copyright (c) Eckhard Roessel. All Rights Reserved.
 * 06/30/2000 - 03/29/2000
 */
//import java.awt.*;
//import java.applet.*;   
//import java.awt.event.*;
/** 
 * @version 1.1
 * @author Eckhard Roessel
 * @modified 03/29/2001
 * @modified 08/16/2006 tweaked by Duncan Mullier 8/2006
 */
//public class Fractal extends Applet implements MouseListener, MouseMotionListener

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public Form1(){
            Console.WriteLine("******* Form1()");
            InitializeComponent();
        }

        class HSB{
            public float rChan, gChan, bChan;

            // constructr 
            public HSB(){
                Console.WriteLine("******* HSB.HSB()");
                rChan = gChan = bChan = 0;
            }
            public void fromHSB(float h,float s,float b){

            float  red = b;
            float green = b;
            float blue = b;

            if (s != 0)
            {
                float max = b;
                float dif = b * s / 255f;
                float min = b - dif;

                float h2 = h * 360f / 255f;

                if (h2 < 60f)
                {
                    red = max;
                    green = h2 * dif / 60f + min;
                    blue = min;
                }
                else if (h2 < 120f)
                {
                    red = -(h2 - 120f) * dif / 60f + min;
                    green = max;
                    blue = min;
                }
                else if (h2 < 180f)
                {
                    red = min;
                    green = max;
                    blue = (h2 - 120f) * dif / 60f + min;
                }
                else if (h2 < 240f)
                {
                    red = min;
                    green = -(h2 - 240f) * dif / 60f + min;
                    blue = max;
                }
                else if (h2 < 300f)
                {
                    red = (h2 - 240f) * dif / 60f + min;
                    green = min;
                    blue = max;
                }
                else if (h2 <= 360f)
                {
                    red = max;
                    green = min;
                    blue = -(h2 - 360f) * dif / 60 + min;
                }
                else
                {
                    red = 0;
                    green = 0;
                    blue = 0;
                }
            }

           rChan = (int)Math.Round(Math.Min(Math.Max(red, 0f), 255));
           gChan = (int)Math.Round(Math.Min(Math.Max(green, 0), 255));
           bChan = (int)Math.Round(Math.Min(Math.Max(blue, 0), 255));
            }
        }


    private readonly  int MAX = 256;      // max iterations
    private readonly  double SX = -2.025; // start value real
    private readonly  double SY = -1.125; // start value imaginary
    private readonly  double EX = 0.6;    // end value real
    private readonly  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 Boolean action, rectangle, finished;
    private static float xy;
    private String statusMessage = "";

    private Image picture;
    private Graphics g1;
    private Cursor c1, c2;
    private HSB HSBcol = new HSB();


    public void init() // all instances will be prepared
    {

        Console.WriteLine("******* Form1()");
        //HSBcol = new HSB();

        finished = false;
        /* TBD
         * 
        //addMouseListener(this);
        //addMouseMotionListener(this);
        */


        c1 = Cursors.WaitCursor;
        c2 = Cursors.Cross;
        //c1 = new Cursor(Cursor.WAIT_CURSOR);
        //c2 = new Cursor(Cursor.CROSSHAIR_CURSOR);


        x1 = pictureBox1.Size.Width;
        y1 = pictureBox1.Size.Height;

        xy = (float)x1 / (float)y1;

        //picture = createImage(x1, y1); 
        picture = new System.Drawing.Bitmap(x1, y1); 
        //g1 = picture.getGraphics();
        g1 = Graphics.FromImage(picture);
        finished = true;
    }

    public void destroy() // delete all instances 
    {
        if (finished)
        {
           // removeMouseListener(this);
           // removeMouseMotionListener(this);
            picture = null;
            g1 = null;
            c1 = null;
            c2 = null;
           // System.gc(); // garbage collection
            GC.Collect();
        }
    }
    public void start()
    {
        action = false;
        rectangle = false;
      initvalues();
        xzoom = (xende - xstart) / (double)x1;
        yzoom = (yende - ystart) / (double)y1;
      mandelbrot(); 
    }
    public void stop()
    {
    }

   /* public void paint(Graphics g)
    {
        update(g);
    }*/

    public void update(Graphics g)
    {
        Pen myPen = new Pen(Color.White);

        g.DrawImage(picture,0,0);

        if (rectangle){
            if (xs < xe)
            {
                if (ys < ye){ 
                    g.DrawRectangle(myPen, xs, ys, (xe - xs), (ye - ys));
                }
            }
            else
            {
               g.DrawRectangle(myPen,xs, ye, (xe - xs), (ys - ye));
            }
            myPen.Dispose();
        }
        /*
        g.drawImage(picture, 0, 0, this);

        if (rectangle)
        {
            g.setColor(Color.white);
            if (xs < xe)
            {
                if (ys < ye) g.drawRect(xs, ys, (xe - xs), (ye - ys));
                else g.drawRect(xs, ye, (xe - xs), (ys - ye));
            }
            else
            {
                if (ys < ye) g.drawRect(xe, ys, (xs - xe), (ye - ys));
                else g.drawRect(xe, ye, (xs - xe), (ys - ye));
            }
        }*/

    }

    private void mandelbrot() // calculate all points
    {**
        int x, y;
        float h, b, alt = 0.0f;
**
        action = false;
        //setCursor(c1);
        this.Cursor = c1;
        //showStatus("Mandelbrot-Set will be produced - please wait...");
        //statusMessage = "Mandelbrot-Set will be produced - please wait...";
        for (x = 0; x < x1; x += 2)
            for (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


               //  g1.setColor(Color.getHSBColor(h, 0.8f, b));

                    Color col = 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);
                Pen pen = new Pen(color);
                g1.DrawLine(pen, x, y, x + 1, y);

            }
      //  showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
        //setCursor(c2);
        this.Cursor = c2;
        action = true;
    }

    private float pointcolour(double xwert, double ywert) // color value from 0.0 to 1.0 by iterations
    {
        double r = 0.0, i = 0.0, m = 0.0;
        int j = 0;

        while ((j < MAX) && (m < 4.0))
        {
            j++;
            m = r * r - i * i;
            i = 2.0 * r * i + ywert;
            r = m + xwert;
        }
        return (float)j / (float)MAX;
    }

    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 Form1_Load(object sender, EventArgs e)
    {
          //Form1.StatusText ()
    }
    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;

        g1 = g;
        action = false;
        rectangle = false;
        initvalues();
        xzoom = (xende - xstart) / (double)x1;
        yzoom = (yende - ystart) / (double)y1;

        //picture = g.DrawImage;

        //g.DrawImage(picture,0,0);
        update(g);
        mandelbrot();

    }
    private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
    {


        if (action)
        {
            xs = e.X;
            ys = e.Y;
        }
        update(pictureBox1.CreateGraphics());

    }

    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        //e.consume();
        if (action)
        {
            xe = e.X;
            ye = e.Y;
            rectangle = true;
            //repaint();
            update(pictureBox1.CreateGraphics());
            Refresh();
        }
    }
    private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
    {
        rectangle = false;
    }

    private void pictureBox1_Click(object sender, EventArgs e)
    {

    }

    }
}

i get a n error on Color col = Color.getHSBColor(h, 0.8f, b);, and Pen pen = new Pen(color);
Can anyone help me ???

There is no method 'getHSBColor' on the Color structure, so you'll get an error there. And you have no variable named 'color' in that method, so again an error.

Next time give the exact error you get (copy/paste from visual studio) and the lines that give it. Posting this much code and making people search through it will cause you not to get answers.

i m sorry, but i dont understand what do i need to add?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.