Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Fractals
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- //Code for MandelbrotFractal()
- public void MandelbrotFractal()
- {
- int c, i, j, w = pictureBox1.Width + pictureBox2.Width, h = pictureBox1.Height, m = 50;
- Bitmap b = new Bitmap(w, h);
- for (i = 0; i < w; i++)
- {
- for (j = 0; j < h; j++)
- {
- double x0 = 4.0 * (i - w / 2) / w - 1; //w-1 sets where on screen it's placed according to width
- double y0 = 4.0 * (j - h / 2) / h;
- double x = 0.0, y = 0.0;
- for (c = 0; x * x + y * y <= 4.0 && c < m; c++)
- {
- var t = x * x - y * y + x0;
- y = 2.0 * x * y + y0; x = t;
- }
- //int v = c == m ? 255 : c * 10 % 255;
- int v;
- if (c == m)
- v = 255; //interior color
- else
- v = c * 10 % 255; //exterior color
- b.SetPixel(i, j, Color.FromArgb(v, v, v));
- }
- }
- pictureBox1.Image = b;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Form1.ActiveForm.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- MandelbrotFractal();
- }
- private void pictureBox1_MouseEnter(object sender, EventArgs e)
- {
- }
- //
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement