\tikzset{ ex_markstyle/.style={}, ex_mark/.style n args={2}{decoration={ markings, % mark= at position 0.5 with with{ \ifnum#1=1 \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \fi \ifnum#1=2 \draw[ex_markstyle] (-1pt,-2pt) -- (-1pt,2pt); \draw[ex_markstyle] (1pt,-2pt) -- (1pt,2pt); \fi \ifnum#1=3 \draw[ex_markstyle] (-2pt,-2pt) -- (-2pt,2pt); \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \draw[ex_markstyle] (2pt,-2pt) -- (2pt,2pt); \fi \ifnum#1=4 \draw[ex_markstyle] (-2pt,-2pt) -- (2pt,2pt); \draw[ex_markstyle] (-2pt,2pt) -- (2pt,-2pt); \fi } }, pic actions/.append code=\tikzset{postaction=decorate}}, ex_mark/.default=1, }Đoạn code trên tạo ra 4 kiểu đánh dấu với cách dùng: ex_mark=...
Ta có thể tùy chỉnh thuộc tính của các kiểu đánh dấu này, như độ lơn (scale), màu sắc (color),... bằng cách dùng: ex_markstyle/.style={...}
Áp dụng, ta có một số kết quả
$$ \usetikzlibrary{calc,quotes,arrows,angles,decorations.markings} \tikzset{ ex_markstyle/.style={}, ex_mark/.style n args={1}{decoration={ markings, % mark= at position 0.5 with with{ \ifnum#1=1 \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \fi \ifnum#1=2 \draw[ex_markstyle] (-1pt,-2pt) -- (-1pt,2pt); \draw[ex_markstyle] (1pt,-2pt) -- (1pt,2pt); \fi \ifnum#1=3 \draw[ex_markstyle] (-2pt,-2pt) -- (-2pt,2pt); \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \draw[ex_markstyle] (2pt,-2pt) -- (2pt,2pt); \fi \ifnum#1=4 \draw[ex_markstyle] (-2pt,-2pt) -- (2pt,2pt); \draw[ex_markstyle] (-2pt,2pt) -- (2pt,-2pt); \fi } }, pic actions/.append code=\tikzset{postaction=decorate}}, } \begin{tikzpicture}[scale=1, font=\footnotesize, line join=round, line cap=round, >=stealth] \path (1,3) coordinate (A) (0,0) coordinate (B) (4,0) coordinate (C) ; \draw (A)--(B)--(C)--cycle; \foreach \p/\r in {A/90,B/-120,C/-60} \fill (\p) circle (1.5pt) node[shift={(\r:3mm)}]{$\p$}; \pic[draw,ex_mark=1] {angle = B--A--C}; \pic[draw,ex_mark=2] {angle = C--B--A}; \pic["$\alpha$",draw,angle radius=0.5cm,ex_mark=3] {angle = A--C--B}; \end{tikzpicture}\begin{tikzpicture}[scale=1, font=\footnotesize, line join=round, line cap=round, >=stealth] \path (1,3) coordinate (A) (0,0) coordinate (B) (4,0) coordinate (C) ; \foreach \p/\r in {A/90,B/-120,C/-60} \fill (\p) circle (1.5pt) node[shift={(\r:3mm)}]{$\p$}; \foreach \r in {0.45,0.5} \pic[draw,angle radius=\r cm,ex_mark=2] {angle = C--B--A}; \pic[fill=yellow!30,fill opacity=0.5,draw,ex_mark=1,double,ex_markstyle/.style={scale=2,red}] {angle = B--A--C}; \pic[fill=yellow!30,fill opacity=0.5,draw,angle radius=0.5cm,ex_mark=4,ex_markstyle/.style={blue}] {angle = A--C--B}; \draw (A)--(B)--(C)--cycle; \end{tikzpicture} $$
\documentclass[tikz,border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{calc,quotes,arrows,angles,decorations.markings} \tikzset{ ex_markstyle/.style={}, ex_mark/.style n args={2}{decoration={ markings, % mark= at position 0.5 with with{ \ifnum#1=1 \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \fi \ifnum#1=2 \draw[ex_markstyle] (-1pt,-2pt) -- (-1pt,2pt); \draw[ex_markstyle] (1pt,-2pt) -- (1pt,2pt); \fi \ifnum#1=3 \draw[ex_markstyle] (-2pt,-2pt) -- (-2pt,2pt); \draw[ex_markstyle] (0pt,-2pt) -- (0pt,2pt); \draw[ex_markstyle] (2pt,-2pt) -- (2pt,2pt); \fi \ifnum#1=4 \draw[ex_markstyle] (-2pt,-2pt) -- (2pt,2pt); \draw[ex_markstyle] (-2pt,2pt) -- (2pt,-2pt); \fi } }, pic actions/.append code=\tikzset{postaction=decorate}}, ex_mark/.default=1, } \begin{document} \begin{tikzpicture}[scale=1, font=\footnotesize, line join=round, line cap=round, >=stealth] \path (1,3) coordinate (A) (0,0) coordinate (B) (4,0) coordinate (C) ; \draw (A)--(B)--(C)--cycle; \foreach \p/\r in {A/90,B/-120,C/-60} \fill (\p) circle (1.5pt) node[shift={(\r:3mm)}]{$\p$}; \pic[draw,ex_mark] {angle = B--A--C}; \pic[draw,ex_mark=2] {angle = C--B--A}; \pic["$\alpha$",draw,angle radius=0.5cm,ex_mark=3] {angle = A--C--B}; \end{tikzpicture} \begin{tikzpicture}[scale=1, font=\footnotesize, line join=round, line cap=miter, >=stealth] \path (1,3) coordinate (A) (0,0) coordinate (B) (4,0) coordinate (C) ; \foreach \p/\r in {A/90,B/-120,C/-60} \fill (\p) circle (1.5pt) node[shift={(\r:3mm)}]{$\p$}; \foreach \r in {0.45,0.5} \pic[draw,angle radius=\r cm,ex_mark=2] {angle = C--B--A}; \pic[fill=yellow!30,fill opacity=0.5,draw,ex_mark=1,double,ex_markstyle/.style={scale=2,red}] {angle = B--A--C}; \pic[fill=yellow!30,fill opacity=0.5,draw,angle radius=0.5cm,ex_mark=4,ex_markstyle/.style={blue}] {angle = A--C--B}; \draw (A)--(B)--(C)--cycle; \end{tikzpicture} \end{document}
0 Nhận xét