Java – supersymmetric line algorithm?
•
Java
In a special case, I need to generate supersymmetric lines or rays in the 2D grid in the order from (x0, Y0) to (x1, Y1):
void drawSymmetricalLine(int x0,int y0,int x1,int y1) { // loop and handle each (x,y)... }
The practical problem is that the popular line graph algorithm does not draw two coordinates (the other is marked x) because it seems to get thicker, which is needed in my case Performance is not important, but simple
This is what I call a supersymmetric line:
ox ooo oo ooo o o o o o o o
Solution
You can use Bresenham's line algorithm and modify it slightly so that when the step changes to move the drawing position from one row to another column, you can draw front and rear pixels on the Y axis for the current X axis
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码