Пример #1
0
        public ShapeCollection CreatePaths(PathData p, double increment)
        {
            ShapeCollection pc = new ShapeCollection();

            if (p == null || !(p is LatticeData))
            {
                return(pc);
            }
            ld = p as LatticeData;

            rowHeight = ld.Layout.Height / (ld.Rows - 1);
            colWidth  = ld.Layout.Width / (ld.Columns - 1);
            //Shape s = MkPath(0, 0, increment);
            //if (s != null)
            //    pc.AddShape(s);
            if ((ld.Layout.RepeatX == 0) && (ld.Layout.RepeatY == 0))
            {
                pc.AddShape(MkPath(0, 0, increment));
            }
            else if ((ld.Layout.RepeatX == 0) && (ld.Layout.RepeatY > 0))
            {
                for (int indy = -ld.Layout.RepeatY; indy < ld.Layout.RepeatY; indy++)
                {
                    Shape s = MkPath(0, indy, increment);
                    if (s != null)
                    {
                        pc.AddShape(s);
                    }
                }
            }
            else if ((ld.Layout.RepeatX > 0) && (ld.Layout.RepeatY == 0))
            {
                for (int indx = -ld.Layout.RepeatX; indx < ld.Layout.RepeatX; indx++)
                {
                    Shape s = MkPath(indx, 0, increment);
                    if (s != null)
                    {
                        pc.AddShape(s);
                    }
                }
            }
            else
            {
                for (int indy = -ld.Layout.RepeatY; indy < ld.Layout.RepeatY; indy++)
                {
                    for (int indx = -ld.Layout.RepeatX; indx < ld.Layout.RepeatX; indx++)
                    {
                        Shape s = MkPath(indx, indy, increment);
                        if (s != null)
                        {
                            pc.AddShape(s);
                        }
                    }
                }
            }
            return(pc);
        }
Пример #2
0
        public ShapeCollection CreatePaths(PathData p, double increment)
        {
            ShapeCollection pc = new ShapeCollection();

            if (p == null || !(p is LatticeData))
            {
                return(pc);
            }
            ld          = p as LatticeData;
            repeatAngle = 360.0 / ld.Layout.RepeatX;
            colAngle    = (repeatAngle - ld.Layout.Margin) / (ld.Columns - 1);

            rowHeight = ld.Layout.Height / (ld.Rows - 1);
            colWidth  = ld.Layout.Width / (ld.Columns - 1);
            origin    = new Point(ld.Layout.ToolPosition, 0);

            if ((ld.Layout.RepeatX == 0) && (ld.Layout.RepeatY == 0))
            {
                pc.AddShape(MkPath(0, 0, increment));
            }
            else if ((ld.Layout.RepeatX == 0) && (ld.Layout.RepeatY > 0))
            {
                for (int indy = -ld.Layout.RepeatY; indy < ld.Layout.RepeatY; indy++)
                {
                    pc.AddShape(MkPath(0, indy, increment));
                }
            }
            else if ((ld.Layout.RepeatX > 0) && (ld.Layout.RepeatY == 0))
            {
                for (int indx = -ld.Layout.RepeatX; indx < ld.Layout.RepeatX; indx++)
                {
                    pc.AddShape(MkPath(indx, 0, increment));
                }
            }
            else
            {
                for (int indy = -ld.Layout.RepeatY; indy < ld.Layout.RepeatY; indy++)
                {
                    for (int indx = -ld.Layout.RepeatX; indx < ld.Layout.RepeatX; indx++)
                    {
                        pc.AddShape(MkPath(indx, indy, increment));
                    }
                }
            }

            //for (int indx = 0; indx < ld.Layout.RepeatX; indx++)
            //{
            //    pc.AddShape(MkPath(indx,increment));
            //}
            return(pc);
        }
Пример #3
0
        public ShapeCollection Path(double inc)
        {
            ShapeCollection pc = new ShapeCollection();

            pc.AddShape(Outline(inc));
            return(pc);
        }
Пример #4
0
        public ShapeCollection CreatePaths(PathData pathdata, double inc)
        {
            ShapeCollection pc = new ShapeCollection();

            pc.PatternName = pathdata.Name;
            pc.AddShape(Path(pathdata, inc));
            return(pc);
        }
