Esempio n. 1
0
        public void DrawEllipse(int x, int y, int radiusX, int radiusY, Color color, int thickness = 1)
        {
            if (radiusX <= -1)
            {
                radiusX *= -1;
            }
            if (radiusY <= -1)
            {
                radiusY *= -1;
            }

            int x1 = x - radiusX;
            int y1 = y - radiusY;
            int x2 = x + radiusX;
            int y2 = y + radiusY;

            if (!IsObjectOnScreen(x1, y1, x2 - x1, y2 - y1))
            {
                return;
            }

            EllipseKey key = new EllipseKey(radiusX, radiusY, color, thickness);


            Rectangle screen = _parent.GetScreen();
            double    zoom   = _parent.GetZoom();

            TextureExt tx_ellipse = GetEllipse(key);

            DrawTexture(tx_ellipse, new Rectangle(0, 0, x2 - x1, y2 - y1), new Vector3(0, 0, 0), new Vector3(x1 - (int)(screen.X / zoom), y1 - (int)(screen.Y / zoom), 0), color);
        }
Esempio n. 2
0
        public TextureExt GetEllipse(EllipseKey key)
        {
            if (tx_ellipses.ContainsKey(key))
            {
                return(tx_ellipses[key]);
            }
            else
            {
                int size = 0;
                if (key.radiusX * 2 > key.radiusY * 2)
                {
                    size = key.radiusX * 2;
                }
                else
                {
                    size = key.radiusY * 2;
                }
                size += key.thickness;
                size += 1;
                Bitmap txb_ellipse = GetTextureReadyBitmap(new Bitmap(size, size));
                using (Graphics g = Graphics.FromImage(txb_ellipse))
                {
                    g.Clear(Color.Transparent);
                    Pen pen = new Pen(key.color);
                    pen.Width = key.thickness;

                    int x      = 0;
                    int y      = 0;
                    int width  = key.radiusX * 2;
                    int height = key.radiusY * 2;

                    g.DrawEllipse(pen, new System.Drawing.RectangleF(x, y, width, height));
                }
                TextureExt tx_ellipse = Methods.Drawing.TextureCreator.FromBitmap(_device, txb_ellipse);
                tx_ellipses.Add(key, tx_ellipse);
                txb_ellipse.Dispose();
                return(tx_ellipses[key]);
            }
        }