How is this 'wy' equation for thick line segment derived?

Thick line segment



1 Answer 1


The main part of it is simply Pythagoras's Theorem. The square root gives the length of the central line segment (which is the hypotenuse of a triangle formed by the change in x and change in y). The ratio between the hypotenuse and the change in x is the same as the ratio between the line width and the line width in y (they are similar triangles). Dividing by two is because $w_y$ is the half-width, not the full width. The -1 doesn't appear to make sense in a continuous context, so I assume it's to make sure the number of pixels is rounded down as part of the division. This prevents the line from jumping in thickness when it crosses a pixel boundary.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.