I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw \"caps\" at
If you want to avoid a sqrt, do the following:
in: line_length, cap_length, rotation, position of line centre
define points:
tl (-line_length/2, cap_length)
tr (line_length/2, cap_length)
bl (-line_length/2, -cap_length)
br (line_length/2, -cap_length)
rotate the four points by 'rotation'
offset four points by 'position'
drawline (midpoint tl,bl to midpoint tr,br)
drawline (tl to bl)
drawline (tr to br)