Bläddra i källkod

Add README.md and rendered image to 6 tikz examples

The examples were found by

```bash
$ find . -type d '!' -exec test -e "{}/README.md" ';' -print
```
Martin Thoma 9 år sedan
förälder
incheckning
6364e13a6a

+ 10 - 12
tikz/bellman-ford-algorithm/Makefile

@@ -2,11 +2,11 @@ SOURCE = bellman-ford-algorithm
 DELAY = 80
 DENSITY = 300
 WIDTH = 512
- 
+
 make:
 	pdflatex $(SOURCE).tex -output-format=pdf
 	make clean
- 
+
 clean:
 	rm -rf  $(TARGET) *.class *.html *.log *.aux *.toc *.snm *.out *.nav
 
@@ -20,22 +20,20 @@ animatedGif:
 	pdfcrop $(SOURCE).pdf
 	convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
 	make clean
- 
-transparentGif:
-	convert $(SOURCE).pdf -transparent white result.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
+	inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
+	rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
+	rm $(SOURCE)1.svg

+ 0 - 1
tikz/bellman-ford-algorithm/README

@@ -1 +0,0 @@
-TODO: Not ready, make ready!

+ 6 - 0
tikz/bellman-ford-algorithm/README.md

@@ -0,0 +1,6 @@
+TODO: Not ready, make ready!
+
+
+Compiled example
+----------------
+![Example](bellman-ford-algorithm.gif)

BIN
tikz/bellman-ford-algorithm/bellman-ford-algorithm.gif


BIN
tikz/bellman-ford-algorithm/bellman-ford-algorithm.png


+ 3 - 5
tikz/center/Makefile

@@ -25,11 +25,9 @@ transparentGif:
 	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
+	inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
+	rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
+	rm $(SOURCE)1.svg

+ 3 - 0
tikz/center/README.md

@@ -0,0 +1,3 @@
+Compiled example
+----------------
+![Example](center.png)

BIN
tikz/center/center.png


+ 20 - 17
tikz/center/tikz.py

@@ -1,6 +1,8 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
 from random import uniform
 import random
-import math
 
 n = 5
 xMin, yMin = 0, 0
@@ -12,29 +14,30 @@ coordinates = []
 random.seed(42)
 
 for i in range(n):
-	x = uniform(xMin, xMax)
-	y = uniform(yMin, yMax)
-	xSum += x
-	ySum += y
-	coordinates.append((x,y))
+    x = uniform(xMin, xMax)
+    y = uniform(yMin, yMax)
+    xSum += x
+    ySum += y
+    coordinates.append((x, y))
 
 center = (float(xSum) / n, float(ySum) / n)
 
 cx, cy = center
-pointCoords = ""
+point_coords = ""
 for p in coordinates:
-	px, py = p	
-	newP = "(%.2f,%.2f)," % (px, py)
-	pointCoords = newP + pointCoords
-	deltaY = cy-py
-	deltaX = cx-px
-	length = (deltaY**2+deltaX**2)**0.5
-	sinAlpha = deltaY/length
-	cosAlpha = deltaX/length
-	print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" % (px, py, px+cosAlpha*length*0.80, py+sinAlpha*length*0.80))
+    px, py = p
+    new_p = "(%.2f,%.2f)," % (px, py)
+    point_coords = new_p + point_coords
+    delta_y = cy-py
+    delta_x = cx-px
+    length = (delta_y**2+delta_x**2)**0.5
+    sin_alpha = delta_y/length
+    cos_alpha = delta_x/length
+    print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" %
+          (px, py, px + cos_alpha*length*0.80, py + sin_alpha*length*0.80))
 
 print("\\node[circle,inner sep=1pt,fill]  at (%.2f,%.2f) {};" % (cx, cy))
 
-print("\\foreach \point in {" + pointCoords + "}{")
+print("\\foreach \point in {" + point_coords + "}{")
 print("\\node[dot] at \point {};")
 print("}")

+ 1 - 0
tikz/cubic-function-intermediate-value-theorem/Makefile

@@ -1,4 +1,5 @@
 SOURCE = cubic-function-intermediate-value-theorem
+
 DELAY = 80
 DENSITY = 300
 WIDTH = 500

+ 3 - 0
tikz/cubic-function-intermediate-value-theorem/README.md

@@ -0,0 +1,3 @@
+Compiled example
+----------------
+![Example](cubic-function-intermediate-value-theorem.png)

BIN
tikz/cubic-function-intermediate-value-theorem/cubic-function-intermediate-value-theorem.png


+ 4 - 3
tikz/dirichlet-function/Makefile

@@ -1,11 +1,10 @@
 SOURCE = dirichlet-function
 DELAY = 80
 DENSITY = 300
-WIDTH = 500
+WIDTH = 512
 
 make:
 	pdflatex $(SOURCE).tex -output-format=pdf
-	pdflatex $(SOURCE).tex -output-format=pdf
 	make clean
 
 clean:
@@ -29,4 +28,6 @@ svg:
 	#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
+	inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
+	rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
+	rm $(SOURCE)1.svg

+ 3 - 0
tikz/dirichlet-function/README.md

@@ -0,0 +1,3 @@
+Compiled example
+----------------
+![Example](dirichlet-function.png)

BIN
tikz/dirichlet-function/dirichlet-function.png


+ 5 - 4
tikz/jordan-normal-form/Makefile

@@ -1,15 +1,14 @@
 SOURCE = jordan-normal-form
 DELAY = 80
 DENSITY = 300
-WIDTH = 500
+WIDTH = 512
 
 make:
 	pdflatex $(SOURCE).tex -output-format=pdf
-	pdflatex $(SOURCE).tex -output-format=pdf
 	make clean
 
 clean:
-	rm -rf  $(TARGET) *.class *.html *.log *.aux
+	rm -rf  $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
 
 gif:
 	pdfcrop $(SOURCE).pdf
@@ -29,4 +28,6 @@ svg:
 	#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
+	inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
+	rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
+	rm $(SOURCE)1.svg

+ 3 - 0
tikz/jordan-normal-form/README.md

@@ -0,0 +1,3 @@
+Compiled example
+----------------
+![Example](jordan-normal-form.png)

BIN
tikz/jordan-normal-form/jordan-normal-form.png


+ 3 - 5
tikz/resource-allocation-graph/Makefile

@@ -25,11 +25,9 @@ transparentGif:
 	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
+	inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
+	rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
+	rm $(SOURCE)1.svg

+ 3 - 0
tikz/resource-allocation-graph/README.md

@@ -0,0 +1,3 @@
+Compiled example
+----------------
+![Example](resource-allocation-graph.png)

BIN
tikz/resource-allocation-graph/resource-allocation-graph.png