Exemple #1
0
        private void GenerateLineFractal(double size, TypeFractalPrimitive type, Point startPoint, double startAngleRad, int deep)
        {
            Point endPoint = new Point(startPoint.X + size * Math.Cos(startAngleRad), startPoint.Y + size * Math.Sin(startAngleRad));

            //    Line newLine = new Line()
            //    {
            //        X1 = startPoint.X,
            //        Y1 = startPoint.Y,
            //        X2 = endPoint.X,
            //        Y2 = endPoint.Y,
            //        StrokeThickness = 2,
            //    //    Stroke=Brushes.Red
            //        Stroke = new LinearGradientBrush(Color.FromArgb((byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255)),
            //        Color.FromArgb((byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255)),0.0)
            //    };

            currentPath += " M " + (int)startPoint.X + "," + (int)startPoint.Y + " L " + (int)endPoint.X + "," + (int)endPoint.Y;

            //Console.WriteLine("New Line(angle):" +startAngle);
            //Console.WriteLine("x1:" + newLine.X1);
            //Console.WriteLine("y1:" + newLine.Y1);
            //Console.WriteLine("x2:" + newLine.X2);
            //Console.WriteLine("y2:" + newLine.Y2);


            //    mainCanvas.Children.Add(newLine);

            TypeFractalPrimitive nextType = typeList[deep - 1];

            GenerateFractalSnow(size, nextType, endPoint, startAngleRad, --deep);
        }
Exemple #2
0
        private void GenerateArcFractal(double size, TypeFractalPrimitive type, Point startPoint, double startAngleRad, int deep)
        {
            Point endPoint = new Point(startPoint.X + size * Math.Cos(startAngleRad), startPoint.Y + size * Math.Sin(startAngleRad));

            //Data = "M150,100 A100,100 0 0 0 50,50"
            currentPath += " M " + (int)startPoint.X + "," + (int)startPoint.Y + " A " + (int)size + "," + (int)size + " 0 0 0 " + (int)endPoint.X + "," + (int)endPoint.Y;


            //Path arc_path = DrawArc(startPoint, size, startAngle,startAngle+size);

            TypeFractalPrimitive nextType = typeList[deep - 1];

            GenerateFractalSnow(size, nextType, endPoint, startAngleRad, --deep);
        }
Exemple #3
0
        private void GenerateCircleFractal(double size, TypeFractalPrimitive type, Point startPoint, double startAngleRad, int deep)
        {
            Point endPoint = new Point(startPoint.X + size * Math.Cos(startAngleRad), startPoint.Y + size * Math.Sin(startAngleRad));

            //Data = "M150,100 A100,100 0 0 0 50,50"
            string Data = " M " + (int)endPoint.X + "," + (int)endPoint.Y
                          + " A " + (int)size + "," + (int)size + " 0 1 0 " + (int)startPoint.X + "," + (int)startPoint.Y;

            currentPath += Data;


            //mainCanvas.Children.Add(new Path() { Data = Geometry.Parse(Data),Stroke=Brushes.Red,StrokeThickness=2 });

            //Path arc_path = DrawArc(startPoint, size, startAngle,startAngle+size);

            TypeFractalPrimitive nextType = typeList[deep - 1];

            GenerateFractalSnow(size, nextType, endPoint, startAngleRad, --deep);
        }
Exemple #4
0
        private void GenerateFractalSnow(double size, TypeFractalPrimitive type, Point startPoint, double startAngleRad, int deep)
        {
            if (size < 5 || deep <= 0)
            {
                return;
            }

            double offsetAngle = offsetAngleList[deep - 1];
            int    count       = (int)((360.0 - cutAngleGrad) / offsetAngle);

            offsetAngle  = (360.0 - cutAngleGrad) / count;
            offsetAngle *= (2 * Math.PI / 360);

            double angleRad = startAngleRad + (cutAngleGrad / 2 - 180) * (2 * Math.PI / 360);

            while (count-- > 0)
            {
                switch (type)
                {
                case TypeFractalPrimitive.Circle:
                    GenerateCircleFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Rectangle:
                    GenerateRectangleFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Line:
                    GenerateLineFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Arc:
                    GenerateArcFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;
                }
                angleRad += offsetAngle;
            }
        }
Exemple #5
0
        private void GenerateFractalSnowFirst(double size, TypeFractalPrimitive type, Point startPoint, double startAngleGrad, int deep)
        {
            currentPath = "M " + startPoint.X + "," + startPoint.Y;

            //определим параметры будущей фигуры(фрактала)
            offsetAngleList.Clear();
            typeList.Clear();
            while (offsetAngleList.Count < deep)
            {
                offsetAngleList.Add(rand.Next(30, 90));
                typeList.Add(RandomEnumValue <TypeFractalPrimitive>());
            }

            if (flag_set_TypePrimitive)
            {
                typeList.Clear();
                typeList.Add((TypeFractalPrimitive)CurrentStatus5.Value);
                typeList.Add((TypeFractalPrimitive)CurrentStatus4.Value);
                typeList.Add((TypeFractalPrimitive)CurrentStatus3.Value);
                typeList.Add((TypeFractalPrimitive)CurrentStatus2.Value);
                typeList.Add((TypeFractalPrimitive)CurrentStatus1.Value);
            }

            if (size < 5 || deep <= 0)
            {
                return;
            }

            double offsetAngle = offsetAngleList[deep - 1];

            int count = (int)(360.0 / offsetAngle);

            offsetAngle  = 360.0 / count;
            offsetAngle *= (2 * Math.PI / 360);//переводим в радианы

            double angleRad = startAngleGrad;

            angleRad *= (2 * Math.PI / 360);//переводим в радианы

            while (count-- > 0)
            {
                switch (typeList[deep - 1])
                {
                case TypeFractalPrimitive.Circle:
                    GenerateCircleFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Rectangle:
                    GenerateRectangleFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Line:
                    GenerateLineFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;

                case TypeFractalPrimitive.Arc:
                    GenerateArcFractal(size * 2 / 3, type, startPoint, angleRad, deep);
                    break;
                }
                angleRad += offsetAngle;
            }
        }