Example #1
0
        public void PointsToLines()
        {
            var polygon = ShapeMaker.U(Vector3.Origin, new Vector3(40.0, 40.0), 10.0);
            var points  = polygon.Vertices;

            Assert.Equal(8.0, Shaper.PointsToLines(points.ToList(), true).Count);
        }
        static void Main(string[] args)
        {
            ShapeMaker shapeMaker = new ShapeMaker();

            shapeMaker.DrawCircle();
            shapeMaker.DrawRectangle();
            shapeMaker.DrawSquare();
        }
Example #3
0
    public void Main()
    {
        ShapeMaker shapeMaker = new ShapeMaker();

        shapeMaker.DrawCircle();
        shapeMaker.DrawRectangle();
        shapeMaker.DrawSquare();
    }
        public static void Test()
        {
            var shapeMaker = new ShapeMaker();

            shapeMaker.DrawCircle();
            shapeMaker.DrawRectangle();
            shapeMaker.DrawSquare();
        }
Example #5
0
        private static void Facade()
        {
            ShapeMaker shapeMaker = new ShapeMaker();

            shapeMaker.drawCircle();
            shapeMaker.drawRectangle();
            shapeMaker.drawSquare();
        }
Example #6
0
        static void Facade()
        {
            var shapeMaker = new ShapeMaker();

            shapeMaker.DrawCircle();
            shapeMaker.DrawRectangle();
            shapeMaker.DrawSquare();
        }
Example #7
0
        static void Main()
        {
            ShapeMaker shapeMaker = new ShapeMaker();

            shapeMaker.DrawTriangle();
            shapeMaker.DrawRectangle();
            shapeMaker.DrawSquare();
        }
        public static void Run()
        {
            ShapeMaker sm = new ShapeMaker();

            sm.DrawCircle();
            sm.DrawRectangle();
            sm.DrawSquare();
        }
