I'm adding borders to some tikz drawings in my document. Some are just images inside a tikz environment and some are full on drawings.
Using existing Q&A from here (most specifically Including an image with a faded border I've used the initial code as I want a constant grey fade rather than fading out the image as they all have white backgrounds) I've got the look I want although on compile I'm getting an extra thin grey line at the edge of my fade. This disappears completely when I comment out the framenode line at the end and set the start to:
\node (image)at (0,0) %[square,draw,line width=3mm]
so I'm sure I'm missing something in the frame set up that was not obvious in the answer I linked above.
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc,fadings}
\usetikzlibrary{shapes.geometric}
\tikzstyle arrowstyle=[scale=1]
\tikzstyle arrowstyle2=[scale=2]
\tikzstyle directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrow[arrowstyle]{stealth}}}}]
\tikzstyle reverse directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrowreversed[arrowstyle]{stealth};}}}]
\tikzstyle directed2=[postaction={decorate,decoration={markings,
mark=at position 1 with {\arrow[arrowstyle2]{stealth}}}}]
\tikzstyle reverse directed2=[postaction={decorate,decoration={markings,
mark=at position 0 with {\arrowreversed[arrowstyle2]{stealth};}}}]
\tikzfading[name=fade l,left color=transparent!100,right color=transparent!0]
\tikzfading[name=fade r,right color=transparent!100,left color=transparent!0]
\tikzfading[name=fade d,bottom color=transparent!100,top color=transparent!0]
\tikzfading[name=fade u,top color=transparent!100,bottom color=transparent!0]
% this "frames" a rectangle node
\newcommand\framenode[2][10pt]{
\fill[white,path fading=fade u] (#2.south west) rectangle ($(#2.south east)+(0, #1)$);
\fill[white,path fading=fade d] (#2.north west) rectangle ($(#2.north east)+(0,-#1)$);
\fill[white,path fading=fade l] (#2.south east) rectangle ($(#2.north east)+(-#1,0)$);
\fill[white,path fading=fade r] (#2.south west) rectangle ($(#2.north west)+( #1,0)$);
}
\begin{document}
\begin{tikzpicture}[square/.style={regular polygon,regular polygon sides=4}]
\node (image)at (0,0) [square,draw,line width=3mm]
{
\begin{tikzpicture}
% define coordinates
\coordinate (O) at (0,0) ;
\coordinate (A) at (0,4) ;
\coordinate (B) at (0,-4) ;
\coordinate (C) at (-4,-4) ;
% media
\node[left] at (-2,-2) {House};
\node[right] at (-1,-2) {h};
\node[] at (1,-5) {d};
\node[] at (-1,2.25) {l};
\node[] at (1.5, -1.25) {\textbf{v}};
% axis
\draw[directed2, dash pattern=on5pt off3pt] (O) -- (-50:2.5) ;
\draw[dash pattern=on5pt off3pt] (-4,0) -- (4,0);
\draw[directed2] (2,3) -- (3,3);
\draw[directed2] (2,3) -- (2,2);
\node[] at (3.5, 3) {\textbf{i}};
\node[] at (2, 1.5) {\textbf{j}};
\draw[directed2] (3,-2) -- (3, -3);
\node[] at (3.5, -2.5) {\textbf{g}};
% lines
\draw[red,ultra thick,reverse directed] (O) -- (130:5.2);
\draw[black, directed2, reverse directed2] (0.25,0.25) -- (-3,4.25);
\draw[black, ultra thick] (O) -- (-90:4);
\draw[black, ultra thick] (C) -- (4,-4);
\draw[black, directed2, reverse directed2] (-0.5,-4) -- (-0.5,0);
\draw[black, directed2, reverse directed2] (0,-4.5) -- (2,-4.5);
\draw[red, ultra thick, directed, dash pattern=on5pt off3pt] plot [smooth] coordinates {(0,0) (0.65,-0.75) (1,-1.35) (2,-4)};
% angles
\draw (-1,0) arc (180:130:1);
\node[] at (335:-1.5) {$\alpha$};
\end{tikzpicture}
};
\framenode[35pt]{image}
\end{tikzpicture}
\end{document}
The effect is exactly what I want apart from the extra 1pt boarder at the edge of the fade - I'd be very grateful for any suggestions!
\begin{document}
, and that all[
,]
has been changed to\[
,\]
. Could you re-insert the code so that is fixed?