Skip to content

Unexpected order of operations when combining flip and offset #31

@jwlarocque

Description

@jwlarocque

I noticed that when using the flip options, offsets are applied before the flip. In my opinion this is unintuitive and I would propose either changing it (since the feature is relatively new, this hopefully wouldn't break too many workflows) or documenting the behavior in the readme.

Relevant code:

document.translate(offset_x, offset_y)
invert_x = config.get("invert_x", False)
invert_y = config.get("invert_y", False)
flip_x = config.get("horizontal_flip", False)
flip_y = config.get("vertical_flip", False)
# transform the document according to inversion parameters
if invert_x or invert_y:
document = invert_axis(document, invert_x, invert_y)
if flip_x or flip_y:
document = invert_axis(
document, flip_x, flip_y, whole_page=True, unit_scale=unit_scale
)

Example of current behavior (gcode)

SVG 175mm tall, with a line segment in the top left: ((10, 10), (30, 10))

profile toml:

offset_x = 45
offset_y = 45

When vertical_flip = false, I get this gcode, as expected:

G0 X55 Y55
G0 X75 Y55

When vertical_flip = true, I would expect:

G0 X55 Y210
G0 X75 Y210

but instead I get:

G0 X55 Y120
G0 X75 Y120

(The expected result can be achieved with offset_y = -45.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions