You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the canvas is transformed in negative x and y. However, since my canvas is set to use canvas.CartesianIV, with the origin at the top-left, I'd expected that when I requested a translation of 5, 5, then the translation would move 5 units right and 5 units down, towards the bottom-right. Instead, the canvas moves left and up instead, moving -5, -5. To achieve my intended result, I currently negate my translations before running Clip.
Is this expected behaviour?
The text was updated successfully, but these errors were encountered:
Hi David, it kind of is expected, but not ideal. All internal operations are in the regular coordinate system (ie. Cartesian I) while we allow a cosmetic change of coordinate system towards Cartesian IV, the one used mostly for imaging. Since the coordinate system change is set in the Context, the underlying Canvas is unaware. Not sure how we could improve this situation.
Thanks for the info, that makes sense. As a solution, would adding a wrapper method like ResizeCanvas to the Context be feasible? It could call Clip under the hood, deciding which direction to translate based on the Cartesian system set. This is pretty much what I’ve implemented in my own struct that has a canvas field on it.
That's a great idea, but it would need to work for all renderers. Currently only the Canvas renderer has a Clip method because we can still transform the drawn objects. For other renderers it has already been rendered and we have no way of changing the view I'm afraid...
In the current implementation of
Clip
:canvas/canvas.go
Lines 771 to 775 in f7585e3
the canvas is transformed in negative x and y. However, since my canvas is set to use
canvas.CartesianIV
, with the origin at the top-left, I'd expected that when I requested a translation of5, 5
, then the translation would move 5 units right and 5 units down, towards the bottom-right. Instead, the canvas moves left and up instead, moving-5, -5
. To achieve my intended result, I currently negate my translations before runningClip
.Is this expected behaviour?
The text was updated successfully, but these errors were encountered: