]> git.leopard-lacewing.eu Git - tex_tools.git/commitdiff
[py] better color function
authorPeter Schaefer <schaeferpm@gmail.com>
Thu, 3 Jan 2019 13:50:02 +0000 (14:50 +0100)
committerPeter Schaefer <schaeferpm@gmail.com>
Thu, 3 Jan 2019 13:50:02 +0000 (14:50 +0100)
git-log-to-tikz.py
git1.tex
text-output.pdf

index 876f25b9d8183e824e67f7969fac344993b4aa0f..629a1acaa5f69adfada4461899799e0f95bc7a90 100755 (executable)
@@ -8,7 +8,11 @@ from re import compile, match
 hashpat = compile(r"[a-f0-9]{7}")
 linepat = compile(r'[^|\/\\]')
 
-colors = ["black", "blue", "brown", "cyan", "darkgray", "gray", "green", "lightgray", "lime", "magenta", "olive", "orange", "pink", "purple", "red", "teal", "violet", "white", "yellow"]
+
+def color(numb):
+    colors = ["black", "blue", "brown", "cyan", "darkgray", "gray", "green", "lightgray", "lime", "magenta", "olive", "orange", "pink", "purple", "red", "teal", "violet", "white", "yellow"]
+    return colors[numb % colors.__len__()]
+
 
 class Commit:
     def __init__(self,line):
@@ -46,7 +50,7 @@ class Commit:
         child._children[self._hash] = self
 
     def export_to_tikz(self, ypos):
-        print("\\node[commit, " + colors[self._node_pos] + ", fill=" +  colors[self._node_pos] + "] (" + self._hash + ") at (" + str(.5 * self._node_pos) + "," + str(ypos) + ") {};")
+        print("\\node[commit, " + color(self._node_pos) + ", fill=" +  color(self._node_pos) + "] (" + self._hash + ") at (" + str(.5 * self._node_pos) + "," + str(ypos) + ") {};")
         print("\\node[right,xshift=10] (label_" + self._hash + ") at (" + self._hash + ".east) {\\verb!" + self._hash + ": " + self._message + "!};")
         #for child in self._children.itervalues():
         #    print("\\path[" + "blue" +"] (" + self._hash + ") to[out=90,in=-90] (" + child._hash + ");") 
@@ -102,7 +106,7 @@ class Repo:
         
         for commit in self._commits.values():
             for child in commit._children.values():
-                print("\\path[" +  colors[commit._node_pos] +"] (" + commit._hash + ") to[out=90,in=-90] (" + child._hash + ");") 
+                print("\\path[" +  color(commit._node_pos) +"] (" + commit._hash + ") to[out=90,in=-90] (" + child._hash + ");") 
 
         for branch in self._branches:
             print("\\node[branch,right,xshift=10] (" + branch._name + ") at (label_" + branch._hash + ".east) {\\lstinline{" + branch._name +"}};")
@@ -136,4 +140,4 @@ for line in return_output.split("\n"):
     if not line == "":
         r.add_branch(Branch(line))
 
-r.export_to_tikz()
\ No newline at end of file
+r.export_to_tikz()
index 84ff7138f3664c8f7cc923345a2fb4b39aa86b71..9a6c2634e1f7bfad3638517815a79f5b5eed48bf 100644 (file)
--- a/git1.tex
+++ b/git1.tex
 \node[right,xshift=10] (label_2256509) at (2256509.east) {\verb!2256509: [py] fixed automatic colors!};
 \node[commit, black, fill=black] (6e41ab0) at (0.0,6.0) {};
 \node[right,xshift=10] (label_6e41ab0) at (6e41ab0.east) {\verb!6e41ab0: [py] fixed order!};
-\node[commit, black, fill=black] (53e02cf) at (0.0,6.5) {};
+\node[commit, blue, fill=blue] (53e02cf) at (0.5,6.5) {};
 \node[right,xshift=10] (label_53e02cf) at (53e02cf.east) {\verb!53e02cf: [doc] test!};
