Describe the bug
When drawing a path, if you apply a transformation during the drawing of that path subsequent parts of the path should have that transformation applied. The Android, Qt and Winforms backends are not doing this, because they are building the path independently without any transformations applied, and then drawing at the end with the final transformation state.
Steps to reproduce
This
canvas.context.translate(100, 100)
for i in range(12):
canvas.context.rect(50, 0, 50, 10)
canvas.context.rotate(math.pi/6)
canvas.context.fill()
should produce a spinner-like image (as it does on HTML Canvas and cocoa backend Canvas):
The Qt backend produces this:
There is a test in #4054 which demonstrates the problem.
Expected behavior
When adding a shape to a path on the canvas' current path, the current transform should be applied to the shape. If the transform changes, subsequent shapes should be added with the new transform applied, but existing shapes should not change their location.
Screenshots
Windows and Qt test failure image from #4054:
Correct image:
Environment
- Operating System: Linux/Qt, Windows, Android
- Python version: All
- Software versions:
- Toga: current GitHub main
Logs
No response
Additional context
Fixing this will require some thought, because it is a fairly intrinsic problem with the way that the backends implementations are designed - it probably means tracking the current transform and applying it to the points that each drawing operation gets.
Additionally I'm not sure how things apply to things like line width: if you draw and then change the scale before stroking, does the old scale apply to the line width, or is it in the scale at the point of drawing? Some testing shows that changing scale doesn't change the line widths during rendering: it is the scale at the end which controls those things.
Describe the bug
When drawing a path, if you apply a transformation during the drawing of that path subsequent parts of the path should have that transformation applied. The Android, Qt and Winforms backends are not doing this, because they are building the path independently without any transformations applied, and then drawing at the end with the final transformation state.
Steps to reproduce
This
should produce a spinner-like image (as it does on HTML Canvas and cocoa backend Canvas):
The Qt backend produces this:
There is a test in #4054 which demonstrates the problem.
Expected behavior
When adding a shape to a path on the canvas' current path, the current transform should be applied to the shape. If the transform changes, subsequent shapes should be added with the new transform applied, but existing shapes should not change their location.
Screenshots
Windows and Qt test failure image from #4054:
Correct image:
Environment
Logs
No response
Additional context
Fixing this will require some thought, because it is a fairly intrinsic problem with the way that the backends implementations are designed - it probably means tracking the current transform and applying it to the points that each drawing operation gets.
Additionally I'm not sure how things apply to things like line width: if you draw and then change the scale before stroking, does the old scale apply to the line width, or is it in the scale at the point of drawing?Some testing shows that changing scale doesn't change the line widths during rendering: it is the scale at the end which controls those things.