document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. void DrawLineConst(Coordenadas *Pinicio, Coordenadas *Pfinal, Cor *cor)
  2. {
  3.  
  4.      float x  = Pinicio->GetX();
  5.      float y  = Pinicio->GetY();
  6.      float xf = Pfinal->GetX();
  7.      float yf = Pfinal->GetY();
  8.      int dx = abs( Pfinal->GetX()) - abs(Pinicio->GetX()); //distancia entre as coordenadas Xinicial e Xfinal
  9.      int dy = abs( Pfinal->GetY() ) - abs( Pinicio->GetY()); //distancia entre as coordenadas Yinicial e Yfinal
  10.      int incX=0;
  11.      int incY=0;
  12.      if (xf > x){            /* X cresce */
  13.         incX=1;
  14.     } else
  15.     {     /* X descresce */
  16.         incX=-1;
  17.     }
  18.     if (yf > y){            /* Y cresce */
  19.         incY = 1;
  20.     } else/* Y descresce */
  21.     {
  22.         incY = -1 ;
  23.     }
  24.  
  25.       cout<<"\\n\\n\\nY = "<<incY;
  26.  
  27.             if( dx==0) // dx igual 0
  28.             {
  29.                     if(incY > 0)
  30.                     {
  31.                         for(y= Pinicio->GetY(); y<=Pfinal->GetY(); y++)
  32.                         {
  33.                             Coordenadas *coordenadas = new Coordenadas(x,y);
  34.                             PutPixel(coordenadas,cor);
  35.                         }
  36.                     }
  37.                     else
  38.                     {
  39.                         for(y= Pfinal->GetY(); y<=Pinicio->GetY(); y++)
  40.                         {
  41.                             Coordenadas *coordenadasA = new Coordenadas(x,y);
  42.                             PutPixel(coordenadasA,cor);
  43.  
  44.                         }
  45.  
  46.                     }
  47.             }
  48.  
  49.             else if(dy==0)
  50.             {
  51.                     if(incX > 0)
  52.                     {
  53.                         for(x= Pinicio->GetX(); x<=Pfinal->GetX(); x++)
  54.                         {
  55.                             Coordenadas *coordenadas = new Coordenadas(x,y);
  56.                             PutPixel(coordenadas,cor);
  57.                         }
  58.                     }
  59.                     else
  60.                     {
  61.                         for(x= Pfinal->GetX(); x<=Pinicio->GetX(); x++)
  62.                         {
  63.                             Coordenadas *coordenadasA = new Coordenadas(x,y);
  64.                             PutPixel(coordenadasA,cor);
  65.  
  66.                         }
  67.  
  68.                     }
  69.  
  70.  
  71.             }
  72.  
  73. }
');