bloco tikz dividido diagonalmente

bloco tikz dividido diagonalmente

Estou tentando desenhar o seguinte diagrama:

insira a descrição da imagem aqui

O que eu poderia fazer até agora:

insira a descrição da imagem aqui

O código:

\documentclass[tikz,border=20pt]{standalone}

\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{babel}
\usetikzlibrary{calc,arrows.meta,patterns,backgrounds}
\usetikzlibrary{shapes.multipart}

\tikzstyle{block} = [draw, rectangle, rounded corners, minimum size=1cm, text centered]
\tikzstyle{transform} = [draw, block, path picture={\draw (path picture bounding box.south west)--(path picture bounding box.north east);}]
\tikzstyle{state} = [draw, rectangle split,rectangle split parts=2,rounded corners, minimum size=1cm, text centered]

\begin{document}

\begin{tikzpicture}
    \node at (0.0,0.0) [transform](inverter){$qd0$};
    \node at (2.0,0.0) [state] {$qd0$ \nodepart{two} $abc$};
\end{tikzpicture}

\end{document}

Eu preciso de ajuda :)

Responder1

Os cálculos são básicos,

insira a descrição da imagem aqui

e se você considerar usar um picformato de nó em vez de um formato de nó completo, a implementação também será direta. O parâmetro livre é considerado a altura da forma completa. A largura é então calculada de forma que a diagonal não corte nenhum dos nós (onde a “distância de segurança” é dada por inner sep).

\documentclass{article}
\usepackage{tikz}
\tikzset{pics/dbox/.style 2 args={code={%
\pgfmathsetmacro{\w}{max((width("#1")+2*\pgfkeysvalueof{/pgf/inner xsep})/(\pgfkeysvalueof{/tikz/dbox/height}-2*\pgfkeysvalueof{/pgf/inner xsep}-height("#1")),%
(width("#2")+2*\pgfkeysvalueof{/pgf/inner xsep})/(\pgfkeysvalueof{/tikz/dbox/height}-2*\pgfkeysvalueof{/pgf/inner xsep}-height("#2")))*\pgfkeysvalueof{/tikz/dbox/height}}
\path[pic actions] (-\w*1pt/2,-\pgfkeysvalueof{/tikz/dbox/height}/2) 
 node[above right] {#2}
 rectangle
(\w*1pt/2,\pgfkeysvalueof{/tikz/dbox/height}/2)
 node[below left] {#1} (-\w*1pt/2,\pgfkeysvalueof{/tikz/dbox/height}/2)
 -- (\w*1pt/2,-\pgfkeysvalueof{/tikz/dbox/height}/2) ;
}},dbox/.cd,height/.initial=2cm}
\begin{document}
\begin{tikzpicture}
 \path pic[draw]{dbox={abc}{xyzuv}} (3,0) pic[draw,blue]{dbox={abc}{xyz}}
 (6,0) pic[draw,red,thick]{dbox={abcdefgh}{xyz}};
\end{tikzpicture}
\end{document}

insira a descrição da imagem aqui

Você pode dar a esta forma as âncoras usuais com um truque simples: basta transformá-la em um nó usando fit. Os nomes devem então ser definidos usando dbox/name=<name>.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\tikzset{pics/dbox/.style 2 args={code={%
\pgfmathsetmacro{\w}{max((width("#1")+2*\pgfkeysvalueof{/pgf/inner xsep})/(\pgfkeysvalueof{/tikz/dbox/height}-2*\pgfkeysvalueof{/pgf/inner xsep}-height("#1")),%
(width("#2")+2*\pgfkeysvalueof{/pgf/inner xsep})/(\pgfkeysvalueof{/tikz/dbox/height}-2*\pgfkeysvalueof{/pgf/inner xsep}-height("#2")))*\pgfkeysvalueof{/tikz/dbox/height}}
\path (-\w*1pt/2,-\pgfkeysvalueof{/tikz/dbox/height}/2) 
 node[above right] (bl) {#2}
 rectangle
(\w*1pt/2,\pgfkeysvalueof{/tikz/dbox/height}/2)
 node[below left] (tr) {#1};
 \node[pic actions,inner sep=0pt,fit=(bl)(tr),path picture={\path[pic actions]
 (path picture bounding box.north west)
 -- (path picture bounding box.south east);}] 
 (\pgfkeysvalueof{/tikz/dbox/name}){};
}},dbox/.cd,height/.initial=2cm,name/.initial=}
\begin{document}
\begin{tikzpicture}
 \path pic[draw]  {dbox={abc}{xyzuv}} (3,0) 
 pic[draw,blue,dbox/name=A] {dbox={abc}{xyz}}
 (6,0) pic[draw,red,thick,rounded corners,dbox/name=B] {dbox={abcdefgh}{xyz}};
 \draw[stealth-stealth] (A.north) to[out=80,in=100](B.100);
\end{tikzpicture}
\end{document}

insira a descrição da imagem aqui

Responder2

Você está procurando um código simples como este? Pense geometricamente: apenas um quadrado (em escala) com algum texto dentro que pode ser ajustado manualmente.

insira a descrição da imagem aqui

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[xscale=.8,yscale=1.5]
\draw[thick] (1,0)--(0,1) (0,0) rectangle (1,1);
\path[magenta] 
(0,0)+(.3,.3)    node{$dq$}
(1,1)+(-.4,-.15) node{$abc$};
\end{tikzpicture}

\begin{tikzpicture}[xscale=2.5,yscale=1.5]
\draw[thick] (1,0)--(0,1) (0,0) rectangle (1,1);
\path[blue] 
(0,0)+(.2,.15)    node{$TikZ$}
(1,1)+(-.4,-.15)  node{$Asymptote$};
\end{tikzpicture}

\end{document}

informação relacionada