Ian Jauslin
summaryrefslogtreecommitdiff
path: root/figs/libs
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2020-12-15 16:28:00 +0100
committerIan Jauslin <ian@jauslin.org>2020-12-15 16:28:00 +0100
commitf11228d28d608a17691ee24719c6a91455503d17 (patch)
tree1aa1bf6d81a4e2f5c452e1de18dfbfcb87ce045c /figs/libs
As presented at UMSM on 2020-12-15HEADv1.0master
Diffstat (limited to 'figs/libs')
-rw-r--r--figs/libs/Makefile28
-rw-r--r--figs/libs/shapes.sty91
2 files changed, 119 insertions, 0 deletions
diff --git a/figs/libs/Makefile b/figs/libs/Makefile
new file mode 100644
index 0000000..33b81e2
--- /dev/null
+++ b/figs/libs/Makefile
@@ -0,0 +1,28 @@
+PROJECTNAME=$(basename $(basename $(wildcard *.tikz.tex)))
+LIBS=$(notdir $(wildcard libs/*))
+
+PDFS=$(addsuffix .pdf, $(PROJECTNAME))
+
+all: $(PDFS)
+
+$(PDFS): $(LIBS)
+ echo $(LIBS)
+ pdflatex -jobname $(basename $@) -file-line-error $(patsubst %.pdf, %.tikz.tex, $@)
+
+install: $(PDFS)
+ cp $^ $(INSTALLDIR)/
+
+$(LIBS):
+ ln -fs libs/$@ ./
+
+clean-libs:
+ rm -f $(LIBS)
+
+clean-aux:
+ rm -f $(addsuffix .aux, $(PROJECTNAME))
+ rm -f $(addsuffix .log, $(PROJECTNAME))
+
+clean-tex:
+ rm -f $(PDFS)
+
+clean: clean-libs clean-aux clean-tex
diff --git a/figs/libs/shapes.sty b/figs/libs/shapes.sty
new file mode 100644
index 0000000..aee8fd3
--- /dev/null
+++ b/figs/libs/shapes.sty
@@ -0,0 +1,91 @@
+% square lattice (width #1, height #2, origin #3, spacing #4)
+\def\grid#1#2#3{
+ \foreach\i in {0,...,#2}{
+ \draw#3++(0,\i)--++(#1,0);
+ }
+ \foreach\i in {0,...,#1}{
+ \draw#3++(\i,0)--++(0,#2);
+ }
+}
+
+
+% cross (color #1, position #2)
+\def\cross#1#2{
+ \fill[color=#1]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-1)--++(-1,0)--++(0,-1)--++(1,0)--++(0,-1)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+ \begin{scope}
+ \clip#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-1)--++(-1,0)--++(0,-1)--++(1,0)--++(0,-1)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+ \grid44{[color=white]#2++(-2,-2)}
+ \end{scope}
+ \draw[color=black]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-1)--++(-1,0)--++(0,-1)--++(1,0)--++(0,-1)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+}
+
+% V triomino (color #1, position #2)
+\def\Vtriomino#1#2{
+ \fill[color=#1]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-2)--++(2,0)--++(0,1)--++(-1,0);
+ \begin{scope}
+ \clip#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-2)--++(2,0)--++(0,1)--++(-1,0);
+ \grid33{[color=white]#2++(-1,-1)}
+ \end{scope}
+ \draw[color=black]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-2)--++(2,0)--++(0,1)--++(-1,0);
+}
+
+% T tetromino (color #1, position #2)
+\def\Ttetromino#1#2{
+ \fill[color=#1]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+ \begin{scope}
+ \clip#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+ \grid34{[color=white]#2++(-1,-2)}
+ \end{scope}
+ \draw[color=black]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,1)--++(-1,0);
+}
+
+% L tetromino (color #1, position #2)
+\def\Ltetromino#1#2{
+ \fill[color=#1]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(2,0)--++(0,1)--++(-1,0)--++(0,1);
+ \begin{scope}
+ \clip#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(2,0)--++(0,1)--++(-1,0)--++(0,1);
+ \grid34{[color=white]#2++(-1,-2)}
+ \end{scope}
+ \draw[color=black]#2++(0.5,0.5)--++(0,1)--++(-1,0)--++(0,-3)--++(2,0)--++(0,1)--++(-1,0)--++(0,1);
+}
+
+% P pentomino (color #1, position #2)
+\def\Ppentomino#1#2{
+ \fill[color=#1]#2++(1.5,1.5)--++(-2,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,2);
+ \begin{scope}
+ \clip#2++(1.5,1.5)--++(-2,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,2);
+ \grid34{[color=white]#2++(-1,-2)}
+ \end{scope}
+ \draw[color=black]#2++(1.5,1.5)--++(-2,0)--++(0,-3)--++(1,0)--++(0,1)--++(1,0)--++(0,2);
+}
+
+% 1x1 square (color #1, position #2)
+\def\square#1#2{
+ \fill[color=#1]#2++(-0.5,-0.5)--++(0,1)--++(1,0)--++(0,-1)--cycle;
+ \draw[color=black]#2++(-0.5,-0.5)--++(0,1)--++(1,0)--++(0,-1)--cycle;
+ \draw[color=white]#2++(-0.5,0)--++(1,0);
+ \draw[color=white]#2++(0,-0.5)--++(0,1);
+}
+
+% 2x2 square (color #1, position #2)
+\def\ttsquare#1#2{
+ \fill[color=#1]#2++(-1,-1)--++(0,2)--++(2,0)--++(0,-2)--cycle;
+ \draw[color=black]#2++(-1,-1)--++(0,2)--++(2,0)--++(0,-2)--cycle;
+ \draw[color=white]#2++(-0.5,-1)--++(0,2);
+ \draw[color=white]#2++(0.5,-1)--++(0,2);
+ \draw[color=white]#2++(-1,-0.5)--++(2,0);
+ \draw[color=white]#2++(-1,0.5)--++(2,0);
+}
+\def\ttsquareempty#1{
+ \draw[color=black]#1++(-1,-1)--++(0,2)--++(2,0)--++(0,-2)--cycle;
+}
+
+% diamond (color #1, position #2)
+\def\diamond#1#2{
+ \fill[color=#1]#2++(0,-1)--++(1,1)--++(-1,1)--++(-1,-1)--cycle;
+ \begin{scope}
+ \clip#2++(0,-1)--++(1,1)--++(-1,1)--++(-1,-1)--cycle;
+ \grid22{[color=white]#2++(-1,-1)}
+ \end{scope}
+ \draw[color=black]#2++(0,-1)--++(1,1)--++(-1,1)--++(-1,-1)--cycle;
+}