2

I would like to shade the region between the two geodesics (a,b) and (b,c) in such a way that the color fades as the region becomes wider. This is the code

\documentclass{article}

\begin{document}

\begin{tikzpicture}

%circle

\draw (0,0) circle [radius=2];

% b

\filldraw (0,2) circle [radius=1pt];

\draw (0,2.3) node {$b$};

%a

\filldraw (-1,-1.73) circle [radius=1pt];

\draw (-1.2,-1.8) node {$a$};

%c

\filldraw (2,0) circle [radius=1pt];

\draw (2.3,0) node {$c$};

%geodesic (b,c)

\draw[name path=A, xshift=2cm, yshift=2cm, domain=180:270] plot(\x:2);

%geodesic (a,b)

\draw[name path=B, xshift=-6cm, yshift=1.6cm, domain=326:364] plot(\x:6);

\end{tikzpicture}

\end{document}

Can anybody tell me how to do it, please? Thanks a lot!

2

2 Answers 2

2

The following gives my solution, hoping it will satisfy your requirement. The basic idea is ti use \fill to fill the region consisted of a -- geodesics (a,b) -- b -- geodesics (b, c) -- c -- geodesics (c, a) -- a.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations,decorations.pathmorphing}
\usetikzlibrary{fadings}

\begin{document}

\begin{tikzpicture}

%circle

\draw (0,0) circle [radius=2];

% b

\filldraw (0,2) circle [radius=1pt];

\draw (0,2.3) node {$b$};

%a

\filldraw (-1,-1.73) circle [radius=1pt];

\draw (-1.2,-1.8) node {$a$};

%c

\filldraw (2,0) circle [radius=1pt];

\draw (2.3,0) node {$c$};

\fill [path fading=south,top color=green!80!white, bottom color=blue!80!white, variable=\x]
(-1,-1.73)
-- plot[domain=326:364]({6*cos(\x)-6},{6*sin(\x)+1.6})
-- (0,2)
-- plot[domain=180:270]({2*cos(\x)+2}, {2*sin(\x)+2})
-- (2,0)
-- plot[domain=240:360]({2*cos(\x)}, {2*sin(\x)})
-- (-1,-1.73);

\end{tikzpicture}

\end{document}

The shading scheme is inspired by Tikz: Shading a path without any filling. However, this solution does not make the color shades as the region gets wider (maybe a more precise path fading setting will do).

The resulted figure looks as follows.

enter image description here

1
  • Thanks! Would shadedraw work instead of fill? I might try, but thanks!
    – Tanda
    Commented Mar 3, 2017 at 8:12
2

Note that some of the earlier items got overdrawn. Also, arcs are drawn from the end points and compute the centers based on the angle and radius. Adding the -- (B) etc. wasn't necessary, but helped debugging the code.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}

\begin{tikzpicture}
%circle
\draw (0,0) circle [radius=2];
% b
\filldraw (0,2) coordinate(B) circle [radius=1pt] node[above] {$b$};
%a
\filldraw (-1,-1.73) coordinate(A) circle [radius=1pt] node[below left] {$a$};
%c
\filldraw (2,0) coordinate(C) circle [radius=1pt] node[right] {$c$};
%geodesic (b,c)
\draw (B) arc[start angle=180, end angle=270, radius=2];
%geodesic (a,b)
\draw (A) arc[start angle=326, end angle=360, radius=6];
%shading
\shadedraw[shading=axis,shading angle=30]
  (A) arc[start angle=326, end angle=360, radius=6] --
  (B) arc[start angle=180, end angle=270, radius=2] --
  (C) arc[start angle=360, end angle=240, radius=2] -- cycle;
\end{tikzpicture}

\end{document}

demo

1
  • Thanks a lot @John. I had tried to use arc to draw the arcs of the circle, but had not succeeded and found this other method with which I could not shade. Thanks!
    – Tanda
    Commented Mar 3, 2017 at 8:10

You must log in to answer this question.

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