Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawLineConst(Coordenadas *Pinicio, Coordenadas *Pfinal, Cor *cor)
- {
- float x = Pinicio->GetX();
- float y = Pinicio->GetY();
- float xf = Pfinal->GetX();
- float yf = Pfinal->GetY();
- int dx = abs( Pfinal->GetX()) - abs(Pinicio->GetX()); //distancia entre as coordenadas Xinicial e Xfinal
- int dy = abs( Pfinal->GetY() ) - abs( Pinicio->GetY()); //distancia entre as coordenadas Yinicial e Yfinal
- int incX=0;
- int incY=0;
- if (xf > x){ /* X cresce */
- incX=1;
- } else
- { /* X descresce */
- incX=-1;
- }
- if (yf > y){ /* Y cresce */
- incY = 1;
- } else/* Y descresce */
- {
- incY = -1 ;
- }
- cout<<"\n\n\nY = "<<incY;
- if( dx==0) // dx igual 0
- {
- if(incY > 0)
- {
- for(y= Pinicio->GetY(); y<=Pfinal->GetY(); y++)
- {
- Coordenadas *coordenadas = new Coordenadas(x,y);
- PutPixel(coordenadas,cor);
- }
- }
- else
- {
- for(y= Pfinal->GetY(); y<=Pinicio->GetY(); y++)
- {
- Coordenadas *coordenadasA = new Coordenadas(x,y);
- PutPixel(coordenadasA,cor);
- }
- }
- }
- else if(dy==0)
- {
- if(incX > 0)
- {
- for(x= Pinicio->GetX(); x<=Pfinal->GetX(); x++)
- {
- Coordenadas *coordenadas = new Coordenadas(x,y);
- PutPixel(coordenadas,cor);
- }
- }
- else
- {
- for(x= Pfinal->GetX(); x<=Pinicio->GetX(); x++)
- {
- Coordenadas *coordenadasA = new Coordenadas(x,y);
- PutPixel(coordenadasA,cor);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement