|
|
@ -141,6 +141,17 @@ def generate_code(lines, args): |
|
|
|
return code |
|
|
|
|
|
|
|
|
|
|
|
def generate_raw(lines, args): |
|
|
|
"""Generate raw line coordinates""" |
|
|
|
ox, oy = int(args.offset[0]), int(args.offset[1]) |
|
|
|
code = "" |
|
|
|
|
|
|
|
for (x_end, y_end), (x_start, y_start) in lines: |
|
|
|
code += f"{x_start} {y_start} {x_end} {y_end}\n" |
|
|
|
|
|
|
|
return code |
|
|
|
|
|
|
|
|
|
|
|
# From Zezeombye's BIDE |
|
|
|
def get_coord(start, end): |
|
|
|
"""Convert a pair of coordonates to the appropriate x+yT Multi DrawStat output""" |
|
|
@ -174,6 +185,7 @@ if __name__ == "__main__": |
|
|
|
parser.add_argument('-p', '--progress', action='store_true', help='print progress info') |
|
|
|
parser.add_argument('-s', '--show', action='store_true', help='show the result') |
|
|
|
parser.add_argument('-d', '--draw', action='store_true', help='draw the result into a new file') |
|
|
|
parser.add_argument('-r', '--raw', action='store_true', help='print raw line coordinates') |
|
|
|
|
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
@ -194,10 +206,15 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
if args.info: |
|
|
|
print_stats(image) |
|
|
|
|
|
|
|
lines = get_lines(image) |
|
|
|
lines = removing_useless(lines) |
|
|
|
lines = get_best_solution(image, lines) |
|
|
|
code = generate_code(lines, args) |
|
|
|
|
|
|
|
if args.raw: |
|
|
|
code = generate_raw(lines, args) |
|
|
|
else: |
|
|
|
code = generate_code(lines, args) |
|
|
|
|
|
|
|
if args.draw or args.show: |
|
|
|
export = Image.new('RGB', image.size, 'white') |
|
|
|