# How to fill a line one-sided using TikZ?

Usually, when drawing a line in TikZ, 'material' is added to both sides of the line to make it visible. Consider the image below (not sketched using TikZ). If I want to draw a black and rather fat line over the red path between A and B, then it would turn up like the top line. However, would it be possible to make the line fill only the left side of the path, such as in the bottom line? The end of the line (rounded or square) is not important.

The only solution I could think of right now is to is to define some kind of patch or fill that would actually define the exact coordinates of the line's boundaries. I'm hoping there is a simpler solution.

Clipping can be used to draw the half of the line in red:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\tikzstyle{myline} = [
ultra thick,
line cap=round,
]
\draw[
myline,
every node/.style={above, text=red, font=\sffamily},
]
(0, 0) coordinate (A) node {A}
--
(3, 1) coordinate (B) node {B}
;
\begin{scope}% limit range of clip
\clip[overlay]
($(A)!-2pt!(B)$) coordinate (tmpA)
-- ($(B)!-2pt!(A)$) coordinate (tmpB)
-- ($(tmpB)!2pt!90:(tmpA)$)
-- ($(tmpA)!2pt!-90:(tmpB)$)
-- cycle
;
\draw[myline, red] (A) -- (B);
\end{scope}
\end{tikzpicture}
\end{document}


Version, which shows the clip area:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\tikzstyle{myline} = [
ultra thick,
line cap=round,
]
\draw[
myline,
every node/.style={above, text=red, font=\sffamily},
]
(0, 0) coordinate (A) node {A}
--
(3, 1) coordinate (B) node {B}
;
\begin{scope}[green]% limit range of clip
\draw[clip,overlay]
($(A)!-2pt!(B)$) coordinate (tmpA)
-- ($(B)!-2pt!(A)$) coordinate (tmpB)
-- ($(tmpB)!2pt!90:(tmpA)$)
-- ($(tmpA)!2pt!-90:(tmpB)$)
-- cycle
;
\draw[
myline,
red,
] (A) -- (B);
\end{scope}
\end{tikzpicture}
\end{document}