Answer the question
In order to leave comments, you need to log in
How to draw a line with my point drawing method?
I have my own method for drawing a point, you can't use another one. I need to draw a line. We need some ready-made line drawing method that can be easily changed.
Answer the question
In order to leave comments, you need to log in
Most likely, your method takes X and Y coordinate parameters. Therefore, you just need to call it in a loop, changing one of the coordinates in each iteration: X for a horizontal line, Y for a vertical one. Well, or both - for the diagonal)
You can use the Bresenham algorithm
https://ru.wikipedia.org/wiki/%D0%90%D0%BB%D0%B3%D...
https://ru.wikibooks.org/wiki/%D0%A0% D0%B5%D0%B0%D...
width=300;
height=300;
CreateWindowEx(hwnd,width,height);
color = red;
x = 100;
for(int i=0;i<100;i++)
{
SetPixel(i,x,red);//горизонтальная линия
SetPixel(x,i,red);//вертикальная линия
SetPixel(i,i,red);//диагональная линия
}
SwapBuffers(doubleBuffer,hwnd);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question