Add pointlog2svg utility for the thesis
[numtypysics.git] / pointlog2svg.py
blob67567f4daa8472db1b824cf842c664d288a715ef
1 #!/usr/bin/python
2 import sys
4 ORIGINAL, TABLE = (800, 480), (1024, 768)
5 STYLE = 'fill:#000000;opacity:.2;'
7 cx = lambda x: int(x)*ORIGINAL[0]/TABLE[0]
8 cy = lambda y: int(y)*ORIGINAL[1]/TABLE[1]
10 print '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
11 print ('<svg xmlns="http://www.w3.org/2000/svg" width="%d" '+
12 'height="%d" version="1.1">') % ORIGINAL
14 for line in sys.stdin:
15 line = line.strip().split('/')
16 if len(line) != 4:
17 continue
18 x, y, curid, timestamp = line
19 print ('<path style="%s" d="m %d,%d a 5.5,5.5 0 1 1'+
20 '-11,0 5.5,5.5 0 1 1 11,0 z"/>') % (STYLE, cx(x), cy(y))
22 print '</svg>'