Example #1
0
 private void put4pitxel(int x, int y, Graphics g)
 {
     ToaDo.putpixel(new Point(tam.X + x, tam.Y + y), g, this.mau);
     ToaDo.putpixel(new Point(tam.X - x, tam.Y + y), g, this.mau);
     ToaDo.putpixel(new Point(tam.X - x, tam.Y - y), g, this.mau);
     ToaDo.putpixel(new Point(tam.X + x, tam.Y - y), g, this.mau);
 }
Example #2
0
 public int netdut(Point p, Graphics g, Color c, int length)
 {
     if (length % 7 >= 0 && length % 7 < 5)
     {
         ToaDo.putpixel(p, g, this.mau);
     }
     length++;
     return(length);
 }
Example #3
0
 public void Drawn8Point(int x, int y, Graphics g, Color color)
 {
     ToaDo.putpixel(new Point(x + tam.X, y + tam.Y), g, color);
     ToaDo.putpixel(new Point(y + tam.X, x + tam.Y), g, color);
     ToaDo.putpixel(new Point(-x + tam.X, -y + tam.Y), g, color);
     ToaDo.putpixel(new Point(-y + tam.X, -x + tam.Y), g, color);
     ToaDo.putpixel(new Point(-x + tam.X, y + tam.Y), g, color);
     ToaDo.putpixel(new Point(-y + tam.X, x + tam.Y), g, color);
     ToaDo.putpixel(new Point(x + tam.X, -y + tam.Y), g, color);
     ToaDo.putpixel(new Point(y + tam.X, -x + tam.Y), g, color);
 }
Example #4
0
        public void vedthang(Graphics g)
        {
            //Này xài thuật toán Breshenhem nha
            int   x, y;
            float p;
            float c2 = 0;
            float c  = 0;

            int x1 = this.diemdau.X;
            int y1 = this.diemdau.Y;
            int x2 = this.diemcuoi.X;
            int y2 = this.diemcuoi.Y;


            float Dx = Math.Abs(x2 - x1);
            float Dy = Math.Abs(y2 - y1);

            c  = Dx - Dy;
            c2 = 2 * c;
            x  = x1;
            p  = 2 * Dy - Dx;
            y  = y1;

            int x_unit = 5, y_unit = 5;

            if (x2 - x1 < 0)
            {
                x_unit = -x_unit;
            }
            if (y2 - y1 < 0)
            {
                y_unit = -y_unit;
            }
            ToaDo.putpixel(new Point(x, y), g, this.mau);
            if (x1 == x2)   // duong thang dung
            {
                while (y != y2)
                {
                    y += y_unit;
                    ToaDo.putpixel(new Point(x, y), g, this.mau);
                }
            }

            else if (y1 == y2)  // duong ngang
            {
                while (x != x2)
                {
                    x += x_unit;
                    ToaDo.putpixel(new Point(x, y), g, this.mau);
                }
            }

            else if (x1 != x2 && y1 != y2)  // duong xien
            {
                if ((Math.Abs(y2 - y1)) <= 25)
                {
                    while (x != x2)
                    {
                        if (p < 0)
                        {
                            p += 2 * Dy;
                        }
                        else
                        {
                            p += 2 * (Dy - Dx);
                            y += y_unit;
                        }
                        x += x_unit;
                        ToaDo.putpixel(new Point(x, y), g, this.mau);
                    }
                }
                else
                {
                    if (x2 >= x1)
                    {
                        // var sign=5;
                        // (y2>y1)? sign=5:sign=-5;
                        while (!(x == x2 + 5 || y == y2))
                        {
                            c2 = 2 * c;
                            if (c2 > -Dy)
                            {
                                c = c - Dy;
                                x = x + x_unit;
                            }
                            if (c2 < Dx)
                            {
                                c = c + Dx;
                                y = y + y_unit;
                            }
                            ToaDo.putpixel(new Point(x, y), g, this.mau);
                        }
                    }
                    if (x2 < x1)
                    {
                        // var sign=5;
                        // (y2>y1)? sign=+5:sign=-5;
                        while (!(x == x2 - 5 || y == y2))
                        {
                            c2 = 2 * c;
                            if (c2 > -Dy)
                            {
                                c = c - Dy;
                                x = x + x_unit;
                            }
                            if (c2 < Dx)
                            {
                                c = c + Dx;
                                y = y + y_unit;
                            }
                            ToaDo.putpixel(new Point(x, y), g, this.mau);
                        }
                    }
                }
            }
        }