diff options
Diffstat (limited to 'lib/elements/utils/stroke_to_satin.py')
| -rw-r--r-- | lib/elements/utils/stroke_to_satin.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/elements/utils/stroke_to_satin.py b/lib/elements/utils/stroke_to_satin.py index 6e6367aa..e75ca5d3 100644 --- a/lib/elements/utils/stroke_to_satin.py +++ b/lib/elements/utils/stroke_to_satin.py @@ -33,7 +33,7 @@ def convert_path_to_satin(path, stroke_width, style_args, rungs_at_nodes=False): if sections: joined_satin = list(sections)[0] for satin in sections[1:]: - joined_satin = merge(joined_satin, satin) + joined_satin = _merge(joined_satin, satin) return joined_satin return None @@ -279,25 +279,18 @@ def generate_rungs(path, stroke_width, left_rail, right_rail, rungs_at_nodes): return rungs -def merge(section, other_section): - """Merge this satin with another satin +def _merge(section, other_section): + """Merge two satin sections - This method expects that the provided satin continues on directly after - this one, as would be the case, for example, if the two satins were the - result of the split() method. - - Returns a new SatinColumn instance that combines the rails and rungs of - this satin and the provided satin. A rung is added at the end of this - satin. - - The returned SatinColumn will not be in the SVG document and will have - its transforms applied. + The two sections are expected to be contiguous; that is, the second one + starts where the first one ends. """ rails, rungs = section other_rails, other_rungs = other_section - if len(rails) != 2 or len(other_rails) != 2: - # weird non-satin things, give up and don't merge + if len(other_rails[0]) < 2 or len(other_rails[1]) < 2: + # Somehow we got a degenerate rail with only one (or no?) point. + # Ignore this one since it has zero length anyway. return section # remove first node of each other rail before merging (avoid duplicated nodes) |
