Exemplo n.º 1
0
        private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            List <Point> l = new List <Point>();

            if (down.X != -1)
            {
                if (flag.Equals("Ret"))
                {
                    p.Draw(white, image);
                    l.Add(new Point(Math.Min(e.X, down.X), Math.Min(e.Y, down.Y)));
                    l.Add(new Point(Math.Abs(down.X - e.X) + Math.Min(e.X, down.X), Math.Min(e.Y, down.Y)));
                    l.Add(new Point(Math.Max(e.X, down.X), Math.Max(e.Y, down.Y)));
                    l.Add(new Point(Math.Min(e.X, down.X), Math.Abs(down.Y - e.Y) + Math.Min(e.Y, down.Y)));
                    p = new Poligono(l, 'R');
                    p.Draw(color, image);
                }
                else if (flag.Equals("Circ"))
                {
                    Primitivas.ponto_medio_circunf(down.X, down.Y, old.X, old.Y, white, image);
                    Primitivas.ponto_medio_circunf(down.X, down.Y, e.X, e.Y, color, image);
                }
                else if (flag.Equals("Elip"))
                {
                    Primitivas.ponto_medio_elipse(down.X, down.Y, old.X, old.Y, white, image);
                    Primitivas.ponto_medio_elipse(down.X, down.Y, e.X, e.Y, color, image);
                }
                else if (flag.Equals("Reta"))
                {
                    Primitivas.bresenham(down.X, down.Y, old.X, old.Y, white, image);
                    Primitivas.bresenham(down.X, down.Y, e.X, e.Y, color, image);
                }
                else if (flag.Equals("Livre"))
                {
                    Primitivas.bresenham(liv.X, liv.Y, e.X, e.Y, color, image);
                    liv = e.Location;
                }
                else if (flag.Equals("Pol"))
                {
                    Primitivas.bresenham(down.X, down.Y, old.X, old.Y, white, image);
                    Primitivas.bresenham(down.X, down.Y, e.X, e.Y, color, image);
                }

                old          = e.Location;
                pbMain.Image = image;
            }

            lbX.Text = e.X + "";
            lbY.Text = e.Y + "";
        }
Exemplo n.º 2
0
        public void SetPoligono(Object o)
        {
            this.p               = (Poligono)o;
            pictureBox1.Width    = Width - 15;
            pictureBox1.Height   = Height - 45;
            pictureBox1.Location = new Point(Location.X, Location.Y);
            image = new Bitmap(pictureBox1.Width, pictureBox1.Height);

            Point centro = p.Centro();
            Point min = p.MinPoint(), max = p.MaxPoint();

            p.Escala(((double)Width - 15) / (max.X - min.X), ((double)Height - 45) / (max.Y - min.Y));
            p.Translacao(-min.X, -min.Y);

            p.Draw(Color.Black, image);
            pictureBox1.Image = image;
        }
Exemplo n.º 3
0
        private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvPolig.SelectedIndex > -1)
            {
                p = (Poligono)lvPolig.Items[lvPolig.SelectedIndex];
                p.Draw(Color.Red, image);

                DataTable dt = new DataTable();
                dt.Columns.Add("X");
                dt.Columns.Add("Y");

                foreach (Point pts in p.PontosAtuais)
                {
                    DataRow dr = dt.NewRow();
                    dr["X"] = pts.X;
                    dr["Y"] = pts.Y;

                    dt.Rows.Add(dr);
                }
                gbTrans.Enabled          = true;
                dataGridView1.DataSource = dt;
                pbMain.Image             = image;
            }
        }
Exemplo n.º 4
0
        private void BtTransformar_Click(object sender, EventArgs e)
        {
            p.Draw(white, image);
            string select = cbTransf.Text;
            double x = tbX.Text.Equals("") ? 0 : double.Parse(tbX.Text), y = tbY.Text.Equals("") ? 0 : double.Parse(tbY.Text);
            Point  ponto_aux = new Point();

            if (select.Equals("ScanLine"))
            {
                cdCor.ShowDialog();
                p.ScanLine(image, cdCor.Color);
            }
            else
            if (select.Equals("Translação"))
            {
                p.Translacao(x, y);
            }
            else if (select.Equals("Rotação"))
            {
                if (rbEixo.Checked)
                {
                    ponto_aux = p.Centro();
                }
                else if (rbPonto.Checked)
                {
                    ponto_aux = new Point(int.Parse(tbPFx.Text), int.Parse(tbPFy.Text));
                }
                if (rbEixo.Checked || rbPonto.Checked)
                {
                    p.Translacao(ponto_aux.X, ponto_aux.Y);
                }
                p.Rotacao(x * Math.PI / 180.0);
                if (rbEixo.Checked || rbPonto.Checked)
                {
                    p.Translacao(-ponto_aux.X, -ponto_aux.Y);
                }
            }
            else
            {
                if (rbEixo.Checked)
                {
                    ponto_aux = p.CentroAtual();
                }
                else if (rbPonto.Checked)
                {
                    ponto_aux = new Point(int.Parse(tbPFx.Text), int.Parse(tbPFy.Text));
                }

                if (rbEixo.Checked || rbPonto.Checked)
                {
                    p.Translacao(p.Centro().X, p.Centro().Y);
                }

                if (select.Equals("Escala"))
                {
                    p.Escala(x, y);
                }
                else if (select.Equals("Cisalhamento"))
                {
                    p.Cisalhamento(x, y);
                }
                else if (select.Equals("Espelhamento"))
                {
                    p.Espelhamento(x, y);
                }

                if (rbEixo.Checked || rbPonto.Checked)
                {
                    p.Translacao(-ponto_aux.X, -ponto_aux.Y);
                }
            }

            p.Draw(Color.Black, image);
            pbMain.Image = image;
        }