Beispiel #1
0
 public Circle(int radius, int x, int y, IDrawAPI drawAPI)
 {
     base.drawAPI = drawAPI;
     this.radius  = radius;
     this.x       = x;
     this.y       = y;
 }
Beispiel #2
0
 public Circle(int x, int y, int radius, IDrawAPI drawAPI)
     : base(drawAPI)
 {
     _x      = x;
     _y      = y;
     _radius = radius;
 }
Beispiel #3
0
 public Circle(int x, int y, int radius, IDrawAPI drawApi) : base(drawApi)
 {
     base._drawAPI = drawApi;
     this._X       = x;
     this._Y       = y;
     this._radius  = radius;
 }
Beispiel #4
0
 public override void Draw(IDrawAPI drawAPI)
 {
     if (drawAPI is VertexBatch v)
     {
         if (paddingBorderInfo == null)
         {
             paddingBorderInfo = Border.GetPaddingBorderDrawInfo(v.primitiveType, position, width, height, roundCorner, paddingColor, quality);
         }
         if (borderColor != default && borderInfo == null)
         {
             borderInfo = Border.GetBorderDrawInfo(PrimitiveType.LineStrip, position, width, height, roundCorner, borderColor, quality);
             borderInfo.primitiveType = PrimitiveType.LineStrip;
         }
         if (shadowColor != default)
         {
             for (int i = 0; i < 6 / shadowDepth; i++)
             {
                 v.Draw(paddingBorderInfo.Transform(delegate(int z, Vertex v)
                 {
                     return(new Vertex(v.Position.XY() + new Vector2(0, i * 2), shadowColor * 0.05f));
                 }));
             }
         }
         v.Draw(paddingBorderInfo);
         font?.DrawString(v, text, position + new Vector2(width, height) / 2, textColor, CenterType.MiddleCenter, textScale);
         if (highLightTimer != 0)
         {
             v.Draw(paddingBorderInfo.Transform(delegate(int z, Vertex v)
             {
                 return(new Vertex(v.Position, highLightColor * 0.2f * highLightTimer));
             }));
         }
         if (rippleTimer > 0)
         {
             Ripple.DrawRound(v, (int)Helper.Lerp(2 * width + height, 0, 3 + rippleTimer * 0.75f, 4), position, ripplePos, width, height, Color.Transparent.LerpTo(rippleColor, rippleTimer, 1), roundCorner, 1, quality * 3);
         }
         rippleTimer *= 0.95f;
         if (rippleTimer < 0.01f)
         {
             rippleTimer = 0;
         }
         if (borderInfo != null)
         {
             v.Draw(borderInfo);
         }
     }
 }
        static void Main()
        {
            Form form = new Form();

            form.Width  = 800;
            form.Height = 600;
            DrawingBoard.Init(form);
            form.Show();
            //DrawingBoard.Draw();

            //Использование абстрактной фабрики
            IFigureFactory figureFactory = LoadFactory();

            for (int i = 0; i < 20; i++)
            {
                IDrawAPI circle = figureFactory.GetFigure("CircleFigure");
                circle.DrawAt(random.Next(0, DrawingBoard.Width - MAXWIDTHOFFSET), random.Next(TEXTOFFSET, DrawingBoard.Height - MAXHEIGTHOFFSET));
            }

            for (int i = 0; i < 20; i++)
            {
                IDrawAPI circle = figureFactory.GetFigure("SquareFigure");
                circle.DrawAt(random.Next(0, DrawingBoard.Width - MAXWIDTHOFFSET), random.Next(TEXTOFFSET, DrawingBoard.Height - MAXHEIGTHOFFSET));
            }

            for (int i = 0; i < 20; i++)
            {
                IDrawAPI circle = figureFactory.GetFigure("RectangleFigure");
                circle.DrawAt(random.Next(0, DrawingBoard.Width - MAXWIDTHOFFSET), random.Next(TEXTOFFSET, DrawingBoard.Height - MAXHEIGTHOFFSET));
            }

            DrawingBoard.Buffer.Graphics.DrawString($"Circle instances:{CircleFigure.ObjectCounter}" +
                                                    $"\nSquare instances:{SquareFigure.ObjectCounter}" +
                                                    $"\nRectangle instances:{RectangleFigure.ObjectCounter}",
                                                    SystemFonts.DefaultFont,
                                                    Brushes.White,
                                                    0, 0);
            DrawingBoard.Draw();
            Application.Run(form);
        }
