我正在尝试改变给定的径向阴影:
\documentclass[10pt]{article}
\usepackage{blindtext}
\usepackage{XCharter}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[x11names,svgnames,dvipsnames]{xcolor}
\usepackage[tikz]{bclogo}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usepackage[most]{tcolorbox}
\definecolor{recyclecolor}{RGB}{154,84,158}
\makeatletter
\tcbset{%
decoration downshift/.store in={\decoration@downshift},
decoration radius/.store in={\decoration@radius},
decoration recycle radius/.store in={\decoration@recyclecircleradius},
decoration dot radius/.store in={\decoration@dotradius},
decoration content/.store in={\decoration@content},
decoration colour/.store in={\decoration@colour},
}
\tcbset{recyclebox/.style={decoration radius=0.5cm,decoration downshift=-0.5cm}}
\tcbset{learnthisbox/.style={%
decoration radius=0.5cm,
decoration downshift=-0.5cm,
decoration content={\bclampe},
decoration colour=blue}
}
\newtcolorbox{recyclebox}[2][]{%
recyclebox,
decoration recycle radius={0.6*\decoration@radius},
decoration dot radius={0.04*\decoration@radius},
decoration colour=recyclecolor,
breakable,
enhanced jigsaw,
leftrule=1.5pt,
fonttitle={\bfseries\large},
title={\MakeUppercase{Recycle!}},
#1,
attach title to upper={{\bfseries\large #2}\par},
interior style={shading=radial,inner color=tcbcol@back!0,outer color=tcbcol@back},
underlay unbroken and first={%
\draw[tcbcol@frame,line width=\kvtcb@left@rule,fill=tcbcol@back] ($(frame.north west) + (\kvtcb@[email protected],\decoration@downshift)$) arc [start angle=90.0,end angle=270.0,radius=\decoration@radius] node[midway,inner sep=0pt] (dottedcircle) {};
\foreach \x in {1,...,12} {%
\draw[fill=tcbcol@back,opacity=4*(\x/12),tcbcol@frame] ($(dottedcircle) + (\decoration@radius,0cm)+(120+\x*30:\decoration@recyclecircleradius)$) circle (\decoration@dotradius);
};
},
colframe={\decoration@colour},
colback={tcbcol@frame!30},
coltitle={tcbcol@frame!150},
}
\makeatother
\begin{document}
\begin{recyclebox}[decoration radius={0.4cm},decoration dot radius=0.03cm]{~title}
\blindtext[1]
\end{recyclebox}
\end{document}
我想要的是增加径向阴影以使白色填充更大。
代码显示:
还有其他类型的阴影吗?矩形的?怎么做?
答案1
更改径向阴影的关键是\pgfdeclareradialshading
,请参阅pgf
手册109.2.2 Radial Shadings
\pgfdeclareradialshading[inner color,middle color, outer color]{ustanakradial}{\pgfpoint{0.0cm}{0.0cm}}%
{ color(0)=(inner color);
color(10bp)=(middle color);
color(28bp)=(outer color)
}
这定义了一个名为 的径向阴影ustanakradial
,其中包含一些符号颜色名称,这些名称应用于具有相关半径的圆。10pt
和的值28pt
只是“猜测”。不要夸大它们。
阴影的中心固定在这里\pgfpoint{0cm}{0cm}
。
\documentclass[10pt]{article}
\usepackage{blindtext}
\usepackage{XCharter}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[x11names,svgnames,dvipsnames]{xcolor}
\usepackage[tikz]{bclogo}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usepackage[most]{tcolorbox}
\definecolor{recyclecolor}{RGB}{154,84,158}
\makeatletter
\tikzset{%
ustanakradial inner color/.code={\colorlet{inner color}{#1}},
ustanakradial middle color/.code={\colorlet{middle color}{#1}},
ustanakradial outer color/.code={\colorlet{outer color}{#1}},
}
\tcbset{%
decoration downshift/.store in={\decoration@downshift},
decoration radius/.store in={\decoration@radius},
decoration recycle radius/.store in={\decoration@recyclecircleradius},
decoration dot radius/.store in={\decoration@dotradius},
decoration content/.store in={\decoration@content},
decoration colour/.store in={\decoration@colour},
}
\tcbset{recyclebox/.style={decoration radius=0.5cm,decoration downshift=-0.5cm}}
\tcbset{learnthisbox/.style={%
decoration radius=0.5cm,
decoration downshift=-0.5cm,
decoration content={\bclampe},
decoration colour=blue}
}
\pgfdeclareradialshading[inner color,middle color, outer color]{ustanakradial}{\pgfpoint{0.0cm}{0.0cm}}%
{ color(0)=(inner color);
color(10bp)=(middle color);
color(28bp)=(outer color)
}
\newtcolorbox{recyclebox}[2][]{%
recyclebox,
decoration recycle radius={0.6*\decoration@radius},
decoration dot radius={0.04*\decoration@radius},
decoration colour=recyclecolor,
breakable,
enhanced jigsaw,
leftrule=1.5pt,
fonttitle={\bfseries\large},
title={\MakeUppercase{Recycle!}},
#1,
attach title to upper={{\bfseries\large #2}\par},
interior style={shading=ustanakradial,ustanakradial inner color=tcbcol@back!0,ustanakradial middle color=tcbcol@back!0,ustanakradial outer color=tcbcol@back},
underlay unbroken and first={%
\draw[tcbcol@frame,line width=\kvtcb@left@rule,fill=tcbcol@back] ($(frame.north west) + (\kvtcb@[email protected],\decoration@downshift)$) arc [start angle=90.0,end angle=270.0,radius=\decoration@radius] node[midway,inner sep=0pt] (dottedcircle) {};
\foreach \x in {1,...,12} {%
\draw[fill=tcbcol@back,opacity=4*(\x/12),tcbcol@frame] ($(dottedcircle) + (\decoration@radius,0cm)+(120+\x*30:\decoration@recyclecircleradius)$) circle (\decoration@dotradius);
};
},
colframe={\decoration@colour},
colback={tcbcol@frame!30},
coltitle={tcbcol@frame!150},
}
\makeatother
\begin{document}
\begin{recyclebox}[decoration radius={0.4cm},decoration dot radius=0.03cm]{~title}
\blindtext[1]
\end{recyclebox}
\end{document}