盒子半填充顏色

盒子半填充顏色

我正在嘗試在 tikz 中製作這個圖形,但我不知道它是如何工作的。我嘗試過

\tcbox[sharp corners, boxsep=5mm, boxrule=.5mm]

但我無法用顏色填滿兩側。

在此輸入影像描述

答案1

如果你更喜歡tcolorbox

\documentclass{article} 
\usepackage[most]{tcolorbox}

\begin{document}
\begin{tcolorbox}[
    sharp corners, boxsep=5mm, boxrule=.5mm,
    colback=brown, width=5cm, 
    halign upper=left, valign upper=top,
    halign lower=right, valign lower=bottom,
    enhanced, segmentation empty,
    underlay = {
        \begin{tcbclipinterior}
            \filldraw[fill=orange, draw=tcbcolframe, line width=.5mm] (frame.south west)--++(90:1cm) to [out=5, in=185] ([yshift=-1cm]frame.north east)|-cycle;
        \end{tcbclipinterior}
}]
    A
    \tcblower
    B
\end{tcolorbox}
\end{document}

在此輸入影像描述

答案2

歡迎來到 TeX.SE。從下次開始嘗試加入一個可編譯的MWE,這樣會吸引更多的用戶來回答你的問題。

您可以從(邊框)開始:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
    \filldraw [black] (3, 2) --(3,0)--(0,0) plot [smooth, tension=2] coordinates { (0,0) (1,1) (2, 1) (3, 2)};
    \filldraw [red] (3, 2) --(0,2)--(0,0) plot [smooth, tension=2] coordinates { (0,0) (1,1) (2, 1) (3, 2)};
    \draw[yellow,  thick] (0,0)--(0,2)--(3,2)--(3,0)--cycle;
    \end{tikzpicture}
\end{document}

要得到:

在此輸入影像描述

剩下的客製化工作我就留給你來做;)

相關內容