5

From page 195 of the tcolorbox manual, I can apply a "glow" effect on a circle:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{shadows}


\begin{document}
\begin{tcolorbox}[enhanced,width=2.5cm,
square,circular arc,
halign=center,valign=center,
colback=red!5!white,colframe=red!75!black,
frame style={circular glow={fill=red}} ]
tcolorbox
\end{tcolorbox}


\end{document}

I'm trying to set up a style with a "rectangular glow". When perusing the tikz manual, I found the following settings, which I guess are supposed to apply to a circular glow and therefore be somehow adaptable to a rectangular shape:

shadow scale=1.25, shadow xshift=0pt, shadow yshift=0pt,
fill=black, path fading={circle with fuzzy edge 15 percent},
every shadow,

Is there a way to adapt (presumably those settings) so that they work in a rectangle such as to generate a result like this one? (Just an example, not exactly the same colors.)

enter image description here

7

You might be interested in shadows.blur. There are many options how you could customize this, see texdoc pgfblur.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{shadows.blur}

\begin{document}
\begin{tcolorbox}[enhanced,width=2.5cm,
square,%circular arc,
halign=center,valign=center,
colback=red!5!white,colframe=red!75!black,
frame style={ blur shadow={shadow blur extra rounding,
shadow blur steps=10,
shadow xshift=0ex,shadow yshift=0ex,shadow blur radius=1.5ex}} 
]
tcolorbox
\end{tcolorbox}
\end{document}

enter image description here

Or

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{shadows.blur}

\begin{document}
\begin{tcolorbox}[enhanced,width=2.5cm,
square,%circular arc,
halign=center,valign=center,
colback=red!5!white,colframe=red!75!black,
frame style={ blur shadow={shadow blur steps=10,shadow opacity=40,
shadow xshift=0ex,shadow yshift=0ex,shadow scale=1.05}} 
]
tcolorbox
\end{tcolorbox}
\end{document}

enter image description here

There are many options and many many ways to combine them.

The glowing effect can be achieved with Percusse's deleted answer.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{shadows.blur}
\makeatletter
\tikzset{render blur shadow/.code={\pgfbs@savebb%
\pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
\pgfbs@compute@shadow@bbox%
\pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
\pgfbs@apply@canvas@transform%
\colorlet{pstb@shadow@color}{white!\pgfbs@opacity!#1}%
\pgfdeclarefading{shadowfading}{\pgfbs@paint@fading}%
\pgfsetfillcolor{#1}%
\pgfsetfading{shadowfading}{\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
\pgfbs@usebbox{fill}%
\pgfbs@restorebb%
},render blur shadow/.default=shadowcolor}
\colorlet{shadowcolor}{black}
\makeatother
\begin{document}
\pagecolor{black}
\colorlet{shadowcolor}{white}
\begin{tcolorbox}[enhanced,width=2.5cm,
square,halign=center,valign=center,
colback=black,colframe=black,colupper=white,
frame style={blur shadow={shadow blur steps=10,
shadow xshift=0ex,shadow yshift=0ex,shadow blur radius=1.5ex}} 
]
\sffamily I am a glowing tcolorbox
\end{tcolorbox}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy