1

I have a /.pic in tikz, but I can not assign a name for that. I want to draw some block in the right of that pic. I have attached the figure which I want. Could you help me with how to solve that? thanks. Here is the figure I want https://imgur.com/a/EiF7THa

\usetikzlibrary{positioning,arrows.meta,calc}
\begin{document}
\tikzset
{myTrapezium/.pic ={\draw [fill=magenta!50] (0,0) -- (0,\b) -- (\a,\c) -- (\a,-\c) -- (0,-\b) -- cycle ;
\coordinate (-center) at (\a/2,0);
\coordinate (-out) at (\a,0);},
block/.style={draw, fill=blue!15, rectangle, minimum height=2em, minimum width=2.1em, font = \Large},
dot/.style = {circle,fill, inner sep=0.01mm, fill=black!15, node contents={}},
  myArrows/.style={line width=2mm, red,-{Triangle[length=1.5mm,width=5mm]},shorten >=2pt, shorten <=2pt, }}

    \def\a{2}  % width of trapezium
    \def\b{.9} % small height of trapezium
    \def\c{2}  % tall height of trapezium

\begin{tikzpicture}
[node distance=1mm, % space between drawn parts
every node/.style={align=center},]
 \coordinate (start) at (-4.08,4.5);
 \node[block, below = 8cm of start] (Alpha) {$x$};
 \node[block, below = 2cm of Alpha] (zed) {$y$};
  \pic (left)[right=3cm of Alpha, rotate=180] {myTrapezium} ;
\node at (left-center) {a} ;
  \def\d{.9}
  \coordinate (u) at (\d,0);
\end{tikzpicture}
\end{document}```
1

Why not use the already provided trapezium shape?

\documentclass[tikz, border=2mm]{standalone}

\usetikzlibrary{positioning, arrows.meta, calc, shapes.geometric}
\begin{document}
\begin{tikzpicture}
    \node[trapezium, draw, minimum height=2cm, fill=magenta!50, shape border rotate=270] (a) {a};
    \draw ($(a.top left corner)!.2!(a.top right corner)$)--++(0:1cm) node[right, draw] {1};
    \draw ($(a.top left corner)!.8!(a.top right corner)$)--++(0:1cm) node[right, draw] {2};
    \draw ($(a.bottom left corner)!.2!(a.bottom right corner)$)--++(180:1cm) node[left, draw] {3};
    \draw ($(a.bottom left corner)!.8!(a.bottom right corner)$)--++(180:1cm) node[left, draw] {4};
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thank you so much. – Sadcow Mar 1 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.