偶然间看到了1210的问题无人问津,故而有此一问.请问,应该如何定制如下图的文本框,我苦思冥想良久,考虑了tcolorbox结合tkiz以及纯tikz这两种方案,都没办法实现,太棘手了,这是我能力问题,我的tikz太差了,不会用,故而想请问专家,这个文本框用latex能定制成功吗?我是实在没办法了,但是又很想要这个盒子,故而,我想有偿定制这个盒子,希望有能力的专家或者大佬能帮帮我!原盒子是原神游戏的弹窗,故而应该使用的HTML语言,所以真的很想知道tikz集合tcolorbox的实现方式.这个盒子典雅端庄,充满了中国文化气息,确实让我一眼就爱上了,虽然我不玩游戏.
使用 tcolorbox
,实现了一部分,四个星的内部还要着色有点麻烦。
\documentclass{ctexart}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, fadings, decorations.markings}
\usepackage{pgfornament}
\usepackage[many]{tcolorbox}
\makeatletter
\definecolor{framegolden}{HTML}{FFA500}
\definecolor{framegray}{HTML}{302E22}
\newdimen\ys@frame@linewidth
\newdimen\ys@frame@radius
\pgfdeclarehorizontalshading{ys@fade@circle}{500bp}
{color(0bp)=(pgftransparent!100); color(25bp)=(pgftransparent!100);
color(45bp)=(pgftransparent!0); color(55bp)=(pgftransparent!0);
color(75bp)=(pgftransparent!100); color(100bp)=(pgftransparent!100)}
\pgfdeclarefading{ys circle}{\pgfuseshading{ys@fade@circle}}
\tcbset{
ys/frame/line width/.code={\pgfmathsetlength\ys@frame@linewidth{#1}},
ys/frame/line width=1.4pt,
ys/frame/radius/.code={\pgfmathsetlength\ys@frame@radius{(#1)*1em}},
ys/frame/radius=2,
ys/frame style/.style={
interior code={
% 外框
\path[draw=framegolden,fill=framegray,fill opacity=.2,line width=\ys@frame@linewidth]
([xshift=\ys@frame@radius]frame.north west)--([xshift=-\ys@frame@radius]frame.north east)
arc(-180:-90:\ys@frame@radius)--
([yshift=-\ys@frame@radius]frame.north east)--([yshift=\ys@frame@radius]frame.south east)
arc(90:180:\ys@frame@radius)--
([xshift=-\ys@frame@radius]frame.south east)--([xshift=\ys@frame@radius]frame.south west)
arc(0:90:\ys@frame@radius)--
([yshift=\ys@frame@radius]frame.south west)--([yshift=-\ys@frame@radius]frame.north west)
arc(-90:0:\ys@frame@radius)--cycle;
% 内线
\path[draw=framegolden,line width=.8\ys@frame@linewidth,line cap=round]
([xshift=\ys@frame@radius+2\ys@frame@linewidth,yshift=-1ex]frame.north west)
--([xshift=-\ys@frame@radius-2\ys@frame@linewidth,yshift=-1ex]frame.north east)
([yshift=-\ys@frame@radius-2\ys@frame@linewidth,xshift=-1ex]frame.north east)
--([yshift=\ys@frame@radius+2\ys@frame@linewidth,xshift=-1ex]frame.south east)
([xshift=\ys@frame@radius+2\ys@frame@linewidth,yshift=1ex]frame.south west)
--([xshift=-\ys@frame@radius-2\ys@frame@linewidth,yshift=1ex]frame.south east)
([yshift=-\ys@frame@radius-2\ys@frame@linewidth,xshift=1ex]frame.north west)
--([yshift=\ys@frame@radius+2\ys@frame@linewidth,xshift=1ex]frame.south west);
% 四角
\path[draw=framegolden,line width=1.5\ys@frame@linewidth,line cap=round]
([xshift=\ys@frame@radius-2.7\ys@frame@linewidth,yshift=-1ex]frame.north west)
--([xshift=1ex,yshift=-1ex]frame.north west)
--([xshift=1ex,yshift=-\ys@frame@radius+2.7\ys@frame@linewidth]frame.north west)
([xshift=-\ys@frame@radius+2.7\ys@frame@linewidth,yshift=-1ex]frame.north east)
--([xshift=-1ex,yshift=-1ex]frame.north east)
--([xshift=-1ex,yshift=-\ys@frame@radius+2.7\ys@frame@linewidth]frame.north east)
([xshift=-\ys@frame@radius+2.7\ys@frame@linewidth,yshift=1ex]frame.south east)
--([xshift=-1ex,yshift=1ex]frame.south east)
--([xshift=-1ex,yshift=\ys@frame@radius-2.7\ys@frame@linewidth]frame.south east)
([xshift=\ys@frame@radius-2.7\ys@frame@linewidth,yshift=1ex]frame.south west)
--([xshift=1ex,yshift=1ex]frame.south west)
--([xshift=1ex,yshift=\ys@frame@radius-2.7\ys@frame@linewidth]frame.south west);
},
segmentation code={
\draw[color=framegolden,path fading=ys circle]
([xshift=5\ys@frame@radius]segmentation.west) to[ornament=88]([xshift=-5\ys@frame@radius]segmentation.east);
},
},
ys style/.style={frame hidden,ys/frame style},
}
\makeatother
\begin{document}
\begin{tcolorbox}[enhanced,ys style]
\centering
\medskip
{\zihao{-3}\bfseries 引蝶之章\ 第一幕}
\par\bigskip
{\zihao{2}\bfseries 奈何蝶飞去}
\par\medskip
\tcblower
\centering
\tcbox[enhanced,frame hidden,top=0pt,bottom=0pt,left=4.5em,right=4.5em,
interior code={\path[fill=framegolden,path fading=ys circle](interior.north west) rectangle (interior.south east);},
]{已开启}
\end{tcolorbox}
\end{document}
tikz 画了一下,可以自己搬到 tcolorbox 里面
\documentclass[margin=.5cm]{standalone}
\usepackage{tikz,ctex}
\usepackage{fontawesome5}
\usetikzlibrary{arrows.meta,calc}
\begin{document}
\begin{tikzpicture}[thick]
\draw[] (0.4,0) arc(0:90:0.4) -- (0,1.6) arc(-90:0:0.4) --(5.6,2) arc(180:270:0.4) --(6,0.4) arc(90:180:0.4) --cycle;
\foreach \x in {(45:0.382),($(0,2)+(-45:0.382)$),($(6,2)+(225:0.382)$),($(6,0)+(135:0.382)$)}
{
\node[inner sep=0pt,] at \x
{
\begin{tikzpicture}
\draw[fill=white,thick,rotate=45,line join=round,x=0.12cm,y=0.12cm] (1,0) to [out=180,in=-90] (0,1) to [out=-90,in=0] (-1,0) to[out=0,in=90] (0,-1) to[out=90,in=180] (1,0)--cycle;
\end{tikzpicture}
};
}
\draw[] (0.3,0.075) -| (0.075,0.3);
\draw[] (0.075,1.7) |- (0.3,2-0.075);
\draw[] (5.7,2-0.075) -| (6-0.075,1.7);
\draw[] (6-0.075,0.3) |- (5.7,0.075);
\draw[] (0.075,0.5) -- (0.075,1.5);
\draw[] (0.5,2-0.075) -- (5.5,2-0.075);
\draw[] (6-0.075,1.5) -- (6-0.075,0.5);
\draw[] (5.5,0.075) -- (0.5,0.075);
\node[font=\kaishu\bfseries] at (3,1.1) {奈何蝶飞去};
\node[font=\kaishu\bfseries,scale=0.6] at (3,1.5) {引蝶之章 第一幕};
\draw[line cap=round] (2,0.8) -- (4,0.8)node[midway,fill=white,inner sep=2pt,scale=0.6]{\faGg};
\node[font=\kaishu\bfseries,scale=0.6] at (3,0.45){已开启};
\end{tikzpicture}
\end{document}
另外,楼上@u40 啸行的答案很有参考性!!!
谢谢大师,我试一下!
老师,请问能把四周的几四个星星实现吗?如果能,那就完美了
您的代码太复杂,我不知道么加星星,所以请您好人帮到底,加一下那四颗星星,谢谢专家!
当输入文本内容时,错误Dimension too large.
<recently read> pgf@pt@y
无法生成pdf
目前的问题是,
1.不支持跨页,一旦使用breakable选项且内容超出一页纸,就会回归默认样式.
2.四角的星星,我尝试了下用arc,但是无论怎么调整参数,都与原图相距甚远,故而请求专家加上四颗星星,如果我满意了,可以支付金钱.
目前的效果
%跨页
@u45041 将
\makeatletter
与\makeother
之间的部分删除,用这个 样式文件 替换即可。其余部分保持原样,另外,只需
\usetikzlibrary{fadings}
,其它库不需要。至于你说的报错,我没有遇到,提供更详细的 MWE。
@u45041