diff --git a/.gitignore b/.gitignore index 68ebbb2..bcd729b 100644 --- a/.gitignore +++ b/.gitignore @@ -160,8 +160,8 @@ cython_debug/ #.idea/ output/ -data/ legacy/ +data/ *.svg .DS_Store .VSCodeCounter/ \ No newline at end of file diff --git a/example/.gitkeep b/example/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/example/demo.json b/example/demo.json new file mode 100644 index 0000000..9722865 --- /dev/null +++ b/example/demo.json @@ -0,0 +1,46 @@ +{ + "type": 1, + "exit": { + "seq": "758" + }, + "lines": [ + [ + { + "type": 5, + "info": { + "main_name": "S1", + "sub_name": "", + "prov": "吉" + } + } + ], + [ + { + "type": 0, + "info": { + "text": "抚 松" + } + }, + { + "type": 7, + "info": { + "name": "长白山景区" + } + } + ], + [ + { + "type": 0, + "info": { + "text": "池西区" + } + }, + { + "type": 0, + "info": { + "text": "长白山机场" + } + } + ] + ] +} \ No newline at end of file diff --git a/rect.png b/rect.png deleted file mode 100644 index fcf0018..0000000 Binary files a/rect.png and /dev/null differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ed38fe2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +svgwrite +cairosvg +lxml +pillow \ No newline at end of file diff --git a/test/main.py b/test/main.py index 319b88e..fc7a610 100644 --- a/test/main.py +++ b/test/main.py @@ -1,5 +1,6 @@ import os import sys +import time sys.path.append(os.getcwd()) import svgwrite @@ -47,9 +48,9 @@ text_size = 40 * SCALE content_width = min_width content_height = min_height + exit_height + 2 * safe_area_size -data_file_name = input('data file name(./data/*.json):') +data_file_path = input('data file path(*.json):') -data_file_path = './data/{}.json'.format(data_file_name) +data_file_name = 'image_{}'.format(time.strftime('%Y%m%d%H%M%S')) svg_file_path = './output/{}.svg'.format(data_file_name) png_file_path = './output/{}.png'.format(data_file_name) # load data @@ -136,7 +137,7 @@ for line in lines: content_height = max(content_height, sum(line_heights) + 2 * exit_height + (len(line_heights) + 2) * space_size + 2 * safe_area_size) # rect -dwg = svgwrite.Drawing(svg_file_path.format(data_file_name), profile='tiny', width=content_width, height=content_height) +dwg = svgwrite.Drawing(svg_file_path, profile='tiny', width=content_width, height=content_height) if obj_type == 1: exit_item.draw(dwg, content_width - exit_item.width(), 0)