TransWikia.com

How to control the position of a line accurately?

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}

enter image description here

enter image description here

One Answer

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}

Red green circle symbol

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

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP