PHẦN MỀM HỖ TRỢ DẠY VÀ HỌC

[TikZ] Hình vẽ cái cân

Hình bên dưới được vẽ bằng TikZ, một thư viện vẽ hình của LaTeX.

$$ \begin{tikzpicture}[font=\footnotesize, line join=round, line cap=round, >=stealth] \def\R{5} \clip(-\R,-0.2*\R)rectangle(\R,1.1*\R); \fill[left color=cyan!30,right color=teal!30](-\R,-0.2*\R)rectangle(\R,1.1*\R); \fill[ball color=magenta,scale=1.18,shift={(0,-0.25)},line width=2pt](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R); \fill[white,line width=2pt,scale=1.06,shift={(0,-0.1)}](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R); \clip(142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R); \draw[line width=4pt,teal](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R); \clip(142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R); \foreach \i in {140,139,...,40}{ \pgfmathsetmacro{\k}{int(\i-20)} \pgfmathsetmacro{\j}{int(mod(\i,10))} \ifnum \j=0 \pgfmathsetmacro{\kk}{int(120-\k)} \draw[line width=1pt] (140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.75)node[below,sloped]{\kk}; \else \ifnum \j=5 \draw[blue,line width=2pt] (140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.5); \else \draw[blue,line width=1pt] (140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.2); \fi \fi } \draw[red,line width=2pt](90:\R)--++(-90:1.15); \end{tikzpicture} $$

\begin{tikzpicture}[font=\footnotesize, line join=round, line cap=round, >=stealth]
\def\R{5}
\clip(-\R,-0.2*\R)rectangle(\R,1.1*\R);
\fill[left color=cyan!30,right color=teal!30](-\R,-0.2*\R)rectangle(\R,1.1*\R);
\fill[ball color=magenta,scale=1.18,shift={(0,-0.25)},line width=2pt](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R);
\fill[white,line width=2pt,scale=1.06,shift={(0,-0.1)}](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R);
\clip(142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R);
\draw[line width=4pt,teal](142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R);
\clip(142:\R)arc(142:38:{\R} and {0.8*\R})..controls++(-110:\R) and ++(-70:\R)..(142:\R);
\foreach \i in {140,139,...,40}{
\pgfmathsetmacro{\k}{int(\i-20)}
\pgfmathsetmacro{\j}{int(mod(\i,10))}
\ifnum \j=0 
\pgfmathsetmacro{\kk}{int(120-\k)}
\draw[line width=1pt]
(140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.75)node[below,sloped]{\kk};
\else
\ifnum \j=5
\draw[blue,line width=2pt]
(140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.5);
\else
\draw[blue,line width=1pt]
(140:\R)arc(140:\i-5:{\R} and {0.8*\R})--([turn]-90:0.2);
\fi
\fi
}
\draw[red,line width=2pt](90:\R)--++(-90:1.15);
\end{tikzpicture}

Đăng nhận xét

0 Nhận xét