LabPlanet

This is the forum of Lab, an alternative rock band from Finland.
It is currently Thu Mar 28, 2024 12:08 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: algoritmo de bresenham em c codigo code Answer's
PostPosted: Fri Jun 24, 2022 1:48 pm 
Offline

Joined: Wed Feb 16, 2022 2:58 pm
Posts: 20
bresenham's algorithm is a simple algorithm to draw line segments. It is based on points, lines and the two-dimensional coordinate system. The main goal of this algorithm is to draw a line segment between two points that are on the edge of the canvas.
algoritmo de bresenham em c codigo
Code:
if(dx == 0){
        if(yf > yi){    //linha pra baixo
            while(linha.y != yf)
            {

                linha.y++;             
                putPixel(linha);

            }
        }
        else{           //linha pra cima
            while(linha.y != yf)
            {

                linha.y--;               
                putPixel(linha);

            }
        }

    }
    else if(dy == 0){
        if(xf > xi){    //linha pra direita
            while(linha.x != xf)
            {

                linha.x++;               
                putPixel(linha);

            }
        }
        else{           //linha pra esquerda
            while(linha.x != xf)
            {

                linha.x--;               
                putPixel(linha);

            }
        }
    }


Top
 Profile  
 
 Post subject: Re: algoritmo de bresenham em c codigo code Answer's
PostPosted: Tue Jun 28, 2022 11:09 am 
Offline

Joined: Tue Jun 28, 2022 11:06 am
Posts: 30
roxijan22 wrote:
bresenham's algorithm is a simple algorithm to draw line segments. It is based on points, lines and the two-dimensional coordinate system. The main goal of this algorithm is to draw a line segment between two points that are on the edge of the canvas.
algoritmo de bresenham em c codigo
Code:
if(dx == 0){
        if(yf > yi){    //linha pra baixo
            while(linha.y != yf)
            {

                linha.y++;             
                putPixel(linha);

            }
        }
        else{           //linha pra cima
            while(linha.y != yf)
            {

                linha.y--;               
                putPixel(linha);

            }
        }

    }
    else if(dy == 0){
        if(xf > xi){    //linha pra direita
            while(linha.x != xf)
            {

                linha.x++;               
                putPixel(linha);

            }
        }
        else{           //linha pra esquerda
            while(linha.x != xf)
            {

                linha.x--;               
                putPixel(linha);

            }
        }
    }

pandrama


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 53 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL