-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphicsutils.sty
More file actions
108 lines (86 loc) · 2.43 KB
/
graphicsutils.sty
File metadata and controls
108 lines (86 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{graphicsutils}[2020/09/25]
\RequirePackage{pgf}
\RequirePackage{tikz}
% For plotting arrow curves
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={decoration={
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}}}
\tikzstyle{interrupt}=[
postaction={
decorate,
decoration={markings,
mark= at position 0.5 with {
\fill[white] (-0.1,-0.3) rectangle (0.1,0.3);
\draw(-0.1,0.3) -- (-0.1,-0.3)
(0.1,0.3) -- (0.1,-0.3);
}
}
}
]
\ProcessOptions\relax
% Argument order for draw calls:
% <coordinates> <labels> <other options>
% COORDINATE
\newcommand{\coord}[2]{\coordinate (#1) at (#2);}
% Draw commands
\newcommand{\drawpoint}[1]{\fill (#1) circle (0.05);}
\newcommand{\drawpointwith}[2]{\node[#2] at (#1) {\textbullet};}
\newcommand{\drawline}[2]{\draw (#1) -- (#2);}
\newcommand{\drawlinewith}[3]{\draw[#3] (#1) -- (#2);}
\newcommand{\drawlinemark}[3]{\draw (#1) -- node[sloped] {#3} (#2);}
\newcommand{\drawrect}[2]{\draw (#1) rectangle (#2);}
\newcommand{\drawrectwith}[3]{\draw[#3] (#1) rectangle (#2);}
\newcommand{\drawcirc}[2]{\draw (#1) circle (#2);}
\newcommand{\drawcircwith}[3]{\draw[#3] (#1) circle (#2);}
\newcommand{\drawnodewith}[3]{\node[#3] at (#1) {#2};}
\newcommand{\drawarrowcurve}[5]{\draw[->-=#5] (#1) to [out=#3,in=#4] (#2);}
% QOL commands
\newcommand{\drawcoordpoint}[2]{
\drawpoint{#1}
\drawnodewith{#1}{$#1$}{#2}
}
\newcommand{\drawcoord}[2]{
\drawnodewith{#1}{$#1$}{#2}
}
\newcommand{\drawtri}[3]{
\drawline{#1}{#2}
\drawline{#2}{#3}
\drawline{#1}{#3}
}
% Templates
\newcommand{\plane}[1]{
\drawrect{-#1,-#1}{#1,#1}
}
\newcommand{\planelabel}[2]{
\plane{#1}
\drawpoint{0,0}
\drawnodewith{0,0}{#2}{left}
}
\newcommand{\axes}[1]{
\drawlinewith{-#1,0}{#1,0}{very thick}
\drawlinewith{0,-#1}{0,#1}{very thick}
}
% maybe change syntax?
\newcommand{\axesalt}[4]{
\drawlinewith{#1,0}{#3,0}{->,very thick}
\drawlinewith{0,#2}{0,#4}{->,very thick}
}
% \coordsys{x_1}{y_1}{x_2}{y_2}{xstep}{ystep}{xlabel}{ylabel}
\newcommand{\coordsys}[8]{
\axesalt{#1}{#2}{#3}{#4}
\draw[xstep=#5-#1,ystep=#6-#2] (#1,#2) grid (#3,#4);
\drawnodewith{#3,0}{$#7$}{right}
\drawnodewith{0,#4}{$#8$}{above}
\foreach \x in {#1,#5,...,#3} {
\drawnodewith{\x,0}{$\x$}{below}
}
\foreach \x in {#2,#6,...,#4} {
\drawnodewith{0,\x}{$\x$}{left}
}
}
\newenvironment{tikzcenter}
{\begin{center}\begin{tikzpicture}}
{\end{tikzpicture}\end{center}}
\endinput