public MainForm() { InitializeComponent(); mMandelbrotGenerator = new MandelbrotGenerator(Width, Height); mMandelbrotGenerator.Width = panel1.Width; mMandelbrotGenerator.Height = panel1.Height; mMandelbrotGenerator.FixAspect(); mMandelbrotGenerator.MandlebrotReady += MMandelbrotGenerator_MandlebrotReady; mMandelbrotGenerator.MandlebrotPaletteChanged += MMandelbrotGenerator_MandlebrotPaletteChanged; MouseWheel += Form1_MouseWheel; UpdateMandelbrot(); propertyGrid1.SelectedObject = mMandelbrotGenerator; //Load the presets from presets.xml (if it exists), and use the defaults otherwise string xmlpath = Path.GetDirectoryName(Application.ExecutablePath) + "\\presets.xml"; if (File.Exists(xmlpath)) { //try loading try { mPresets = MandelbrotPresets.FromXml(File.ReadAllText(xmlpath)); } catch { mPresets = MandelbrotPresets.GenerateDefault(); SavePresets(); } } else { mPresets = MandelbrotPresets.GenerateDefault(); SavePresets(); } UpdatePresets(); }
private void exportButton_Click(object sender, EventArgs e) { //Generate it 4 times as big, to scale it down later and have nice anti-aliasing MandelbrotGenerator mg = new MandelbrotGenerator(mMandelbrotGeneratorTemplate, (int)widthUpDown.Value * 4, (int)heightUpDown.Value * 4); mg.FixAspect(); mg.MandlebrotReady += delegate(Bitmap mandelbrot, bool is2Times) { mandelbrot = new Bitmap(mandelbrot, (int)widthUpDown.Value, (int)heightUpDown.Value); mandelbrot.Save(pathTextBox.Text, ImageFormat.Png); //Controls can't be changed from a different thread progressBar.Invoke((Action) delegate { progressBar.Style = ProgressBarStyle.Blocks; progressBar.Value = 100; }); DialogResult = DialogResult.OK; }; progressBar.Enabled = true; progressBar.Style = ProgressBarStyle.Marquee; cancelButton.Enabled = false; exportButton.Enabled = false; groupBox1.Enabled = false; groupBox2.Enabled = false; mg.StartGenerateMandelbrot(); }
public Scene(MandelbrotGenerator generator, double posX, double posY, double pixelToWorldScale, int numIterations) { PosX = posX; PosY = posY; PixelToWorldScale = pixelToWorldScale; NumIterations = numIterations; Generator = generator; Generate(); }
public static void Main(string[] args) { var height = 2048; short maxIterations = 1000; var scale = 2F; MandelbrotGenerator gen = new MandelbrotGenerator(height, maxIterations, scale); gen.Generate(); gen.SaveImage("image.jpg"); Console.Read(); }
public MandelbrotPreset(MandelbrotGenerator template, String name) { this.name = name; x = template.MandelbrotX; y = template.MandelbrotY; width = template.MandelbrotWidth; height = template.MandelbrotHeight; maxCount = template.MandlebrotMaxCount; style = template.MandelbrotStyle; palette = new int[template.MandelbrotPalette.Count]; for (int i = 0; i < template.MandelbrotPalette.Count; i++) { palette[i] = template.MandelbrotPalette[i].ToArgb(); } }
public void ApplyToGenerator(MandelbrotGenerator generator) { generator.MandelbrotX = x; generator.MandelbrotY = y; generator.MandelbrotWidth = width; generator.MandelbrotHeight = height; generator.MandelbrotStyle = style; generator.MandlebrotMaxCount = maxCount; generator.BeginUpdatePalette(); generator.MandelbrotPalette.Clear(); foreach (int c in palette) { generator.MandelbrotPalette.Add(Color.FromArgb(c)); } generator.EndUpdatePalette(); generator.FixAspect(); }
//create a new MandelbrotGenerator based on another public MandelbrotGenerator(MandelbrotGenerator template, int width, int height) : this(width, height) { MandelbrotX = template.MandelbrotX; MandelbrotY = template.MandelbrotY; MandelbrotWidth = template.MandelbrotWidth; MandelbrotHeight = template.MandelbrotHeight; MandelbrotStyle = template.MandelbrotStyle; mMandlebrotMaxCount = template.mMandlebrotMaxCount; BeginUpdatePalette(); MandelbrotPalette.Clear(); foreach (Color c in template.MandelbrotPalette) { MandelbrotPalette.Add(c); } EndUpdatePalette(); }
public MandelExporterForm(MandelbrotGenerator generatorTemplate) { mMandelbrotGeneratorTemplate = generatorTemplate; InitializeComponent(); }
public Form1() { InitializeComponent(); generator = new MandelbrotGenerator(pbCanvas.Width, pbCanvas.Height); }
public Scene(MandelbrotGenerator generator) { Generator = generator; Generate(); }