TeX - LaTeX Asked by dozer on February 4, 2021
I want to draw a line and a half circle. I want them to have the same bottom, but they cannot have the same bottom line.
documentclass[tikz,border=2pt]{standalone}
begin{document}
tikz {
draw[line width=2cm,red] (0,0) arc [radius=5,start angle=0, end angle=180];
draw[line width=2cm,green] (0,0) arc [radius=5,start angle=0, end angle=-180];
draw [line width=2cm, red] (-10,1) -- (0,1);
}
end{document}
To avoid viewer artefacts and the thick line width, you can just layer appropriate shapes like this:
documentclass[tikz,border=2pt]{standalone}
begin{document}
begin{tikzpicture}
fill[green] (0,0) circle[radius=6];
fill[white] (0,0) circle[radius=4];
fill[red] (6,0) arc [radius=6, start angle=0, end angle=180] -- cycle;
fill[white] ({asin(2/4)}:4) arc [radius=4, start angle=asin(2/4), end angle=180-asin(2/4)] -- cycle;
end{tikzpicture}
end{document}
If you need transparent background, here is the same thing using even odd rule
:
documentclass[tikz,border=2pt]{standalone}
begin{document}
begin{tikzpicture}
fill[green, even odd rule] (0,0) circle[radius=6] (0,0) circle[radius=4];
fill[red, even odd rule] (6,0) arc [radius=6, start angle=0, end angle=180] -- cycle ({asin(2/4)}:4) arc [radius=4, start angle=asin(2/4), end angle=180-asin(2/4)] -- cycle;
end{tikzpicture}
end{document}
Answered by hpekristiansen on February 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP