An algorithm to know if a point $P$ is in the rectangle $ABCD$ is to check that
- $\vec{AB}\cdot \vec{AP}\leq 0$,
- $\vec{DC}\cdot \vec{DP}\geq 0$,
- $\vec{DA}\cdot \vec{DP}\leq 0$, and
- $\vec{CB}\cdot \vec{CP}\geq 0$.
Since you have the two extremity point and the width $A,B,C$ and $D$ should be easy to compute. And you can restrict the point you are checking to $(x,y)$ such that $min(A_x,B_x,C_x,D_x)\leq x \leq max(A_x,B_x,C_x,D_x)$ and $min(A_y,B_y,C_y,D_y)\leq y \leq max(A_y,B_y,C_y,D_y)$.
It may not be optimal but it should be working.
Ps: I agree with @Dukeling.
[Edit] to compute $A$
If begin and end have the same abscissa (or ordinate) then it easy. Otherwise:
Let $begin=(b_x,b_y)$, $end=(e_x,e_y)$, $A=(x,y)$ and $width/2=w$ you know that:
$$\vec{beginend}=((e_x-b_x),(e_y-b_y))$$
$$\vec{beginA}=((x-b_x),(y-b_y))$$
hence:
$$\vec{beginend}\cdot\vec{beginA}=(e_x-b_x)(x-b_x)+(e_y-b_y)(y-b_y)=0$$
hence:
$$ x = b_x -\frac{(e_y-b_y)(y-b_y)}{(e_x-b_x)} $$
Also $|\vec{beginA}|=w$ hence:
$$(x-b_x)^2+(y-b_y)^2=w$$
hence:
$$(b_x -\frac{(e_y-b_y)(y-b_y)}{(e_x-b_x)}-b_x)^2+(y-b_y)^2=w$$
Solve this equation and you have $y$, then replace the solution in $$ x = b_x -\frac{(e_y-b_y)(y-b_y)}{(e_x-b_x)} $$ and you have $x$.
Notice that you have two solution one for $A$ the other for $D$ ...
Do the same for $B$ and $C$ with appropriate vectors.