7

In TikZ one can fade objects using the fadings library. I want to fill and draw a circle and fade the whole object. However, the fade option only affects the filling.

MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}

\begin{document}
\begin{tikzpicture}
\filldraw[color = black, fill = blue, path fading = west] (0, 0) circle (1.0);
\end{tikzpicture}
\end{document}

Resulting TikZ image

Is there a way to fade the circle and the filling?

0

2 Answers 2

7

like this?

enter image description here

you shouldn't explicit declare draw color:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{fadings}

\begin{document}
\begin{tikzpicture}
\filldraw[very thick, fill = blue, path fading = west] (0, 0) circle (1.0);
\end{tikzpicture}
\end{document}
2
  • Yes, like this! Unfortunately, if I compile your code I get the same output as before, i.e., no faded circle. Did you compile it using pdflatex?
    – snem
    Dec 18, 2017 at 13:19
  • @snem, i compile width pdflatex (recent version of miktex and tikz). it also work with xelatex.
    – Zarko
    Dec 18, 2017 at 13:34
3

An idea is to use just fill command and create a bigger filled black circle bellow the next (blue). The blue will be placed over the black and the only visible part will become a surrounding on second circle:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}

\begin{document}
\begin{tikzpicture}
  \fill[black, path fading= west] (0, 0) circle (1.01);
  \fill[ fill = blue, path fading = west] (0, 0) circle (1.0);
\end{tikzpicture}
\end{document}

Output:

enter image description here

Improving the idea:

We can create a command that will reduce the inner circle size (radius) by (line width)/2 from the given radius and extend the outer circle radius by the same length. Then the the "visible line" (surrounding) of the circle will have the usual width and the result will be like Zarkos (better) solution.

PS: Just leaving the answer as an idea for similar problems... But Zarco's answer is the real answer (Mine can shade surrounding from right to left or top to bottom or rotated etc)

1
  • Interesting idea, maybe I'll come back to it, if other ways don't work.
    – snem
    Dec 18, 2017 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .