From 9af10c2b7851e74f0f67fbbbcb2c299f566285f9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 5 May 2022 12:39:34 +0200 Subject: remove map sketches and added technical operation summary + discussion notes --- maps/mappdf.py | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100755 maps/mappdf.py (limited to 'maps/mappdf.py') diff --git a/maps/mappdf.py b/maps/mappdf.py deleted file mode 100755 index 4f4a45d..0000000 --- a/maps/mappdf.py +++ /dev/null @@ -1,56 +0,0 @@ -import sys -from struct import unpack -import svgutils.transform as sg -import svgutils.compose as sc - -SVG_TILE_SIZE = 24 -DPI = 96 -INCH = 2.54 -ROBOT_SIZE = 9.5 -ROBOT_SIZE_UNIT = "cm" - -RESIZE_FACTOR = ROBOT_SIZE / (SVG_TILE_SIZE / DPI * INCH) - -def read_tiles(): - tiles = [] - for x in range(16): - tile = open(f"./tiles/{x:x}.svg", "r") - tiles.append(tile.read()) - tile.close() - return tiles - -def mappdf(filename): - file = open(filename, 'rb') - contents = file.read() - file.close() - tiles = read_tiles() - - width, height = unpack('>HH', contents[0:4]) - - target = sg.SVGFigure() - target.set_size((f"{width * SVG_TILE_SIZE}px", f"{height * SVG_TILE_SIZE}px")) - - for y in range(height): - for x in range(width): - nibble = x + y * width - byte = int(nibble / 2) - shift = byte * 2 - nibble + 1 - num = (contents[4 + byte] & (0xf << 4 * shift)) >> 4 * shift - - tile = sg.fromstring(tiles[num]).getroot() - tile.moveto(x * SVG_TILE_SIZE, y * SVG_TILE_SIZE) - target.append(tile) - - target.save(f"{filename}.svg") - target_scaled = sc.SVG(f"{filename}.svg") - target_scaled.scale(RESIZE_FACTOR) - target = sc.Figure(width * SVG_TILE_SIZE * RESIZE_FACTOR, height * SVG_TILE_SIZE * RESIZE_FACTOR, target_scaled) - target.save(f"{filename}.svg") - print(f"inkscape --export-pdf={filename}.pdf {filename}.svg") - - -if __name__ == "__main__": - if len(sys.argv) > 1: - mappdf(sys.argv[1]) - else: - exit(1) -- cgit v1.2.3