def test_marked_angles(): """Check Angle's instanciation.""" pointO = Point(0, 0, 'O') pointI = Point(1, 0, 'I') pointJ = Point(0, 1, 'J') required.tikz_library['angles'] = False theta = Angle(pointI, pointO, pointJ) assert theta.tikz_decorations() == '' theta.decoration = AngleDecoration(color='red', thickness='ultra thick', radius=Number(2)) assert theta.tikz_decorations() \ == 'pic [draw, ultra thick, angle radius = 2, red] {angle = I--O--J}' assert required.tikz_library['angles'] required.tikz_library['angles'] = False theta.mark_right = True theta.decoration = AngleDecoration() assert theta.label is None assert theta.tikz_decorations() == '' assert not required.tikz_library['angles'] assert theta.tikz_rightangle_mark() == \ '\draw[thick, cm={cos(0), sin(0), -sin(0), cos(0), (O)}]' \ ' (0.25 cm, 0) -- (0.25 cm, 0.25 cm) -- (0, 0.25 cm);' assert theta.tikz_rightangle_mark(winding='clockwise') == \ '\draw[thick, cm={cos(0), sin(0), -sin(0), cos(0), (O)}]' \ ' (0.25 cm, 0) -- (0.25 cm, -0.25 cm) -- (0, -0.25 cm);' with pytest.raises(ValueError) as excinfo: theta.tikz_rightangle_mark(winding=None) assert str(excinfo.value) == 'Expect \'clockwise\' or \'anticlockwise\'. '\ 'Found \'None\' instead.'
def test_drawing_double_decorated_angles(): P = Point(0, 0, 'P') L = Point(0, 2, 'L') E = Point('-1.84', '0.8', 'E') α = Angle(L, P, E, label_vertex=True, draw_vertex=True, label_endpoints=True, draw_endpoints=True, label=Number(39, unit=r'\textdegree')) α.decoration = AngleDecoration(radius=Number('0.7', unit='cm'), eccentricity=Number('1.6')) α.decoration2 = AngleDecoration(radius=Number('1.6', unit='cm'), eccentricity=Number('1.3'), label=Number(42, unit=r'\textdegree'), color='NavyBlue', do_draw=False, thickness=None) assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (L) at (0,2); \coordinate (P) at (0,0); \coordinate (E) at (-1.84,0.8); % Draw Angle \draw[thick] (L) -- (P) -- (E) pic ["\ang{39}", angle eccentricity=1.6, draw, thick, angle """\ r"""radius = 0.7 cm] {angle = L--P--E} pic ["\ang{42}", angle eccentricity=1.3, angle radius = 1.6 cm, """\ r"""NavyBlue] {angle = L--P--E};
def test_drawing_angles_with_arrowtips(): """Check drawing standalone Angles.""" A = Point(0, 0, 'A') X = Point(6, 1, 'X') Y = Point(3, 5, 'Y') α = Angle(X, A, Y) α.decoration = AngleDecoration(arrow_tips='<->') assert α.drawn == r"""
def test_drawing_marked_rightangles(): """Check drawing standalone Angles.""" A = Point(0, 0, 'A') X = Point(6, 1, 'X') Y = Point(-1, 6, 'Y') α = Angle(X, A, Y) α.decoration = AngleDecoration(radius=Number('0.5', unit='cm')) α.mark_right = True assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (-1,6); % Draw Angle \draw[thick] (X) -- (A) -- (Y); % Mark right angle \draw[thick, cm={cos(9.46), sin(9.46), -sin(9.46), cos(9.46), (A)}]"""\ r""" (0.5 cm, 0) -- (0.5 cm, 0.5 cm) -- (0, 0.5 cm);
def test_drawing_marked_labeled_angles(): """Check drawing standalone Angles.""" A = Point(0, 0, 'A') X = Point(6, 1, 'X') Y = Point(3, 5, 'Y') α = Angle(X, A, Y, label=Number(38, unit=r'\textdegree')) α.decoration = AngleDecoration(radius=Number('0.5', unit='cm')) assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic ["\ang{38}", angle eccentricity=1.8, draw, thick, """\ r"""angle radius = 0.5 cm] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ α.decoration.variety = 'double' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm] {angle = X--A--Y} pic ["\ang{38}", angle eccentricity=1.8, draw, thick, """\ r"""angle radius = 0.58 cm] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ A = Point(0, 0, 'A') X1 = Point(6, 1, 'X1') Y1 = Point(3, 5, 'Y1') α = Angle(X1, A, Y1, armspoints=[('X', ), ('Y', )], label_vertex=True, draw_vertex=True, label=Number(38, unit=r'\textdegree')) α.decoration = AngleDecoration(radius=Number('0.5', unit='cm'), variety='double', hatchmark='singledash') assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X1) at (6,1); \coordinate (A) at (0,0); \coordinate (Y1) at (3,5); \coordinate (X) at (4.8,0.8); \coordinate (Y) at (2.4,4); % Draw Angle \draw[thick] (X1) -- (A) -- (Y1) pic [draw, thick, angle radius = 0.5 cm, singledash] {angle = X1--A--Y1} pic ["\ang{38}", angle eccentricity=1.8, draw, thick, """\ r"""angle radius = 0.58 cm, singledash] {angle = X1--A--Y1};
def test_drawing_marked_angles(): """Check drawing standalone Angles.""" A = Point(0, 0, 'A') X = Point(6, 1, 'X') Y = Point(3, 5, 'Y') α = Angle(X, A, Y) α.decoration = AngleDecoration(radius=Number('0.5', unit='cm')) assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ α.decoration.variety = 'double' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm] {angle = X--A--Y} pic [draw, thick, angle radius = 0.58 cm] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ α.decoration.variety = 'triple' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm] {angle = X--A--Y} pic [draw, thick, angle radius = 0.58 cm] {angle = X--A--Y} pic [draw, thick, angle radius = 0.66 cm] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ α.decoration.variety = 'single' α.decoration.hatchmark = 'singledash' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm, singledash] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ assert required.tikz_library['decorations.markings'] assert required.tikzset['singledash_hatchmark'] assert not required.tikzset['doubledash_hatchmark'] assert not required.tikzset['tripledash_hatchmark'] required.tikz_library['decorations.markings'] = False required.tikzset['singledash_hatchmark'] = False α.decoration.hatchmark = 'doubledash' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm, doubledash] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ assert required.tikz_library['decorations.markings'] assert not required.tikzset['singledash_hatchmark'] assert required.tikzset['doubledash_hatchmark'] assert not required.tikzset['tripledash_hatchmark'] required.tikz_library['decorations.markings'] = False required.tikzset['doubledash_hatchmark'] = False α.decoration.hatchmark = 'tripledash' assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic [draw, thick, angle radius = 0.5 cm, tripledash] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ assert required.tikz_library['decorations.markings'] assert not required.tikzset['singledash_hatchmark'] assert not required.tikzset['doubledash_hatchmark'] assert required.tikzset['tripledash_hatchmark'] α.decoration.variety = 'triple' α.decoration.hatchmark = 'doubledash' assert α.drawn == r"""
def test_drawing_labeled_angles(): """Check drawing standalone Angles.""" A = Point(0, 0, 'A') X = Point(6, 1, 'X') Y = Point(3, 5, 'Y') α = Angle(X, A, Y, label=Number(38, unit=r'\textdegree')) required.tikz_library['quotes'] = False assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic ["\ang{38}", angle eccentricity=2.6] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ assert required.tikz_library['quotes'] assert α.label == r'\ang{38}' α.decoration = None assert α.label == r'\ang{38}' assert α.decoration is not None assert repr(α.decoration) == r'AngleDecoration(variety=None; '\ r'hatchmark=None; label=\ang{38}; color=None; thickness=thick; '\ r'radius=0.25 cm; eccentricity=2.6)' α = Angle(X, A, Y, decoration=AngleDecoration(label=Number(38, unit=r'\textdegree'), variety=None)) assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic ["\ang{38}", angle eccentricity=2.6] {angle = X--A--Y}; % Label Points \end{tikzpicture} """ α = Angle(X, A, Y, label=Number(38, unit=r'\textdegree'), decoration=AngleDecoration(radius=Number('0.9', unit='cm'))) assert α.drawn == r""" \begin{tikzpicture} % Declare Points \coordinate (X) at (6,1); \coordinate (A) at (0,0); \coordinate (Y) at (3,5); % Draw Angle \draw[thick] (X) -- (A) -- (Y) pic ["\ang{38}", angle eccentricity=1.44, draw, thick, """\ r"""angle radius = 0.9 cm] {angle = X--A--Y};