Beispiel #6
0
 protected Shape(IDrawAPI api)
 {
     this.dap = api;
 }
 public BridgeCircle(int x, int y, int radius, IDrawAPI drawAPI) : base(drawAPI)
 {
     this.x      = x;
     this.y      = y;
     this.radius = radius;
 }
Beispiel #8
0
 protected Shape(IDrawAPI draw)
 {
     drawAPI = draw;
 }
Beispiel #9
0
 protected Shape(IDrawAPI draw)
 {
     this.drawApi = draw;
 }
Beispiel #10
0
 protected Shape(IDrawAPI drawAPI)
 {
     this.drawAPI = drawAPI;
 }
Beispiel #11
0
 public Circle(int radius, int x, int y, IDrawAPI drawAPI) : base(drawAPI)
 {
     this.radius = radius;
     this.x      = x;
     this.y      = y;
 }
Beispiel #12
0
 public Shape(IDrawAPI drawAPI)
 {
     this.DrawAPI = drawAPI;
 }
Beispiel #13
0
 public Circle(int _x, int _y, int _radius, IDrawAPI drawAPI) : base(drawAPI)
 {
     x      = _x;
     y      = _y;
     radius = _radius;
 }
Beispiel #14
0
 protected IShape(IDrawAPI drawAPI)
 {
     m_drawAPI = drawAPI;
 }
Beispiel #15
0
 public Circle(int x, int y, int radius, IDrawAPI drowAPI) : base(drowAPI)
 {
     this.X      = x;
     this.Y      = y;
     this.Radius = radius;
 }
Beispiel #16
0
        private void button2_Click(object sender, EventArgs e)
        {
            IDrawAPI rectangle = FigureFactory.GetFigure("Rectangle");

            rectangle.GetFigure(GetRandom(200), GetRandom(200), GetRandom(200), GetRandom(200), PictureBox);
        }
Beispiel #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            IDrawAPI circle = FigureFactory.GetFigure("Circle");

            circle.GetFigure(GetRandom(200), GetRandom(200), GetRandom(200), PictureBox);
        }
Beispiel #18
0
 public Shape(IDrawAPI drawAPI)
 {
     _drawAPI = drawAPI;
 }
Beispiel #19
0
 protected AbstractShape_抽象图形(IDrawAPI drawAPI)
 {
     this.drawAPI = drawAPI;
 }
Beispiel #20
0
 public Circle(IDrawAPI api) : base(api)
 {
 }
Beispiel #21
0
 public virtual void Draw(IDrawAPI drawAPI)
 {
     States[currentState].Draw(drawAPI);
 }
Beispiel #22
0
 public BridgeShape(IDrawAPI drawAPI)
 {
     this.drawAPI = drawAPI;
 }
Beispiel #23
0
 /// <summary>
 /// 需要手动调用的绘制
 /// </summary>
 /// <param name="drawAPI">绘制接口</param>
 public virtual void Draw(IDrawAPI drawAPI)
 {
 }
Beispiel #24
0
 protected Shape(IDrawAPI drawApi)
 {
     DrawApi = drawApi;
 }
Beispiel #25
0
 protected Shape(IDrawAPI drawApi)
 {
     _drawAPI = drawApi;
 }
Beispiel #26
0
 /// <summary>
 /// 通过IDrawAPI绘制文字
 /// </summary>
 public void DrawString(IDrawAPI spriteBatch, string text, Vector2 position)
 {
     DrawString(spriteBatch, text, position, Color.White, default, new Vector2(1, 1));
Beispiel #27
0
 public CircleEx(int x, int y, int radius, IDrawAPI drawapi) : base(drawapi)
 {
     this.x      = x;
     this.y      = y;
     this.radius = radius;
 }
Beispiel #28
0
 public Circle(IDrawAPI api, int x, int i, int radius) : base(api)
 {
     this.x      = x;
     this.y      = i;
     this.radius = radius;
 }