Exemplo n.º 1
0
 /// <summary>
 /// Creates a list of all points, which are used in the fractal
 /// </summary>
 private void FindDots(DrawingParameters drawingParameters, Dispatcher dispatcher)
 {
     try
     {
         SCDrawingParams scDrawingParams = (SCDrawingParams)drawingParameters;
         double          currX           = drawingParameters.CurrentCoords.X;
         double          currY           = drawingParameters.CurrentCoords.Y;
         double          side            = scDrawingParams.CurrentLength;
         Point           centerPoint     = new Point(currX, currY);
         SolidColorBrush brush           = GetCurrentColor.Get(StartColor, EndColor,
                                                               drawingParameters.RecursionLevel - 1, MaxRecursionLevel - 1);
         pointsList.Add(new PointData(side, brush, new Point(currX, currY)));
         SCDrawingParams newQCParams = new SCDrawingParams(scDrawingParams.CurrentLength / 2,
                                                           scDrawingParams.RecursionLevel + 1, new Point(0, 0));
         if (scDrawingParams.RecursionLevel < MaxRecursionLevel)
         {
             SCDrawingParams newDrawingParams = new SCDrawingParams(side / 2,
                                                                    scDrawingParams.RecursionLevel + 1,
                                                                    new Point(centerPoint.X, centerPoint.Y -
                                                                              side * Math.Sqrt(3) / 8));
             FindDots(newDrawingParams, dispatcher);
             newDrawingParams = new SCDrawingParams(side / 2,
                                                    scDrawingParams.RecursionLevel + 1,
                                                    new Point(centerPoint.X - side / 4.0, centerPoint.Y +
                                                              side * Math.Sqrt(3) / 8));
             FindDots(newDrawingParams, dispatcher);
             newDrawingParams = new SCDrawingParams(side / 2,
                                                    scDrawingParams.RecursionLevel + 1,
                                                    new Point(centerPoint.X + side / 4.0, centerPoint.Y +
                                                              side * Math.Sqrt(3) / 8));
             FindDots(newDrawingParams, dispatcher);
         }
     }
     catch (OutOfMemoryException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (StackOverflowException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (Exception ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a list of all points, which are used in the fractal
 /// </summary>
 private void FindDots(DrawingParameters drawingParameters, Dispatcher dispatcher)
 {
     try
     {
         QCDrawingParams qcDrawingParams = (QCDrawingParams)drawingParameters;
         double          currX           = drawingParameters.CurrentCoords.X - qcDrawingParams.CurrentLength;
         double          currY           = drawingParameters.CurrentCoords.Y - qcDrawingParams.CurrentLength;
         double          length          = qcDrawingParams.CurrentLength;
         SolidColorBrush brush           = GetCurrentColor.Get(StartColor, EndColor,
                                                               drawingParameters.RecursionLevel - 1, MaxRecursionLevel - 1);
         pointsList.Add(new PointData(length, brush, new Point(currX, currY)));
         QCDrawingParams newQCParams = new QCDrawingParams(qcDrawingParams.CurrentLength / 2,
                                                           qcDrawingParams.RecursionLevel + 1, new Point(0, 0), new bool[] { });
         if (drawingParameters.RecursionLevel < MaxRecursionLevel)
         {
             bool[][] newSidesDrawability = GetNewSidesDrawability(qcDrawingParams.SidesDrawability);
             for (int i = 0; i < qcDrawingParams.SidesDrawability.Length; i++)
             {
                 if (qcDrawingParams.SidesDrawability[i])
                 {
                     newQCParams.CurrentCoords = GetNewPoint(qcDrawingParams.CurrentCoords,
                                                             qcDrawingParams.CurrentLength, i);
                     newQCParams.SidesDrawability = newSidesDrawability[i];
                     FindDots(newQCParams, dispatcher);
                 }
             }
         }
     }
     catch (OutOfMemoryException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (StackOverflowException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (Exception ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Draws the first main triangle
        /// </summary>
        public void InitialDraw(DrawingParameters drawingParameters)
        {
            SCDrawingParams scDrawingParams = (SCDrawingParams)drawingParameters;

            Point[] tPointsArr = GetTrianglePoints(scDrawingParams.CurrentCoords,
                                                   scDrawingParams.CurrentLength);
            PointCollection tPointsCollection = new PointCollection(tPointsArr);
            Polyline        line = new Polyline
            {
                Points          = tPointsCollection,
                StrokeThickness = 0.3,
                Stroke          = GetCurrentColor.Get(StartColor, EndColor,
                                                      scDrawingParams.RecursionLevel, MaxRecursionLevel)
            };

            MainCanvas.Children.Add(line);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a list of all points, which are used in the fractal
 /// </summary>
 private void FindDots(DrawingParameters drawingParameters, Dispatcher dispatcher)
 {
     try
     {
         NFDrawingParams nfDrawingParams = (NFDrawingParams)drawingParameters;
         Point[]         tPointsArr      = GetFractalPoints(nfDrawingParams.CurrentCoords,
                                                            nfDrawingParams.CurrentLength);
         SolidColorBrush brush = GetCurrentColor.Get(StartColor, EndColor,
                                                     nfDrawingParams.RecursionLevel - 1, MaxRecursionLevel - 1);
         nfFractalPointsList.Add(new NFFractalPointData(tPointsArr, brush));
         if (nfDrawingParams.RecursionLevel < MaxRecursionLevel)
         {
             //define new drawing params for four new elements and find the data about them
             NFDrawingParams newDrawingParams = new NFDrawingParams(
                 nfDrawingParams.CurrentLength / 2, nfDrawingParams.RecursionLevel + 1,
                 tPointsArr[2]);
             FindDots(newDrawingParams, dispatcher);
             newDrawingParams.CurrentCoords = tPointsArr[3];
             FindDots(newDrawingParams, dispatcher);
             newDrawingParams.CurrentCoords = tPointsArr[4];
             FindDots(newDrawingParams, dispatcher);
             newDrawingParams.CurrentCoords = tPointsArr[5];
             FindDots(newDrawingParams, dispatcher);
         }
     }
     catch (OutOfMemoryException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (StackOverflowException ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
     catch (Exception ex)
     {
         dispatcher.Invoke(() => MessageBox.Show(ex.Message,
                                                 "Soft's message", MessageBoxButton.OK,
                                                 MessageBoxImage.Information));
     }
 }