5

I'm trying to change the radial shading given:

\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@left@rule-0.03pt,\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}

What I want is to increase the radial shading so as the white fill be bigger.

The code shows:

a

Is there another kind of shading? Rectangular? How to do it?

  • And I put so many effort to provide the radial shading in there, now you want to drop it :-( – user31729 Apr 19 '17 at 23:24
  • @ChristianHupfer I don't want to drop it. I just want to see if I can increase the radius for the white fill; I do appreciate your posts! I wouldn't do nothing if it weren't for you! – Alejandro Apr 19 '17 at 23:26
  • Keyword: functionalshading. – Symbol 1 Apr 20 '17 at 0:54
  • You can define a custom shading to replace radial. – cfr Apr 20 '17 at 3:38
  • See tex.stackexchange.com/questions/286984/…. (Not the shading you want, but shows how to do it.) – cfr Apr 20 '17 at 3:39
3

The key to change a radial shading is \pgfdeclareradialshading, see the pgf manual at 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)
}

This defines a radial shading named ustanakradial, with some symbolic color names that are applied on the circles with relevant radii. The values of 10pt and 28pt are 'guesses' only. Don't exaggerate them.

The center of the shading is fixed here to \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@left@rule-0.03pt,\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}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.