algoritmo de bresenham em c codigo code Answer's
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
By Condemned Capybara
on Apr 28, 2021
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);
}
}
}
Source: github.com
0
algoritmo de bresenham em c codigo
By Condemned Capybara
on Apr 28, 2021
void drawLine(Pixel inicial, Pixel final){
int xi = inicial.x;
int xf = final.x;
int yi = inicial.y;
int yf = final.y;
int dx = abs(xf - xi);
int dy = abs(yf - yi);
int controle = 0; //Controla se a direção menor vai crescer ou nao;
int incX = 0;
int incY = 0;
//Define se Y e X estão indo nas direções positivas ou negativas
if(xf > xi) incX = 1;
else incX = -1;
if(yf > yi) incY = 1;
else incY = -1;
putPixel(inicial);
Pixel linha = {inicial.x, inicial.y, inicial.red, inicial.green, inicial.blue, inicial.alpha}; //Esse pixel é o que se moverá e pintará a linha
Source: github.com
0
The program above uses bresenham's algorithm to draw a line segment from (0,0) to (2,3). You can change the value to see how it changes as you change it.
C++ answers related to "algoritmo de bresenham em c codigo"
algoritmo de bresenham em c codigo algoritmo de bresenham em c codigo bresenham's line algorithm c++ bresenham's line algorithm c++ bresenham's line algorithm c++
View All C++ queries
C++ queries related to "algoritmo de bresenham em c codigo"
Browse Other Code Languages
Abap ActionScript Assembly BASIC C C# C++ Clojure Cobol CSS Dart Delphi Elixir Erlang F# Fortran Go Groovy Haskell Html Java Javascript Julia Kotlin Lisp Lua Matlab Objective-C Pascal Perl PHP PostScript Prolog Python R Ruby Rust Scala Scheme Shell/Bash Smalltalk SQL Swift TypeScript VBA WebAssembly Whatever