Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'figs/libs/grid.sty')
-rw-r--r--figs/libs/grid.sty24
1 files changed, 24 insertions, 0 deletions
diff --git a/figs/libs/grid.sty b/figs/libs/grid.sty
new file mode 100644
index 0000000..495bc80
--- /dev/null
+++ b/figs/libs/grid.sty
@@ -0,0 +1,24 @@
+% light gray color
+\definecolor{lightgray}{gray}{0.7}
+
+% a grid with starting from #1 mesh #2 of width #3*#2 and height #4*#2
+\def\grid#1#2#3#4{
+ % vertical lines
+ \foreach\i in{0,...,#3}{
+ \draw[color=lightgray]#1++(\i*#2,0)--++(0,#4*#2);
+ }
+ % horizontal lines
+ \foreach\j in{0,...,#4}{
+ \draw[color=lightgray]#1++(0,\j*#2)--++(#3*#2,0);
+ }
+}
+
+% a square centered at #1 of side #2
+\def\square#1#2{
+ \draw#1++(-0.5*#2,-0.5*#2)--++(#2,0)--++(0,#2)--++(-#2,0)--cycle;
+}
+
+% fill a square centered at #1 of side #2 and color #3
+\def\fillsquare#1#2#3{
+ \fill[color=#3]#1++(-0.5*#2,-0.5*#2)--++(#2,0)--++(0,#2)--++(-#2,0)--cycle;
+}