4

I am doing a job that is simple but must be done thousands of times. I want to create a command whose inputs are two coordinates ( \coordinate (A) at (0,0); and B at \coordinate (B) at (3,6); for example), and four colors. The desired output is a path between the coordinates that is decorated with this figure that I show you below

decoration

I have tried, but the command is beyond my knowledge of Tikz. Also below I show you some handmade examples with the result that I need.

examples

The base code is

\documentclass[border=5]{standalone}
\usepackage{tikz}
\usetikzlibrary {decorations.markings}
\begin{document}
    \begin{tikzpicture}
        
        \begin{scope}
            \draw (-8,0)-- (8,0);       
            \draw[fill][line width=0.5pt, ](-2,-1)rectangle (2, 1);
            \draw[red] (-1.5, 1)-- ++ (0,-2);
            \draw[blue] (-1, 1)-- ++ (0,-2);
            \draw[yellow] (-0.5, 1)-- ++ (0,-2);
            \draw[orange] (-0, 1)-- ++ (0,-2);
        \end{scope}
    \end{tikzpicture}
\end{document}

Thank you very much for any help.

1 Answer 1

4

You could do this with a path picture in a sloped node. You can adjust minimum height and minimum width, and then also adjust the (relative) coordinates of the four lines.

enter image description here

\documentclass{article}

\usepackage{tikz}
\tikzset{
    mynode/.style n args={4}{sloped, allow upside down, thick, fill, minimum height=2cm, minimum width=4cm, path picture={
        \draw[#1](-1.5,-1)--(-1.5,1);
        \draw[#2](-1,-1)--(-1,1);
        \draw[#3](-.5,-1)--(-.5,1);
        \draw[#4](0,-1)--(0,1);}
    }
}

\begin{document}

\begin{tikzpicture}
\draw[thick](0,0)--node[mynode={blue}{white}{orange}{yellow}]{}(8,3);
\end{tikzpicture}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .