I have a figure with various lines which needs to have a gradient on a side as in the image below:

[![enter image description here](https://i.stack.imgur.com/VZVRq.png)](https://i.stack.imgur.com/VZVRq.png)

The direction of the gradient should be perpendicular to the red thick line starting with dark green on the line itself and then becoming fully transparent (where now is black). 

How can I fix the position of the gradient (as its starting points seems to be outside the rectangle) and make the black fully transparent (using `transparent` doesn't seem to work properly)? I know I should use a canvas transformation but I can’t do it properly as I can no longer use the coordinates I saved.

Here's the MWE used to generate the image:

```
\documentclass{article}

\usepackage{tikz,pgf}
\usetikzlibrary{shapes,positioning,decorations.pathreplacing,intersections,calc}
\usepackage{color}
\definecolor{darkgreen}{rgb}{0,0.4,0}

%Length and angle for a segment in tikz
\makeatletter      
\newcommand{\getAngle}[2]{%
    \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}
                              {\pgfpointanchor{#2}{center}}
    \global\let\angle\pgfmathresult % we need a global macro 
}
\makeatother

\begin{document}
\begin{tikzpicture}
    \draw[->] (0,0) coordinate(origin)
    ++(-.2,0) -- ++(6.5,0) node[right]{$x_1$};
    \draw[->] (origin) ++(0,-.2) -- ++(0,5.5) node[above]{$x_2$};

    \draw[blue,shorten >= -.1cm, shorten <=-.1cm] (4,0) coordinate(v1_1) -- (4,5) coordinate(v1_2); % eq 1
    \path ($(v1_1)!-.1cm!(v1_2)$) coordinate(v1_1) ($(v1_2)!-.1cm!(v1_1)$) coordinate(v1_2);

    \draw[red,shorten >= -.1cm, shorten <=-.1cm] (0,5) coordinate(v2_1) -- (4,5) coordinate(v2_2);% eq 2
    \path ($(v2_1)!-.1cm!(v2_2)$) coordinate(v2_1) ($(v2_2)!-.1cm!(v2_1)$) coordinate(v2_2);

    \path[shorten >= 1.1cm, shorten <=-.1cm] (6,0) coordinate(v3_1) -- (2,6) coordinate(v3_2); % eq 3
    \path ($(v3_1)!-.1cm!(v3_2)$) coordinate(v3_1) ($(v3_2)!1.1cm!(v3_1)$) coordinate(v3_2);
    \getAngle{v3_1}{v3_2}
    \begin{scope}[rotate=\angle]
        \path (v3_2) -- ++(90:.7) coordinate(v3_3) (v3_1) -- ++(90:.7) coordinate(v3_4);
        % Here black should become transparent
        \shade[left color=black,right color=darkgreen,shading angle=\angle] (v3_3) rectangle (v3_1);
    \end{scope}
    \draw[red,ultra thick] (v3_1) -- (v3_2);
\end{tikzpicture}
\end{document}

```