[Tex/LaTex] setting a tikzset which has draw inside as style of a \node

tikz-pgftikz-styles

I need to get different color edges for my rectangular nodes.

I found this question
How do I set only one side of a tikz node's border color?

The \tikzset mentioned in the answer has input arguments and I don't know how to set them when used with \node.

I have tried to remove the arguments and set the styles but the all I get is a xetex in infinite loop.

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\tikzset{%
mynode/.style ={
       \draw[thick,red,line cap=butt,shorten <= -0.5\pgflinewidth,shorten >= 0.5\pgflinewidth] (a.south west) |- (a.north east);
       \draw[thick,blue,line cap=butt,shorten <= 0.5\pgflinewidth,shorten >= -0.5\pgflinewidth] (a.south west) -| (a.north east);

}
}
\begin{document}
\begin{figure}[ht]
\begin{center}
\begin{tikzpicture}
\tikzstyle{main}=[rectangle, minimum width = 30mm,minimum height = 50mm, thick, draw =black!80, node distance = 6mm]

    \node[main] (m)  {$A$ };
    \node[mynode] [right=of m] (x2) { $R$}; %commenting this line out with eliminate the infinite loop
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}

thanks in advance

Best Answer

if you looking for something like this

enter image description here

than the following MWE can be of help:

\documentclass[tikz,border=3mm]{standalone}
\newcommand\ppbb{path picture bounding box}
\tikzset{%
    mynode/.style = {rectangle, 
    path picture={%
    \draw[thick,red]    (\ppbb.south west) |- (\ppbb.north east);
    \draw[thick,blue]   (\ppbb.south west) -| (\ppbb.north east);
                },% end of path picture
                 },
        }% end of tikzset
\begin{document}
    \begin{tikzpicture}
\node (x2) [mynode] {$R$};    
    \end{tikzpicture}
\end{document}

edit: or slightly different appearance

enter image description here

obtained with the following (slightly modified) code:

\documentclass[tikz,border=3mm]{standalone}
\newcommand\ppbb{path picture bounding box}
\tikzset{%
    myline/.style={draw=#1, thick, shorten <=0.5\pgflinewidth},
    mynode/.style = {rectangle, 
    path picture={%
    \draw[myline=red]    (\ppbb.south west) |- (\ppbb.north east);
    \draw[myline=blue]   (\ppbb.north east) |- (\ppbb.south west);
                },% end of path picture
                 },
        }% end of tikzset
\begin{document}
    \begin{tikzpicture}
\node (x2) [mynode] {$R$};    
    \end{tikzpicture}
\end{document}