Ejemplo n.º 1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     W             = (int)canvas1.ActualWidth;
     H             = (int)canvas1.ActualHeight;
     Image1.Width  = W;
     Image1.Height = H;
     point         = JG_Matrix.Matrix.FromArray(new double[] { 0, 0 });
     P1            = 0.01;
     P2            = 0.85;
     P3            = 0.07;
     P4            = 0.07;
     F1            = JG_Matrix.Matrix.FromArray(new double[, ] {
         { 0.00, 0.00 }, { 0.00, 0.16 }
     });
     F2 = JG_Matrix.Matrix.FromArray(new double[, ] {
         { 0.85, 0.04 }, { -0.04, 0.85 }
     });
     F3 = JG_Matrix.Matrix.FromArray(new double[, ] {
         { 0.20, -0.26 }, { 0.23, 0.22 }
     });
     F4 = JG_Matrix.Matrix.FromArray(new double[, ] {
         { -0.15, 0.28 }, { 0.26, 0.24 }
     });
     C1       = JG_Matrix.Matrix.FromArray(new double[] { 0.0, 0.00 });
     C2       = JG_Matrix.Matrix.FromArray(new double[] { 0.0, 1.60 });
     C3       = JG_Matrix.Matrix.FromArray(new double[] { 0.0, 1.60 });
     C4       = JG_Matrix.Matrix.FromArray(new double[] { 0.0, 0.44 });
     my_Color = Colors.Lime;
     Init();
     MnuShowSettings.IsChecked = true;
     ShowSettingForm();
     App_Started = true;
 }
Ejemplo n.º 2
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            double test;
            int    X, Y;

            //Draw a new point
            for (int I = 0; I <= 500; I++)
            {
                X = (int)((point.GetValue(0, 0) + 3) * canvas1.ActualWidth / 6);
                Y = (int)((10.5 - point.GetValue(1, 0)) * canvas1.ActualHeight / 10.5);
                SetPixel(X, Y, my_Color, PixelData, Stride);
                //Appy point transformation
                test = Rnd.NextDouble();
                if (test < P1)
                {
                    point = F1 * point + C1;
                }
                else if (test < P1 + P2)
                {
                    point = F2 * point + C2;
                }
                else if (test < P1 + P2 + P3)
                {
                    point = F3 * point + C3;
                }
                else
                {
                    point = F4 * point + C4;
                }
            }
            bitmap        = BitmapSource.Create(W, H, 96, 96, PixelFormats.Rgb24, null, PixelData, Stride);
            Image1.Source = bitmap;
        }
Ejemplo n.º 3
0
        private void MnuFileOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            StreamReader   sr;

            //Show an OpenFile dialog
            if (FilePath == "")
            {
                openFileDialog1.InitialDirectory = Environment.CurrentDirectory;
            }
            else
            {
                openFileDialog1.InitialDirectory = FilePath;
            }
            openFileDialog1.Filter           = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == true)
            {
                FilePath         = Path.GetDirectoryName(openFileDialog1.FileName);
                SettingsFileName = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
                sr = new StreamReader(openFileDialog1.FileName);
                Init();
                //Read the setting data from the file
                P1 = Double.Parse(sr.ReadLine());
                P2 = Double.Parse(sr.ReadLine());
                P3 = Double.Parse(sr.ReadLine());
                P4 = Double.Parse(sr.ReadLine());

                F1 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                F2 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                F3 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                F4 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                C1 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                C2 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                C3 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                C4 = JG_Matrix.Matrix.FromString(sr.ReadLine());
                if (settingForm != null)
                {
                    settingForm.Show();
                    settingForm.Left             = Left + Width;
                    settingForm.Top              = Top;
                    settingForm.TxtFernType.Text = SettingsFileName;
                    settingForm.P1 = P1;
                    settingForm.P2 = P2;
                    settingForm.P3 = P3;
                    settingForm.P4 = P4;
                    settingForm.F1 = F1;
                    settingForm.F2 = F2;
                    settingForm.F3 = F3;
                    settingForm.F4 = F4;
                    settingForm.C1 = C1;
                    settingForm.C2 = C2;
                    settingForm.C3 = C3;
                    settingForm.C4 = C4;
                }
            }
        }
Ejemplo n.º 4
0
 public void GetParameters()
 {
     if (settingForm != null)
     {
         P1 = settingForm.P1;
         P2 = settingForm.P2;
         P3 = settingForm.P3;
         P4 = settingForm.P4;
         F1 = settingForm.F1;
         F2 = settingForm.F2;
         F3 = settingForm.F3;
         F4 = settingForm.F4;
         C1 = settingForm.C1;
         C2 = settingForm.C2;
         C3 = settingForm.C3;
         C4 = settingForm.C4;
     }
 }