-\node[commit, black, fill=black] (8dde7ec) at (0.0,7.0) {};
+\node[commit, blue, fill=blue] (8dde7ec) at (0.5,7.0) {};
 \node[right,xshift=10] (label_8dde7ec) at (8dde7ec.east) {\verb!8dde7ec: [doc] neues Hooks!};
-\node[commit, black, fill=black] (8024ece) at (0.0,7.5) {};
+\node[commit, blue, fill=blue] (8024ece) at (0.5,7.5) {};
 \node[right,xshift=10] (label_8024ece) at (8024ece.east) {\verb!8024ece: [doc] hook test!};
-\node[commit, black, fill=black] (7ef61eb) at (0.0,8.0) {};
+\node[commit, blue, fill=blue] (7ef61eb) at (0.5,8.0) {};
 \node[right,xshift=10] (label_7ef61eb) at (7ef61eb.east) {\verb!7ef61eb: [doc] hooktest 2!};
 \node[commit, brown, fill=brown] (d477a13) at (1.0,8.5) {};
 \node[right,xshift=10] (label_d477a13) at (d477a13.east) {\verb!d477a13: [doc] neuer Branch!};
-\node[commit, blue, fill=blue] (16d4f59) at (0.5,9.0) {};
+\node[commit, black, fill=black] (16d4f59) at (0.0,9.0) {};
 \node[right,xshift=10] (label_16d4f59) at (16d4f59.east) {\verb!16d4f59: [doc] test!};
-\node[commit, black, fill=black] (d2bf877) at (0.0,9.5) {};
+\node[commit, blue, fill=blue] (d2bf877) at (0.5,9.5) {};
 \node[right,xshift=10] (label_d2bf877) at (d2bf877.east) {\verb!d2bf877: [py] new git order!};
-\node[commit, black, fill=black] (6b30984) at (0.0,10.0) {};
+\node[commit, blue, fill=blue] (6b30984) at (0.5,10.0) {};
 \node[right,xshift=10] (label_6b30984) at (6b30984.east) {\verb!6b30984: [py] 2new git order!};
-\node[commit, blue, fill=blue] (feccffc) at (0.5,10.5) {};
+\node[commit, black, fill=black] (feccffc) at (0.0,10.5) {};
 \node[right,xshift=10] (label_feccffc) at (feccffc.east) {\verb!feccffc: Merge branch 'develop'!};
-\node[commit, blue, fill=blue] (1b6432e) at (0.5,11.0) {};
+\node[commit, black, fill=black] (1b6432e) at (0.0,11.0) {};
 \node[right,xshift=10] (label_1b6432e) at (1b6432e.east) {\verb!1b6432e: merge successful!};
-\node[commit, black, fill=black] (827f503) at (0.0,11.5) {};
+\node[commit, blue, fill=blue] (827f503) at (0.5,11.5) {};
 \node[right,xshift=10] (label_827f503) at (827f503.east) {\verb!827f503: [doc] Features/Bugs [py] reversed changed!};
-\node[commit, black, fill=black] (0ee95d1) at (0.0,12.0) {};
+\node[commit, blue, fill=blue] (0ee95d1) at (0.5,12.0) {};
 \node[right,xshift=10] (label_0ee95d1) at (0ee95d1.east) {\verb!0ee95d1: [doc] Hook test!};
-\node[commit, black, fill=black] (0009b09) at (0.0,12.5) {};
+\node[commit, blue, fill=blue] (0009b09) at (0.5,12.5) {};
 \node[right,xshift=10] (label_0009b09) at (0009b09.east) {\verb!0009b09: [doc] Hook2 test!};
-\node[commit, black, fill=black] (494a6ba) at (0.0,13.0) {};
+\node[commit, blue, fill=blue] (494a6ba) at (0.5,13.0) {};
 \node[right,xshift=10] (label_494a6ba) at (494a6ba.east) {\verb!494a6ba: [doc] Hook2 test!};
