代码

代码

我想用tikz-pgf下面的图片来画画

在此处输入图片描述

欢迎提供建议和/或网站。谢谢!

编辑这是我的尝试:

\usepackage{tikz,tikz-inet,pgf,pgfplots}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}[font=\Large, thick]
    \node[quadro={8cm}]
        (mysquare)
        {};
    \node[quadro={4cm}, draw=none,  anchor=west, text centered] (mydashed) at 
(mysquare.west) {};
    \node[below left=.3cm and -.7cm of mysquare.south east] (descr1) {};
     \draw [line width=0.01mm] (-4,-4) -- (4,4);
     \draw [line width=0.01mm] (-4,-2) -- (2,4);
     \draw [line width=0.01mm] (-2,-4) -- (4,2);
     \draw [dashed, line width=0.01mm] (-2,-4) -- (-4,-2);
     \draw [dashed, line width=0.01mm] (2,4) -- (4,2);
\end{tikzpicture}
\end{document}

答案1

像这样?

在此处输入图片描述

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{decorations.pathmorphing,
                calligraphy,% had to be after lib. decorations.pathreplacing
                patterns.meta}

\begin{document}
    \begin{tikzpicture}[
BC/.style = {% Brace Calligraphic
            decorate,
            decoration={calligraphic brace, mirror,
            raise=3pt, amplitude=6pt},
            thick, pen colour={red}
            }
                        ]
\draw[|-|]  (0,8) |- (8,0)  node[pos=0.25, left] {L}
                            node[pos=0.75,below] {L};
\draw[dashed]   (0,8) -| (8,0);
     \draw  (0,0) -- (8,8);
     \draw  (0,2) -- (6,8);
     \draw  (0,2) -- (2,0);
     \draw  (2,0) -- (8,6);
%
\draw[dashed]   (6,8) -- (8,6)
                (6,8) |- (8,6)
                (0,2) -| (2,0);
%
\path[pattern={Lines[angle=120,distance={3pt},line width=0.2pt]},
      pattern color=gray] (0,0) -- (0,2) -- (6,8) -| (8,6) -- (2,0) -- (0,0);
%
\draw[BC]   (0,0) -- node[below=3mm] {$R$} (2,0);
\draw[BC]   (0,2) -- node[left=3mm]  {$R$} (0,0);
\draw[BC]   (8,8) -- node[above=3mm] {$R$} (6,8);
\draw[BC]   (8,6) -- node[right=3mm] {$R$} (8,8);
\end{tikzpicture}
\end{document}

答案2

使用 Asymptote 进行编译。

import patterns;
size(300);
unitsize(1cm);
transform t=shift((3,3));
pair A=(0,0),B=(1,0),C=(1,1),D=(0,1),
     tA=t*A,tB=t*B,tC=t*C,tD=t*D;
add("ahihidongoc",hatch(H=2mm,dir=dir(-65),gray));
fill(A--B--tB--tC--tD--D--cycle,pattern("ahihidongoc"));
pen dashed=linetype(new real[] {5,5});
draw(D--C--B,dashed); 
draw(tD--tC--tB--tA--cycle,dashed);
draw(D--A--B^^A--tC^^tD--D--B--tB^^D--(D.x,tD.y)^^B--(tB.x,B.y));
draw(tB--tD,dashed);
draw(tD--(D.x,tD.y),dashed);
draw(tB--(tB.x,B.y),dashed);
draw((D.x,tD.y)+(.05,0)--(D.x,tD.y)-(.05,0));
draw((tB.x,B.y)+(0,.05)--(tB.x,B.y)-(0,.05));
draw(Label("$R$",align=W),brace(A-.1,D-.1));
draw(Label("$R$",align=S),brace(B-(0,.1),A-(0,.1)));
draw(Label("$R$",align=N),brace(tD+(0,.1),tC+(0,.1)));
draw(Label("$R$",align=E),brace(tC+(.1,0),tB+(.1,0)));
label("$L$",(D.x,tD.y)--A);
label("$L$",A--(tB.x,B.y));
shipout(bbox(2mm,invisible));

在此处输入图片描述

答案3

利用对称性的解决方案tkz-euclide。还允许用户更改长度 L 和 R。我可能可以直接绘制形状,但我更喜欢只反映点。

在此处输入图片描述

代码

\documentclass{standalone}
\usepackage{tkz-euclide} 
\usetkzobj{all}
\usetikzlibrary{decorations.pathmorphing,
                calligraphy,% had to be after lib. decorations.pathreplacing
                }

\begin{document}

\begin{tikzpicture}[
    BC/.style = {% Brace Calligraphic
                decorate,
                decoration={calligraphic brace, mirror,
                raise=3pt, amplitude=6pt},
                thick, pen colour={red}
                }
                        ]
\tkzInit[xmin=-1, ymin=-1, ymax=9, xmax=9] \tkzClip
\def\L{8} \pgfmathsetmacro{\R}{0.25*\L}

\tkzDefPoints{0/0/O, 0/\R/R1, \R/\R/C, 0/\L/L1}

\tkzDefPointsBy[reflection=over O--C](R1,L1){R2,L2}
\tkzDefPointsBy[reflection=over L1--L2](O,C,R1,R2){O',C',R1',R2'}

\path[pattern={north west lines}, pattern color=gray] 
      (O) -- (R1) -- (R1') -| (O') -- (R2') -- (R2);

\tkzDrawSegments(O,O' R1,R1' R2,R2' R1,R2 O,L1 O,L2)
\tkzDrawSegments[dashed](L1,O' O',L2 R1,C C,R2  R1',C' C',R2' R1',R2')

\draw[BC]   (O)   -- node[below=3mm] {$R$} (R2);
\draw[BC]   (R1)  -- node[left=3mm]  {$R$} (O);
\draw[BC]   (O')  -- node[above=3mm] {$R$} (R1');
\draw[BC]   (R2') -- node[right=3mm] {$R$} (O');

\tkzLabelSegment[left](O, L1){L} \tkzLabelSegment[below](O, L2){L}
\end{tikzpicture}

\end{document}

相关内容