我有一个由闭合曲线包围的区域,如下图所示。我该如何给这个区域上色?
我注意到我已经使用过tkz-euclide
,虽然我认为该库tikz-avoidpath
是为了绘制此类图形以进行复杂分析而创建的,包括填充颜色,但由于该功能,我无法弄清楚如何使用它 neck
。
\documentclass{standalone}
\usepackage{tkz-euclide}
\definecolor{lgray}{RGB}{200,200,200}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tikzset{tkz arrows/.style=
{postaction=
{on each path=
{tkz arrow=
{Stealth[scale=1.5,black]}}}},
tkz smallarrows/.style=
{postaction=
{on each path={tkz arrow=
{Stealth[scale=1,black]}}}},
tkz revsmallarrows/.style=
{postaction=
{on each path={tkz arrow=
{Stealth[scale=-1,black]}}}}}
\draw[help lines, lgray] (-4,-1) grid (4,4);
\tkzDefPoints{0/0/O, 3/0/R, -3/0/-R, -1.5/0/L_R, 0/3/H_R}
% First 8th root of unity
\tkzDefPoint(45:1){z_1}
% c_1 will be the circle around z_1
\tkzDefShiftPoint[z_1](0,.4){c_1}
% Lines to find intersections with c_1
\tkzDefShiftPoint[z_1](.05,0){r1}
\tkzDefShiftPoint[z_1](-.05,0){l1}
\tkzDefPointBy[projection=onto -R--R](z_1)
\tkzGetPoint{Z1}
\tkzDefShiftPoint[Z1](.05,0){R1}
\tkzDefShiftPoint[Z1](-.05,0){L1}
% Intersection with c_1
\tkzInterLC(r1,R1)(z_1,c_1) \tkzGetPoints{cr1}{sr1}
\tkzInterLC(l1,L1)(z_1,c_1) \tkzGetPoints{sl1}{cl1}
% Third 8th root of unity
\tkzDefPoint(135:1){z_2}
% c_2 will be the circle around z_2
\tkzDefShiftPoint[z_2](0,.4){c_2}
% Lines to find intersections with c_2
\tkzDefShiftPoint[z_2](.05,0){r2}
\tkzDefShiftPoint[z_2](-.05,0){l2}
\tkzDefPointBy[projection=onto -R--R](z_2)
\tkzGetPoint{Z2}
\tkzDefShiftPoint[Z2](.05,0){R2}
\tkzDefShiftPoint[Z2](-.05,0){L2}
% Intersection with c_2
\tkzInterLC(r2,R2)(z_2,c_2) \tkzGetPoints{cr2}{sr2}
\tkzInterLC(l2,L2)(z_2,c_2) \tkzGetPoints{sl2}{cl2}
\tkzDrawPoints(z_1,z_2,-R,R,O)
\tkzLabelPoints[above](H_R,L_R,c_1,c_2)
\tkzLabelPoints[below](-R,R)
\tkzLabelPoint[below](O){$0$}
\tkzLabelPoints[right](z_1)
\tkzLabelPoints[left](z_2)
% Draw L_R
\tkzDrawSegments[tkz arrows](-R,L2 R2,L1 R1,R)
\tkzDrawArc[tkz arrows,black](O,R)(-R)
% Draw c_1 and c_2
\tkzDrawArc[tkz revsmallarrows, black](z_1,cr1)(cl1)
\tkzDrawArc[tkz revsmallarrows, black](z_2,cr2)(cl2)
% Draw necks
\tkzDrawSegment[ tkz smallarrows](cr1,R1)
\tkzDrawSegment[tkz smallarrows](L1,cl1)
\tkzDrawSegment[ tkz smallarrows](cr2,R2)
\tkzDrawSegment[tkz smallarrows](L2,cl2)
\end{tikzpicture}
\end{document}
答案1
tkz-euclide
是制作欧几里得几何图形的工具,因此它并不特别适合做其他事情。有时你必须找到技巧才能获得某些结果。SebGlav 的评论是正确的, 的主要问题之一tkz-euclide
是 的整体概念的丧失path
。复杂图形是由 并置形成的paths
。
\documentclass{standalone}
\usepackage{tkz-euclide}
\definecolor{lgray}{RGB}{200,200,200}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tikzset{tkz arrows/.style=
{postaction=
{on each path=
{tkz arrow=
{Stealth[scale=1.5,black]}}}},
tkz smallarrows/.style=
{postaction=
{on each path={tkz arrow=
{Stealth[scale=1,black]}}}},
tkz revsmallarrows/.style=
{postaction=
{on each path={tkz arrow=
{Stealth[scale=-1,black]}}}}}
\draw[help lines, lgray] (-4,-1) grid (4,4);
\tkzDefPoints{0/0/O, 3/0/R, -3/0/-R, -1.5/0/L_R, 0/3/H_R}
% First 8th root of unity
\tkzDefPoint(45:1){z_1}
% c_1 will be the circle around z_1
\tkzDefShiftPoint[z_1](0,.4){c_1}
% Lines to find intersections with c_1
\tkzDefShiftPoint[z_1](.05,0){r1}
\tkzDefShiftPoint[z_1](-.05,0){l1}
\tkzDefPointBy[projection=onto -R--R](z_1)
\tkzGetPoint{Z1}
\tkzDefShiftPoint[Z1](.05,0){R1}
\tkzDefShiftPoint[Z1](-.05,0){L1}
% Intersection with c_1
\tkzInterLC(r1,R1)(z_1,c_1) \tkzGetPoints{cr1}{sr1}
\tkzInterLC(l1,L1)(z_1,c_1) \tkzGetPoints{sl1}{cl1}
% Third 8th root of unity
\tkzDefPoint(135:1){z_2}
% c_2 will be the circle around z_2
\tkzDefShiftPoint[z_2](0,.4){c_2}
% Lines to find intersections with c_2
\tkzDefShiftPoint[z_2](.05,0){r2}
\tkzDefShiftPoint[z_2](-.05,0){l2}
\tkzDefPointBy[projection=onto -R--R](z_2)
\tkzGetPoint{Z2}
\tkzDefShiftPoint[Z2](.05,0){R2}
\tkzDefShiftPoint[Z2](-.05,0){L2}
% Intersection with c_2
\tkzInterLC(r2,R2)(z_2,c_2) \tkzGetPoints{cr2}{sr2}
\tkzInterLC(l2,L2)(z_2,c_2) \tkzGetPoints{sl2}{cl2}
\tkzDrawPoints(z_1,z_2,-R,R,O)
\tkzLabelPoints[above](H_R,L_R,c_1,c_2)
\tkzLabelPoints[below](-R,R)
\tkzLabelPoint[below](O){$0$}
\tkzLabelPoints[right](z_1)
\tkzLabelPoints[left](z_2)
\begin{scope}
\tkzClipCircle[out](z_1,cr1)
\tkzClipCircle[out](z_2,cr2)
\tkzClipPolygon[out](L1,R1,cr1,cl1)
\tkzClipPolygon[out](L2,R2,cr2,cl2)
\tkzDrawArc[tkz arrows,black,fill=teal!10](O,R)(-R)
\end{scope}
% Draw L_R
\tkzDrawSegments[tkz arrows](-R,L2 R2,L1 R1,R)
\tkzDrawArc[tkz arrows,black](O,R)(-R)
% Draw c_1 and c_2
\tkzDrawArc[tkz revsmallarrows, black](z_1,cr1)(cl1)
\tkzDrawArc[tkz revsmallarrows, black](z_2,cr2)(cl2)
% Draw necks
\tkzDrawSegment[ tkz smallarrows](cr1,R1)
\tkzDrawSegment[tkz smallarrows](L1,cl1)
\tkzDrawSegment[ tkz smallarrows](cr2,R2)
\tkzDrawSegment[tkz smallarrows](L2,cl2)
\end{tikzpicture}
\end{document}