inkstitch/lib/api/stitch_plan.py

26 wiersze
813 B
Python
Czysty Zwykły widok Historia

2021-03-12 04:17:19 +00:00
# Authors: see git history
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
2020-04-28 16:34:05 +00:00
from flask import Blueprint, g, jsonify
2021-08-07 16:18:55 +00:00
from ..stitch_plan import stitch_groups_to_stitch_plan
2020-04-28 16:34:05 +00:00
stitch_plan = Blueprint('stitch_plan', __name__)
@stitch_plan.route('')
def get_stitch_plan():
if not g.extension.get_elements():
return dict(colors=[], stitch_blocks=[], commands=[])
metadata = g.extension.get_inkstitch_metadata()
collapse_len = metadata['collapse_len_mm']
2022-06-22 13:22:34 +00:00
min_stitch_len = metadata['min_stitch_len_mm']
2021-08-07 16:37:17 +00:00
patches = g.extension.elements_to_stitch_groups(g.extension.elements)
2022-06-22 13:22:34 +00:00
stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len)
2020-04-28 16:34:05 +00:00
return jsonify(stitch_plan)