Beispiel #1
0
        public void TestDraw()
        {
            ShapeFactory sf = new ShapeFactory();

            Shapes.Rectangle myRectangle = sf.MakeRectangle(1, 2, 5, 6);
            Bitmap           bitmap      = new Bitmap(1024, 1024, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics         g           = Graphics.FromImage(bitmap);

            myRectangle.Draw(g);
            bitmap.Save("rectangle.bmp");
        }
Beispiel #2
0
 private void DrawSquare()
 {
     using (Pen pen = new Pen(Color.Black))
     {
         rect.Rotate(1);
         rect.Move((float)(moveKx * xStep), (float)(moveKy * Math.Abs(kPerp) * xStep));
         if (line.Contains(rect.P1) || line.Contains(rect.P2) || line.Contains(rect.P3) || line.Contains(rect.P4))
         {
             t?.Dispose();
         }
         alpha = (alpha + 1) % 360;
         rect?.Draw(graphics, pen);
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();

                if (input == "c")
                {
                    Shape circle = new Circle(5);
                    Console.WriteLine(circle.CalculateArea());
                    Console.WriteLine(circle.CalculatePerimeter());
                    Console.WriteLine(circle.Draw());
                }

                else if (input == "r")
                {
                    Shape rec = new Rectangle(4, 60);
                    Console.WriteLine(rec.CalculateArea());
                    Console.WriteLine(rec.CalculatePerimeter());
                    Console.WriteLine(rec.Draw());
                }
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            //Set Points
            var A = new Point(0, 0);
            var B = new Point(3, 4);
            var C = new Point(1.5, 5);
            var D = new Point(1, 2);

            //Distance between points
            var ab = new Distance(A, B);
            var bc = new Distance(B, C);
            var cd = new Distance(C, D);
            var da = new Distance(D, A);

            //Unit explanation
            UnitExplanation.Units();

            //Triangle test
            //var iso = TriangleType.Isosceles;
            //var rect = TriangleType.Rectangular;
            //var obt = TriangleType.Obtuse;
            //var equi = TriangleType.Echilateral;
            var t1 = new TriangleWithSides(A, B, C);
            var t2 = new TriangleWithSides(3, 4, 5);
            var t3 = new TriangleWithSides(1.5, 3.7, 5);
            var t4 = new TriangleWithAngle(3, 3, 45);
            var t5 = new TriangleWithAngle(A, B, C);
            var t6 = new TriangleWithAngle(3, 4, 90);

            t1.Draw();
            t1.DisplayShape();
            t2.DisplayShape();
            t3.DisplayShape();
            t4.DisplayShape();
            t5.DisplayShape();
            t6.DisplayShape();

            //Circle Test
            var circle1 = new Circle(A, B);
            var circle2 = new Circle(3);

            circle1.Draw();
            circle1.DisplayShape();
            circle2.DisplayShape();

            //Rectangle test
            var rect1 = new Rectangle(A, B, D);
            var rect2 = new Rectangle(3, 4);

            rect1.Draw();
            rect1.DisplayShape();
            rect2.DisplayShape();

            //Square test
            var sq1 = new Square(4);
            var sq2 = new Square(A, B);

            sq1.Draw();
            sq1.DisplayShape();
            sq2.DisplayShape();

            //Cylinder test
            var cyl1 = new Cylinder(A, B, C);
            var cyl2 = new Cylinder(3, 5);

            cyl1.Draw();
            cyl1.DisplayShape();
            cyl2.DisplayShape();

            //Sphere test
            var sphere1 = new Sphere(A, B);
            var sphere2 = new Sphere(7.5);

            sphere1.Draw();
            sphere1.DisplayShape();
            sphere2.DisplayShape();

            //Hemisphere test
            var hs1 = new Hemisphere(B, D);
            var hs2 = new Hemisphere(3.7);

            hs1.Draw();
            hs1.DisplayShape();
            hs2.DisplayShape();

            //Cone test
            var cone1 = new Cones(A, B, C);
            var cone2 = new Cones(2.5, 4, 5);

            cone1.Draw();
            cone1.DisplayShape();
            cone2.DisplayShape();

            //Cuboid test
            var cub1 = new Cuboid(5.0, 6.0, 7.0);
            var cub2 = new Cuboid(A, B, C, D);

            cub1.Draw();
            cub1.DisplayShape();
            cub2.DisplayShape();

            //Testing Cube
            var cube1 = new Cube(5);
            var cube2 = new Cube(A, B);

            cube1.Draw();
            cube1.DisplayShape();
            cube2.DisplayShape();
            Display();
            var shapes = new List <Shape>();

            shapes.Add(cub1);
            shapes.Add(cone1);
            shapes.Add(t1);
            shapes.Add(rect1);
            foreach (var item in shapes)
            {
                item.Draw();
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Shape shape  = new Rectangle(3.5, 12);
            Shape shape1 = new Circle(1);

            Console.WriteLine($"Perimeter = {shape.CalculatePerimeter():f2}; \nArea = {shape.CalculateArea():f2}; \n{shape.Draw()}");
            Console.WriteLine($"Perimeter = {shape1.CalculatePerimeter():f2}; \nArea = {shape1.CalculateArea():f2}; \n{shape1.Draw()}");
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            IDrawable shape = new Rectangle(10, 5);

            shape.Draw();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Shape rectangle = new Rectangle(5, 6);

            Console.WriteLine(rectangle.Draw());
        }