mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
graph triangles
This commit is contained in:
parent
ef302ae8d2
commit
d9a06acf14
5 changed files with 77 additions and 0 deletions
35
tikz/graph-triangles/Makefile
Normal file
35
tikz/graph-triangles/Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
SOURCE = graph-triangles
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
make
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
||||
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
|
||||
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
|
||||
rm $(SOURCE)2.svg
|
3
tikz/graph-triangles/README.md
Normal file
3
tikz/graph-triangles/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
7
tikz/graph-triangles/coordinates.py
Normal file
7
tikz/graph-triangles/coordinates.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
def giveCoordinates(n):
|
||||
for y in range(0,n):
|
||||
for x in range(y,2*n-y,2):
|
||||
print(x,y)
|
||||
print("")
|
||||
|
||||
giveCoordinates(5)
|
BIN
tikz/graph-triangles/graph-triangles.png
Normal file
BIN
tikz/graph-triangles/graph-triangles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
32
tikz/graph-triangles/graph-triangles.tex
Normal file
32
tikz/graph-triangles/graph-triangles.tex
Normal file
|
@ -0,0 +1,32 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
|
||||
\usepackage{ifthen}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{calc}
|
||||
\tikzstyle{vertex}=[draw,red,fill=red,circle,
|
||||
minimum size=10pt,inner sep=0pt]
|
||||
\tikzstyle{edge}=[red, very thick]
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}
|
||||
\newcommand{\n}{10}
|
||||
\foreach \y in {0, ..., \n}{
|
||||
\pgfmathsetmacro{\loopend}{{2*\n-\y}}
|
||||
\pgfmathsetmacro{\second}{{\y+2}}
|
||||
\foreach \x in {\y, \second,..., \loopend}{
|
||||
\ifthenelse{\n=\y}{\breakforeach}{}
|
||||
\node (n-\x\y)[vertex] at (\x,\y) {};
|
||||
|
||||
\ifthenelse{\y=0}{}{\draw[edge] (\x,\y) -- (\x+1,\y-1);}
|
||||
\pgfmathtruncatemacro\X{\x}
|
||||
\ifthenelse{\X<\loopend}{\draw[edge] (\x,\y) -- (\x+2,\y);}{}
|
||||
\ifthenelse{\X=\loopend}{}{\draw[edge] (\x,\y) -- (\x+1,\y+1);}
|
||||
|
||||
}
|
||||
}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue