Esempio n. 1
0
        public static Bitmap Midpoint(Bitmap img, int x1, int y1, int x2, int y2, Color cor)
        {
            Bitmap btm = new Bitmap(img);
            int    R   = (int)Math.Round(Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)));
            int    x   = 0;
            int    y   = R;
            int    d   = 1 - R;

            btm = DrawCircle.Draw(btm, x, y, x1, y2, cor);
            while (y > x)
            {
                if (d < 0)
                {
                    d += 2 * x + 3;
                }
                else
                {
                    d += 2 * (x - y) + 5;
                    y--;
                }
                x++;
                btm = DrawCircle.Draw(btm, x, y, x1, y2, cor);
            }
            return(btm);
        }
Esempio n. 2
0
        public static Bitmap RealCircle(Bitmap img, int x1, int y1, int x2, int y2, Color cor)
        {
            Bitmap btm  = new Bitmap(img);
            int    raio = (int)Math.Round(Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)));
            int    cx   = x1;
            int    cy   = y1;

            for (int x = 0; x < raio; x++)
            {
                int y = (int)Math.Round(Math.Sqrt(Math.Pow(raio, 2) - Math.Pow(x, 2)));
                btm = DrawCircle.Draw(btm, x, y, cx, cy, cor);
            }
            return(btm);
        }
Esempio n. 3
0
        private void picBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (picBox.Image != null)
            {
                toolTip.SetToolTip(picBox, "X:" + e.X + " Y:" + e.Y);
            }
            if (polyflag == true && polyfirst == false)
            {
                picBox.Image = DrawLine.DDA((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
            }
            else
            {
                if (flag == true && picBox.Image != null && polyflag == false)
                {
                    switch (this.Active)
                    {
                    case "Equação Real da Reta":
                        picBox.Image = DrawLine.RealLine((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    case "DDA":
                        picBox.Image = DrawLine.DDA((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    case "Bresenham":
                        picBox.Image = DrawLine.Bresenham((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    case "Trigonometria":
                        picBox.Image = DrawCircle.Trigonometry((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    case "Ponto Médio":
                        picBox.Image = DrawCircle.Midpoint((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    case "Ponto Médio Elipse":
                        picBox.Image = DrawEllipse.Midpoint((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;

                    default:
                        picBox.Image = DrawCircle.RealCircle((Bitmap)img, point.X, point.Y, e.X, e.Y, Color.Black);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        public static Bitmap Trigonometry(Bitmap img, int x1, int y1, int x2, int y2, Color cor)
        {
            Bitmap btm       = new Bitmap(img);
            double angle     = 45;
            int    R         = (int)Math.Round(Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)));
            double perimeter = 2 * Math.PI * R;
            double inc       = 360 / perimeter;

            for (; angle <= 90; angle += inc)
            {
                double g = angle * Math.PI / 180;
                int    x = (int)Math.Round(R * Math.Cos(g));
                int    y = (int)Math.Round(R * Math.Sin(g));
                Console.WriteLine(x + " | " + y);
                btm = DrawCircle.Draw(btm, x, y, x1, y1, cor);
            }
            return(btm);
        }