Пример #5
0
        static void Main(string[] args)
        {
            #region Text Color
            Console.ForegroundColor = ConsoleColor.Red;
            #endregion
            #region Creating Shapes
            Circle   circle   = new Circle(2);
            Triangle triangle = new Triangle(3, 4, 5);
            Square   square   = new Square(2);
            #endregion
            #region Calling Methods
            // Circle
            circle.GetArea();
            circle.GetPerimeter();
            Console.WriteLine("-------------------------------------------\n");
            // Triangle
            triangle.GetArea();
            triangle.GetPerimeter();
            Console.WriteLine("-------------------------------------------\n");
            // Square
            square.GetArea();
            square.GetPerimeter();
            Console.WriteLine("-------------------------------------------\n");
            Console.WriteLine("-------------------------------------------\n");

            ShapeCollection shapes = new ShapeCollection();
            shapes.AddShape(new Circle(2));
            shapes.AddShape(new Square(4));
            shapes.AddShape(new Triangle(3, 4, 5));
            Console.WriteLine($"There are total of {shapes.Count()} shapes\n");
            Console.WriteLine("The total area of the collection is {0}. \n", shapes.TotalArea());
            Console.WriteLine("The total perimeter of the collection is {0}. \n", shapes.TotalPerimeter());
            #endregion


            Console.WriteLine("\nPress enter to exit...");
            Console.ReadLine();
        }
Пример #6
0
        /// <summary>
        /// In this class the second parameter is the number of paths
        /// </summary>
        /// <param name="pathdata"></param>
        /// <param name="increment"></param>
        /// <returns></returns>
        public ShapeCollection CreatePaths(PathData pathdata, double increment)
        {
            ShapeCollection pc = new ShapeCollection();

            pc.PatternName = pathdata.Name;
            if (pathdata.PathType == PatternType.barrel)
            {
                Barrel           b    = pathdata as Barrel;
                RadialOffsetPath path = b.OutlineAsOffsets((int)(1 / increment));
                Polygon          poly = CreatePolygonFrom(path, b.ToolPosition);
                (poly.RenderTransform as CompositeTransform).Rotation = b.Phase;
                pc.AddShape(poly);
            }
            return(pc);
        }
Пример #7
0
        public ShapeCollection CreatePaths(PathData pathdata, double inc)
        {
            //Debug.WriteLine("BazelyEngine CreatePaths");
            ShapeCollection pc = new ShapeCollection();

            pc.PatternName = pathdata.Name;
            Polygon poly = Path(pathdata, inc);

            try
            {
                pc.AddShape(poly);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            //Debug.WriteLine("End BazelyEngine CreatePaths");
            return(pc);
        }
Пример #8
0
        public ShapeCollection CreatePaths(PathData pd, double increment)
        {
            bd = pd as BraidData;
            ShapeCollection pc = new ShapeCollection();

            pc.PatternName = pd.Name;
            repeatAngle    = 2 * Math.PI / bd.Repeats;
            colAngle       = (repeatAngle - rad * bd.Margin) / bd.Perms.Count;

            rowHeight = bd.Width / (bd.NumStrands - 1);
            colWidth  = bd.Length / bd.Perms.Count;
            origin    = new Point(bd.ToolPosition, 0);

            for (int indx = 0; indx < bd.Repeats; indx++)
            {
                pc.AddShape(MkPath(indx, increment));
            }
            return(pc);
        }
        static void Main(string[] args)
        {
            //Circle krug = new Circle(3);

            //double fside = 3;
            //double sside = 4;
            //double tside = 5;

            //if (Triangle.IsValidTriangle(fside, sside, tside))
            //{
            //    Triangle triangle = new Triangle(fside, sside, tside);
            //    Console.WriteLine(triangle.GetArea());
            //}
            //else
            //{
            //    Console.WriteLine("That is not valid");
            //}

            //double side = -2;
            //if (Square.IsValid(side))
            //{
            //    Square square = new Square(side);
            //    Console.WriteLine(square.GetArea());
            //}
            //else
            //{
            //    Console.WriteLine("That is not valid");
            //}


            ShapeCollection shapes = new ShapeCollection();

            shapes.AddShape(new Circle(10));
            shapes.AddShape(new Triangle(3, 4, 5));
            shapes.AddShape(new Triangle(3, 10, 12));
            shapes.AddShape(new Square(10));

            Console.WriteLine($"There are {shapes.Count()} shapes");
            Console.WriteLine($"Total area is {shapes.TotalArea()} ");
            Console.WriteLine($"Total perimeter is {shapes.TotalPerimeter()} ");

            Console.WriteLine($"Average area is {shapes.GetAverageArea()} ");
            Console.WriteLine($"Average area is {Helper.GetAverageArea(shapes)} ");

            Console.WriteLine(Helper.IsEven(2));
            Console.WriteLine(Helper.IsEven(3));

            Console.WriteLine(2.IsEven());
            Console.WriteLine(3.IsEven());

            var x = 10;

            Console.WriteLine(Helper.AddOne(Helper.Double(Helper.Square(x))));
            Console.WriteLine(x.Square().Double().AddOne());

            Triangle t = new Triangle(3, 7, 9);

            // these two are completely the same
            Console.WriteLine(IShapeHelper.GetRatio(t));
            Console.WriteLine(t.GetRatio());

            // these two are completely the same
            Console.WriteLine(IShapeHelper.GetMultipliedArea(t, 3));
            Console.WriteLine(t.GetMultipliedArea(3));
        }