A thick line is a polygon. (Let's forget about antialiasing for now)
start = line start = vector(x1, y1)
end = line end = vector(x2, y2)
dir = line direction = end - start = vector(x2-x1, y2-y1)
ndir = normalized direction = dir*1.0/length(dir)
perp = perpendicular to direction = vector(dir.x, -dir.y)
nperp = normalized perpendicular = perp*1.0/length(perp)
perpoffset = nperp*w*0.5
diroffset = ndir*w*0.5
(You can easily remove one normalization and calculate one of the offsets by taking perpendicular from the other)
p0, p1, p2, p3 = polygon points:
p0 = start + perpoffset - diroffset
p1 = start - perpoffset - diroffset
p2 = end + perpoffset + diroffset
p3 = end - perpoffset + diroffset
P.S. You're the last person I ever going to explain this stuff to.
Things like these should be understood on intuitive level.