Am trying to make a thick line for my drawing app. issue is i found some book online http://members.chello.at/~easyfilter/Bresenham.pdf (page 81 thick line algorithm) its writen in C i think anyway i converted it to C# but have issue my lines dont have constant width duno why…
My code:
void plotLineWidth(int x0, int y0, int x1, int y1, float wd)
{ // plot an anti-aliased line of width wd
int dx = Mathf.Abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
int dy = Mathf.Abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
int err = dx - dy, e2, x2, y2; // error value e_xy
float ed = dx + dy == 0 ? 1 : Mathf.Sqrt((float)dx * dx + (float)dy * dy);
for (wd = (wd + 1) / 2; ;) { // pixel loop
SetPixelMyImg(x0, y0);
e2 = err; x2 = x0;
if (2 * e2 >= -dx) { // x step
for (e2 += dy, y2 = y0; e2 < ed * wd && (y1 != y2 || dx > dy); e2 += dx) {
y2 += sy;
SetPixelMyImg(x0, y2);
}
if (x0 == x1) break;
e2 = err; err -= dy; x0 += sx;
}
if (2 * e2 <= dy) { // y step
for (e2 = dx - e2; e2 < ed * wd && (x1 != x2 || dx < dy); e2 += dy) {
x2 += sx;
SetPixelMyImg(x2, y0);
}
if (y0 == y1) break;
err += dx; y0 += sy;
}
}
}
So you can see what heppends. I draw lines (more like drawing colors cuz i am deliting black white top layer parts so bottom layer color shows) from mid to all directions…
See how its all bent. i think 90 degree lines are thin while all other are thick and deformed near ends. Any help would be nice ![]()