Example #9
0
        public void Ribs()
        {
            var ribs = ShapeMaker.L(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Ribs();

            Assert.Equal(6, ribs.Count);
            ribs = ShapeMaker.C(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Ribs();
            Assert.Equal(8, ribs.Count);
            ribs = ShapeMaker.X(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Ribs();
            Assert.Equal(12, ribs.Count);
        }
Example #10
0
        private void btFacadePattern_Click(object sender, EventArgs e)
        {
            string     str        = "";
            ShapeMaker shapeMaker = new ShapeMaker();

            str += shapeMaker.drawCircle() + "\r\n";
            str += shapeMaker.drawRectangle() + "\r\n";
            str += shapeMaker.drawSquare() + "\r\n";
            tbOutWindow.Text = str;
        }
Example #11
0
 public static void Run()
 {
     Console.WriteLine("<Private Class Data Pattern Example>");
     Console.WriteLine();
     ShapeMaker.GetShape(ShapeType.Circle).Draw();
     ShapeMaker.GetShape(ShapeType.Rectangle).Draw();
     Console.WriteLine();
     Console.WriteLine("</Private Class Data Pattern Example>");
     Console.WriteLine();
 }
Example #12
0
        public void Skeleton()
        {
            var skeleton = ShapeMaker.L(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Skeleton();

            Assert.Equal(8, skeleton.Count);
            skeleton = ShapeMaker.C(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Skeleton();
            Assert.Equal(11, skeleton.Count);
            skeleton = ShapeMaker.X(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Skeleton();
            Assert.Equal(16, skeleton.Count);
        }
Example #13
0
        public void L()
        {
            var polygon  = ShapeMaker.L(Vector3.Origin, new Vector3(3.0, 5.0), 1.0);
            var vertices = polygon.Vertices;

            Assert.Contains(vertices, p => p.X == 0.0 && p.Y == 0.0);
            Assert.Contains(vertices, p => p.X == 3.0 && p.Y == 0.0);
            Assert.Contains(vertices, p => p.X == 3.0 && p.Y == 1.0);
            Assert.Contains(vertices, p => p.X == 1.0 && p.Y == 1.0);
            Assert.Contains(vertices, p => p.X == 1.0 && p.Y == 5.0);
            Assert.Contains(vertices, p => p.X == 0.0 && p.Y == 5.0);
        }
Example #14
0
        public void test_shape_draw()
        {
            ShapeMaker shapeMaker = new ShapeMaker();

            shapeMaker.DrawCircle();
            shapeMaker.DrawSquare();
            shapeMaker.DrawRectangle();

            Assert.That(shapeMaker.IsCircleDrawn() == true);
            Assert.That(shapeMaker.IsSquareDrawn() == true);
            Assert.That(shapeMaker.IsRectangleDrawn() == true);
        }
Example #15
0
        public void C()
        {
            var polygon  = ShapeMaker.C(new Vector3(2.0, 2.0), new Vector3(3.0, 5.0), 1.0);
            var vertices = polygon.Vertices;

            Assert.Contains(vertices, p => p.X == 2.0 && p.Y == 2.0);
            Assert.Contains(vertices, p => p.X == 5.0 && p.Y == 2.0);
            Assert.Contains(vertices, p => p.X == 5.0 && p.Y == 3.0);
            Assert.Contains(vertices, p => p.X == 3.0 && p.Y == 3.0);
            Assert.Contains(vertices, p => p.X == 3.0 && p.Y == 6.0);
            Assert.Contains(vertices, p => p.X == 5.0 && p.Y == 6.0);
            Assert.Contains(vertices, p => p.X == 5.0 && p.Y == 7.0);
            Assert.Contains(vertices, p => p.X == 2.0 && p.Y == 7.0);
        }
Example #16
0
        public void FacadeTest()
        {
            // Arrange
            IShapeMaker shapeMaker = new ShapeMaker();

            // Act
            Facade.IShape circle   = shapeMaker.CreateCircle();
            Facade.IShape square   = shapeMaker.CreateSquare();
            Facade.IShape triangle = shapeMaker.CreateTriangle();

            // Assert
            Assert.IsInstanceOfType(circle, typeof(Facade.Shapes.Circle));
            Assert.IsInstanceOfType(square, typeof(Facade.Shapes.Square));
            Assert.IsInstanceOfType(triangle, typeof(Facade.Shapes.Triangle));
        }
Example #17
0
        public static void Run()
        {
            var shapeMaker = new ShapeMaker();

            Console.WriteLine("<Facade Pattern Example>");
            Console.WriteLine();
            Console.Write("\t");
            shapeMaker.DrawCircle();
            Console.Write("\t");
            shapeMaker.DrawRectangle();
            Console.Write("\t");
            shapeMaker.DrawSquare();
            Console.WriteLine();
            Console.WriteLine("</Facade Pattern Example>");
            Console.WriteLine();
        }
Example #18
0
        public void Jigsaw()
        {
            var jigsaw = ShapeMaker.L(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Jigsaw();

            Assert.Equal(6, jigsaw.Count);
            jigsaw = ShapeMaker.C(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Jigsaw();
            Assert.Equal(8, jigsaw.Count);
            jigsaw = ShapeMaker.X(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Jigsaw();
            Assert.Equal(12, jigsaw.Count);
            var model = new Model();

            foreach (var polygon in jigsaw)
            {
                model.AddElement(new Space(polygon, 4.0, new Material(Palette.Aqua, 0.0f, 0.0f, false, null, false, Guid.NewGuid(), "room")));
            }
            model.ToGlTF("../../../../GeometryExTests/output/polygon.Jigsaw.glb");
        }
Example #19
0
	// Use this for initialization
	void Start () 
	{
		//Intitalize Components.
		m_gameBoard = (GameBoard)(GameObject.Find("o_GameBoard")).GetComponent(typeof(GameBoard));
		m_shapeMaker = (ShapeMaker)(GameObject.Find("o_ShapeMaker")).GetComponent(typeof(ShapeMaker));
		m_playerInput = (PlayerInput)(GameObject.Find("o_PlayerInput")).GetComponent(typeof(PlayerInput));
		m_GameOver = (GameOver)(GameObject.Find("img_GameOver")).GetComponent(typeof(GameOver));

		m_width = 12;
		m_height = 24;
		gameOver = false;
		lastPlayerInput = 0;

		//Init functions
		Debug.Log("Intit 1");
		m_gameBoard.initGameBoard(m_width, m_height);
		Debug.Log("Intit 2");
		m_shapeMaker.initShapeMaker(m_gameBoard);
		Debug.Log("Intit 3");
	} //end start
Example #20
0
        public void FitWithin()
        {
            var within   = ShapeMaker.U(Vector3.Origin, new Vector3(40.0, 40.0), 10.0);
            var fit      = Polygon.Rectangle(new Vector3(-10.0, 20.0), new Vector3(50.0, 30.0));
            var polygons = Shaper.FitWithin(fit, within);

            Assert.Equal(2, polygons.Count);

            var vertices = polygons.First().Vertices.ToList();

            vertices.AddRange(polygons.Last().Vertices);

            Assert.Contains(vertices, p => p.X == 0.0 && p.Y == 20.0);
            Assert.Contains(vertices, p => p.X == 0.0 && p.Y == 30.0);
            Assert.Contains(vertices, p => p.X == 10.0 && p.Y == 20.0);
            Assert.Contains(vertices, p => p.X == 10.0 && p.Y == 30.0);
            Assert.Contains(vertices, p => p.X == 30.0 && p.Y == 20.0);
            Assert.Contains(vertices, p => p.X == 30.0 && p.Y == 30.0);
            Assert.Contains(vertices, p => p.X == 40.0 && p.Y == 20.0);
            Assert.Contains(vertices, p => p.X == 40.0 && p.Y == 30.0);
        }
Example #21
0
        public void Spine()
        {
            var spine = ShapeMaker.L(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Spine();

            Assert.Equal(2, spine.Count);
            spine = ShapeMaker.C(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Spine();
            Assert.Equal(3, spine.Count);
            spine = ShapeMaker.X(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).Spine();
            Assert.Equal(4, spine.Count);
            var model     = new Model();
            var corridors = new List <Polygon>();

            foreach (var line in spine)
            {
                corridors.Add(new Polyline(new[] { line.Start, line.End }).Offset(1.0, EndType.Square).First());
            }
            corridors = Shaper.Merge(corridors);
            foreach (var corridor in corridors)
            {
                model.AddElement(new Space(corridor, 4.0, new Material(Palette.Aqua, 0.0f, 0.0f, false, null, false, Guid.NewGuid(), "corridor")));
            }
            model.ToGlTF("../../../../GeometryExTests/output/polygon.Spine.glb");
        }
Example #22
0
        public void ToMesh()
        {
            var mesh = ShapeMaker.C(Vector3.Origin, new Vector3(100.0, 100.0), 25.0).ToMesh();

            Assert.Equal(6, mesh.Triangles.Count);
        }
Example #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("Singleton Pattern");

            // Singleton Pattern
            SingleObject singleObject = SingleObject.Instance();

            singleObject.ShowMessage();

            Console.WriteLine("\nBuilder Pattern");

            // Builder Pattern
            MealBuilder mealBuilder = new MealBuilder();

            Meal vegMeal = mealBuilder.PrepareVegMeal();

            Console.WriteLine("Veg Meal");
            vegMeal.ShowItems();
            Console.WriteLine("Total Cost : " + vegMeal.GetCost());

            Meal nonVegMeal = mealBuilder.PrepareNonVegMeal();

            Console.WriteLine("NonVeg Meal");
            nonVegMeal.ShowItems();
            Console.WriteLine("Total Cost : " + nonVegMeal.GetCost());

            Console.WriteLine("\nAbstract Factory");

            // Abstract Factory Pattern
            AbstractFactory shapeFactory = FactoryProducer.GetFactory("shape");
            IShape          circleShape  = shapeFactory.GetShape("circle");

            circleShape.Draw();

            AbstractFactory colorFactory = FactoryProducer.GetFactory("color");
            IColor          blueColor    = colorFactory.GetColor("blue");

            blueColor.Fill();

            Console.WriteLine("\nAdapter");

            //Adapter Pattern
            AudioPlayer audioPlayer = new AudioPlayer();

            audioPlayer.Play("mp4");
            audioPlayer.Play("flac");
            audioPlayer.Play("vlc");

            Console.WriteLine("\nFacade");

            //Facade Pattern
            ShapeMaker shapeMaker = new ShapeMaker();

            shapeMaker.DrawCircle();
            shapeMaker.DrawRectangle();
            shapeMaker.DrawSquare();

            Console.WriteLine("\nDecorator doesn't work");

            //Decorator Pattern
            IDecoratorShape rectangle    = new RectangleDecorator();
            IDecoratorShape redRectangle = new RedShapeDecorator(new RectangleDecorator());

            Console.WriteLine("Rectangle with no color");
            rectangle.Draw();
            Console.WriteLine("Rectangle with color");
            redRectangle.Draw();

            Console.WriteLine("\nComposite");

            //Composite Pattern
            Employee DSI           = new Employee("employee1", "DSI", 100000);
            Employee chefDeProjet1 = new Employee("employee2", "Chef de projet", 60000);
            Employee chefDeProjet2 = new Employee("employee3", "Chef de projet", 60000);
            Employee dev1          = new Employee("employee4", "Développeur", 40000);
            Employee dev2          = new Employee("employee5", "Développeur", 40000);

            DSI.Add(chefDeProjet1);
            DSI.Add(chefDeProjet2);
            chefDeProjet1.Add(dev1);
            chefDeProjet2.Add(dev2);

            Console.WriteLine(DSI.Details());
            foreach (Employee e1 in DSI.GetSubordinates())
            {
                Console.WriteLine(e1.Details());
                foreach (Employee e2 in e1.GetSubordinates())
                {
                    Console.WriteLine(e2.Details());
                }
            }

            Console.WriteLine("\nBridge");

            //Bridge Pattern
            BridgeShape shape1 = new BridgeCircle(10, 10, 1, new GreenCircle());
            BridgeShape shape2 = new BridgeCircle(100, 100, 10, new RedCircle());

            shape1.Draw();
            shape2.Draw();

            Console.WriteLine("\nCommand");

            //Command Pattern
            Stock    stock1   = new Stock("laptop", 100);
            BuyStock buyStock = new BuyStock(stock1);

            Stock     stock2    = new Stock("screen", 30);
            SellStock sellStock = new SellStock(stock2);

            Broker broker = new Broker();

            broker.TakeOrder(buyStock);
            broker.TakeOrder(sellStock);
            broker.PlaceOrders();

            Console.WriteLine("\nInterpreter");

            //Interpreter Pattern
            IExpression isMale    = InterpreterPatternDemo.GetMaleExpression();
            IExpression isMarried = InterpreterPatternDemo.GetMarriedWomanExpression();

            Console.WriteLine("John is male ? " + isMale.Interpret("john"));
            Console.WriteLine("Barbara is male ? " + isMale.Interpret("barbara"));

            Console.WriteLine("Julie is married ? " + isMarried.Interpret("julie married"));
            Console.WriteLine("Bob is married ? " + isMarried.Interpret("bob married"));
        }