I am building a mapping software, and i have a problem in calculating specific points for building the roads. The way i build them is that i have the start and end point (all information is in x and y coordinates), the width of the road, and i can calculate the slope.

To draw the middle (dashed lines on the road) line is simple, it is from starting to ending point, but i am having problem finding the starting and ending points of the road boundaries (which has distance of width/2 above and below the middle line). Now if the road is completely horizontal, i simply can add width/2 in the y coordinate of the above boundary's starting and ending point, and subtract width/2 from the y coordinate of the starting and ending points to calculate the starting and ending points of the lower boundary. But i am stuck at how to find these points when the road is not horizontal or vertical, but tilted or diagonal (when ill need to add something to both x and y coordinates).

I can have the slope of the road, and slope of the perpendicular (on which the start points of both upper and lower boundary will lie), and i have the width, but how to continue from here?

I have attached an image to make the point clear.

Thanks in advance for the replies!