Consider the figure below (I'm sure you already know this basic 2D geometry, but without that my answer would be incomplete):

The coordinates for points A and B are known, and we want to find a function that can be used to calculate the y-coordinate whenever the x-coordinate is known, so that the point (x, y) lies on a straight line. In figure 1:
k = tan (alpha) = (y2 - y1) / (x2 - x1) - line slope
Putting the coordinates A or B in the well-known linear equation y = kx + m , we can calculate m to make the equation complete. Having this equation, for any x coordinate, we can calculate the y coordinate using this equation. The good thing is that it does not depend on the position of points A and B or the deviations (angle) of the line - you have to take care of the special case of vertical / horizontal lines, where y / x will be infinite in accordance with this equation.
Let's get back to your question. Take a look at Figure 2 below:

Here we have a very similar situation, between points A and C there is a straight line, and between points B and D. I assume that point A is in the center of the coordinate system! This, as a rule, will not, but it really is not a limitation, since you can perform a translation that will put A in the center, then do your calculations, and then translate everything back.
Using the technique described at the beginning, you can find a linear equation for the line connecting points A and C, and for the line connecting points B and D (D coordinates can be easily calculated). Suppose you did just that:
AC: y = k1 * x (m is zero when the line passes through center A)
BD: y = k2 * x + m2 (m2 is not equal to zero, since the line does not pass through the center A)
Finally, an algorithm that you could use to draw these parallel lines:
- Select the space in which you want to take the x-coordinates between x1 and x3. For example, if you want 4 lines, this space will be
s = (x3 - x1) / 4 , etc. - Set the value
x_start = x1 + s (and later x_start += s) and calculate the y-coordinate using the equation for the AC line y_end = k1*x_start . This will give you a point lying on the AC line, and this is the beginning of your line. - Similarly, calculate the endpoint that will lie on the line connecting B and D:
x_end = x2 + s (later x_end + = s)
y_end = k2 * x_end + m2
- Using these equations, calculate the points (x_start, y_start) and (x_end, y_end) for all the lines you want to draw (of which
|x3 - x1| / desired_num_of_lines ).
You will need to generate new equations every time point A leaves the current AC line, since each time this happens, the slop of the AC line (and BD) changes the invalidity of the current equations.
I will not write any JS code, but the presence of the logic of a possible solution should give you more than enough information to move forward with your own implementation.