I use bufferedimage and have methods to
put a pixel in the image ( edit a value in the array), and i have a myDrawLine(int x,int y) method that draws a line using the pixel method. However it doesnt work as expected, the line drawn has space in it..can someone post an algorithm for drawing a line just by filling in the pixels representing the line?
this is for the 4k competition game im trying to make, i really would like to get this to work by myself but..:/ im not good enough
ive been looking for a basic tutorial on graphics with this kind of algorithm explained and from what i learned i created this method:
public static void myDrawLine(int x1, int y1, int x2, int y2)
int deltax = x2 - x1;
int deltay = y2 - y1;
int y = y1;
int ynum = deltax / 2;
for (int x = x1; x <= x2; x++)
ynum += deltay;
if (ynum >= deltax)
ynum -= deltax;
but the line created looks incomplete drawn at some
angles..i know this works only when the x coordinate is smaller then the x2 coordinate..
maybe i should just use the Graphics.drawline() method? would save some space probably