コード例 #1
0
        public static void Main(string[] args)
        {
            IDrawShapes api01 = new DrawShapes(new DrawAPI01());

            api01.CallCircle();
            api01.CallRectangle();

            IDrawShapes api02 = new DrawShapes(new DrawAPI02());

            api02.CallCircle();
            api02.CallRectangle();
        }
コード例 #2
0
 public static DrawRecord Make(DrawShapes type)
 {
     return(new DrawRecord {
         Shape = type
     });
 }
コード例 #3
0
        /// <summary>Demo the shapes package</summary>
        static void ShapesDemo()
        {
            //Let's draw a box.

            //good lord why did we have to call a WindowElement Icon. Now we have an ambiguity with System.Drawing.

            ConsoleColor C = ConsoleColor.Red;
            ConsoleColor W = ConsoleColor.White;
            ConsoleColor G = ConsoleColor.Green;
            ConsoleColor Y = ConsoleColor.Yellow;
            ConsoleColor B = ConsoleColor.Blue;

            System.Drawing.Rectangle R  = new System.Drawing.Rectangle(4, 1, 30, 5);
            System.Drawing.Point[]   Ps =
            {
                new System.Drawing.Point(30, 10),
                new System.Drawing.Point(30, 20),
                new System.Drawing.Point(10, 15)
            };

            System.Drawing.Point[] Cube1 =
            {
                new System.Drawing.Point(45,  4),
                new System.Drawing.Point(65,  4),
                new System.Drawing.Point(65, 14),
                new System.Drawing.Point(45, 14),
            };

            int CA = 7;

            System.Drawing.Point[] Cube2 =
            {
                new System.Drawing.Point(45 - CA,  4 + CA),
                new System.Drawing.Point(65 - CA,  4 + CA),
                new System.Drawing.Point(65 - CA, 14 + CA),
                new System.Drawing.Point(45 - CA, 14 + CA),
            };

            System.Drawing.Point[] Cube3 =
            {
                new System.Drawing.Point(65,            4),
                new System.Drawing.Point(65,           14),
                new System.Drawing.Point(65 - CA, 14 + CA),
                new System.Drawing.Point(65 - CA,  4 + CA),
            };

            System.Drawing.Point[] Cube4 =
            {
                new System.Drawing.Point(45,           4),
                new System.Drawing.Point(65,           4),
                new System.Drawing.Point(65 - CA, 4 + CA),
                new System.Drawing.Point(45 - CA, 4 + CA),
            };

            System.Drawing.Point[] Cube5 =
            {
                new System.Drawing.Point(45,            4),
                new System.Drawing.Point(45,           14),
                new System.Drawing.Point(45 - CA, 14 + CA),
                new System.Drawing.Point(45 - CA,  4 + CA),
            };

            DrawShapes.DrawLine(2, 2, 8, 20, C);
            DrawShapes.DrawLine(20, 2, 2, 20, W);
            DrawShapes.DrawLine(2, 2, 60, 20, G);
            DrawShapes.DrawRectangle(R, Y);
            DrawShapes.DrawPolygon(Ps, B);

            //We're gonna draw two squares
            DrawShapes.DrawPolygon(Cube1, W);
            DrawShapes.DrawPolygon(Cube2, W);
            DrawShapes.DrawPolygon(Cube3, W);
            DrawShapes.DrawPolygon(Cube4, W);
            DrawShapes.DrawPolygon(Cube5, W);

            DrawShapes.FillPolygon(Cube4, ConsoleColor.Gray);
            DrawShapes.FillPolygon(Cube3, ConsoleColor.DarkGray);
            DrawShapes.FillPolygon(Cube2, ConsoleColor.White);

            DrawShapes.FillPolygon(Ps, B);

            Curve C1 = new Curve(new System.Drawing.Point(20, 13), 10, 0, 180);
            Curve C2 = new Curve(new System.Drawing.Point(20, 13), 10, 180, 360);

            DrawShapes.DrawCurve(C1, ConsoleColor.Cyan);
            DrawShapes.DrawCurve(C2, ConsoleColor.Cyan);

            //now turn it into a polygon
            Line[] CircleCurves = { C1, C2 };

            Polygon Circle = new Polygon(CircleCurves);

            DrawShapes.FillPolygon(Circle, ConsoleColor.Cyan);

            RenderUtils.Pause();
        }