-\path[black] (0009b09) to[out=90,in=-90] (494a6ba);
-\path[black] (0ee95d1) to[out=90,in=-90] (0009b09);
-\path[black] (827f503) to[out=90,in=-90] (0ee95d1);
-\path[blue] (feccffc) to[out=90,in=-90] (1b6432e);
-\path[black] (6b30984) to[out=90,in=-90] (827f503);
-\path[black] (6b30984) to[out=90,in=-90] (feccffc);
-\path[black] (d2bf877) to[out=90,in=-90] (6b30984);
-\path[blue] (16d4f59) to[out=90,in=-90] (feccffc);
-\path[black] (7ef61eb) to[out=90,in=-90] (d477a13);
-\path[black] (7ef61eb) to[out=90,in=-90] (d2bf877);
-\path[black] (8024ece) to[out=90,in=-90] (7ef61eb);
-\path[black] (8dde7ec) to[out=90,in=-90] (8024ece);
-\path[black] (53e02cf) to[out=90,in=-90] (8dde7ec);
+\node[commit, blue, fill=blue] (ddec20f) at (0.5,13.5) {};
+\node[right,xshift=10] (label_ddec20f) at (ddec20f.east) {\verb!ddec20f: [doc] lsting Hooks!};
+\node[commit, black, fill=black] (65dae54) at (0.0,14.0) {};
+\node[right,xshift=10] (label_65dae54) at (65dae54.east) {\verb!65dae54: Merge branch 'develop'!};
+\path[blue] (ddec20f) to[out=90,in=-90] (65dae54);
+\path[blue] (494a6ba) to[out=90,in=-90] (ddec20f);
+\path[blue] (0009b09) to[out=90,in=-90] (494a6ba);
+\path[blue] (0ee95d1) to[out=90,in=-90] (0009b09);
+\path[blue] (827f503) to[out=90,in=-90] (0ee95d1);
+\path[black] (1b6432e) to[out=90,in=-90] (65dae54);
+\path[black] (feccffc) to[out=90,in=-90] (1b6432e);
+\path[blue] (6b30984) to[out=90,in=-90] (827f503);
+\path[blue] (6b30984) to[out=90,in=-90] (feccffc);
+\path[blue] (d2bf877) to[out=90,in=-90] (6b30984);
+\path[black] (16d4f59) to[out=90,in=-90] (feccffc);
+\path[blue] (7ef61eb) to[out=90,in=-90] (d477a13);
+\path[blue] (7ef61eb) to[out=90,in=-90] (d2bf877);
+\path[blue] (8024ece) to[out=90,in=-90] (7ef61eb);
+\path[blue] (8dde7ec) to[out=90,in=-90] (8024ece);
+\path[blue] (53e02cf) to[out=90,in=-90] (8dde7ec);
 \path[black] (6e41ab0) to[out=90,in=-90] (16d4f59);
 \path[black] (6e41ab0) to[out=90,in=-90] (53e02cf);
 \path[black] (2256509) to[out=90,in=-90] (6e41ab0);
@@ -84,8 +91,8 @@
 \path[black] (e5c3cd5) to[out=90,in=-90] (9ebee64);
 \path[black] (d78896f) to[out=90,in=-90] (e5c3cd5);
 \path[black] (a6f6d74) to[out=90,in=-90] (d78896f);
-\node[branch,right,xshift=10] (develop) at (label_494a6ba.east) {\lstinline{develop}};
+\node[branch,right,xshift=10] (develop) at (label_ddec20f.east) {\lstinline{develop}};
 \node[branch,right,xshift=10] (feature/python) at (label_6b30984.east) {\lstinline{feature/python}};
 \node[branch,right,xshift=10] (feature/python2) at (label_d477a13.east) {\lstinline{feature/python2}};
-\node[branch,right,xshift=10] (master) at (label_1b6432e.east) {\lstinline{master}};
+\node[branch,right,xshift=10] (master) at (label_65dae54.east) {\lstinline{master}};
 \end{tikzpicture}
index 356f3364201c1a5c19e6f89705f9a257fb6b328e..4c9b99ed3a972a110eb08f5761b90df56087c498 100644 (file)
Binary files a/text-output.pdf and b/text-output.pdf differ