0

Consider the code

\documentclass{book}
% Code can be compiled with Pdflatex or Xelatex
\usepackage{tikz} 
\usetikzlibrary{fadings}
\definecolor{darkamber}{RGB}{213,54,0}
\definecolor{sunriseyellow}{RGB}{255,219,0}
\definecolor{topaz}{RGB}{255,200,124}

\begin{document}
\thispagestyle{empty}

\tikzfading[name=fade out, inner color=transparent!0,
outer color=transparent!100]
\tikzset{
  star/.style={darkamber, fill=white, path fading=fade out}
}
\begin{tikzpicture}
  \clip (-3, -3) rectangle (3, 3);
  \draw[black, shading=mradial, inner color=topaz, 
  middle color=darkamber!60!sunriseyellow, outer color=darkamber]
  (-3, -3) rectangle (3, 3);
\end{tikzpicture} 

\end{document}

which produces the circular radial effect

enter image description here

QUESTION: Instead of having the radial fading encompass an entire circle, I would like to display that portion of the radial circle ranging from -60 degrees to 240 degrees (i.e., I would like to remove the radial effect of the above image that covers 240-300 degrees from the solid darkamber background). How may I do this?

Thank you.

3
  • Like this? \draw[black, shading=mradial, inner color=topaz, middle color=darkamber!60!sunriseyellow, outer color=darkamber] (-60:2cm) arc (-60:240:2cm) -- (0,0) -- cycle;
    – Sigur
    Jun 20 at 15:49
  • @Sigur Not exactly. When I replace my \draw[black, shading ...; command with yours, I get the portion of the circular fading removed that I want, but so is the square darkamber solid background also removed, which I don't want to happen. Basically, I want to remove the angular portion of the fading which you did---but replace it with a solid darkamber "pie piece" and keep everything else the same. Jun 20 at 16:31
  • Why don't you just draw and fill this solid portion you want after the shading?
    – SebGlav
    Jun 21 at 7:50

1 Answer 1

1

As a follow up to my above comment, here's the simplest solution that came to my mind. Just draw the pie piece above the shading.

shading but not all

\documentclass{book}
% Code can be compiled with Pdflatex or Xelatex
\usepackage{tikz} 
\usetikzlibrary{fadings}
\definecolor{darkamber}{RGB}{213,54,0}
\definecolor{sunriseyellow}{RGB}{255,219,0}
\definecolor{topaz}{RGB}{255,200,124}

\begin{document}
\thispagestyle{empty}

\tikzfading[name=fade out, inner color=transparent!0,
outer color=transparent!100]
\tikzset{
  star/.style={darkamber, fill=white, path fading=fade out}
}
\begin{tikzpicture}
  \clip (-3, -3) rectangle (3, 3);
  \draw[black, shading=mradial, inner color=topaz, 
  middle color=darkamber!60!sunriseyellow, outer color=darkamber]
  (-3, -3) rectangle (3, 3);
  \fill[darkamber] (240:4cm) arc (240:300:4cm) -- (0,0) -- cycle; % <---- The pie piece
\end{tikzpicture} 

\end{document}
2
  • 1
    Thank you for your answer. I thought perhaps there might be a way to restrict the "radial sweep" directly; but this gets the job done. Jun 21 at 12:05
  • There is a way to restrict, but you need to fill the background before. In any case, you'll have to do it with two commands.
    – SebGlav
    Jun 21 at 15:45

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.