Exemplo n.º 1
0
 private void toolStripButton13_Click(object sender, EventArgs e)
 {
     UnCheckAllStylePainting();
     CheckStylePainting(sender);
     stylePainting = StylePainting.Symmetric;
     pictureBox1.Invalidate();
 }
Exemplo n.º 2
0
 public Form1()
 {
     stripChoice   = ToolStripChoice.DrawFigure;
     stylePainting = StylePainting.Brezenham;
     collection    = new CollectionFigure();
     isMoving      = false;
     InitializeComponent();
 }
Exemplo n.º 3
0
 public static void BrezenhamAlgorithm(this Graphics g, Models.Vertice start, Models.Vertice end, Pen pen, Brush brush, StylePainting stylePainting)
 {
     if (stylePainting == StylePainting.DrawLine)
     {
         g.DrawLine(pen, start.x, start.y, end.x, end.y);
     }
     else if (stylePainting == StylePainting.Brezenham)
     {
         double a = (double)(end.y - start.y) / (end.x - start.x);
         if (a > 1)
         {
             g.MidpointLineN_NE(brush, start.x, start.y, end.x, end.y);
             g.MidpointLineN_NE(brush, end.x, end.y, start.x, start.y);
         }
         else if (a <= 1 && a > 0)
         {
             g.MidpointLineE_NE(brush, start.x, start.y, end.x, end.y);
             g.MidpointLineE_NE(brush, end.x, end.y, start.x, start.y);
         }
         else if (a <= 0 && a >= -1)
         {
             g.MidpointLineE_SE(brush, start.x, start.y, end.x, end.y);
             g.MidpointLineE_SE(brush, end.x, end.y, start.x, start.y);
         }
         else
         {
             g.MidpointLineS_SE(brush, start.x, start.y, end.x, end.y);
             g.MidpointLineS_SE(brush, end.x, end.y, start.x, start.y);
         }
     }
     else if (stylePainting == StylePainting.Symmetric)
     {
         double a = (double)(end.y - start.y) / (end.x - start.x);
         if (a > 1)
         {
             g.SymmetricLineN_NE(brush, start.x, start.y, end.x, end.y);
             g.SymmetricLineN_NE(brush, end.x, end.y, start.x, start.y);
         }
         else if (a <= 1 && a > 0)
         {
             g.SymmetricLineE_NE(brush, start.x, start.y, end.x, end.y);
             g.SymmetricLineE_NE(brush, end.x, end.y, start.x, start.y);
         }
         else if (a <= 0 && a >= -1)
         {
             g.SymmetricLineE_SE(brush, start.x, start.y, end.x, end.y);
             g.SymmetricLineE_SE(brush, end.x, end.y, start.x, start.y);
         }
         else
         {
             g.SymmetricLineS_SE(brush, start.x, start.y, end.x, end.y);
             g.SymmetricLineS_SE(brush, end.x, end.y, start.x, start.y);
         }
     }
     else if (stylePainting == StylePainting.WU)
     {
         //Rozwiazanie zaczerpniete z https://rosettacode.org/wiki/Xiaolin_Wu%27s_line_algorithm?fbclid=IwAR3NZV-yyZdm4uB8sM76pNIRu-bZZbcsdD7TMNKLknokcgbq8pjbtyu3OWA#C.23
         WU wu = new WU(start.x, start.y, end.x, end.y, Color.Black, g);
         g = wu.Draw();
     }
 }