Sergey Y.
01/26/2024, 12:09 AMSergey Y.
01/26/2024, 12:09 AMModifier.graphicsLayer {}
(as shown in the screenshot).
My challenge arises with graphicsLayer
demanding a transformOrigin
specification, which dictates the pivot point for transformations. Calculating this pivot point is not straightforward, and the fractional nature of transformOrigin
adds complexity.
To address this, I applied the temporary matrix directly to the Canvas used for drawing the path, which works but introduces an additional dependency into the widget hierarchy, diverging from simply modifying the composable graphics layer (as illustrated in another screenshot).
🧵 Could we consider enhancing the Modifier API to include such functionality in the future, or are there technical limitations at present? For comparison, my colleagues working with SwiftUI on iOS have a modifier that performs this task directly, as demonstrated in the accompanying screenshot.Sergey Y.
01/26/2024, 12:11 AMSergey Y.
01/26/2024, 12:12 AMdewildte
01/26/2024, 12:23 AMSergey Y.
01/26/2024, 12:23 AMSergey Y.
01/26/2024, 12:28 AMromainguy
01/26/2024, 12:28 AMromainguy
01/26/2024, 12:31 AMSergey Y.
01/26/2024, 12:35 AMNader Jawad
01/26/2024, 12:38 AMSergey Y.
01/26/2024, 12:39 AMNader Jawad
01/26/2024, 12:39 AMNader Jawad
01/26/2024, 12:39 AMNader Jawad
01/26/2024, 12:40 AMSergey Y.
01/26/2024, 12:40 AMIt seems like you want the transformOrigin to be relative to the handle have you tried doing this?Ideally, I wouldn't want to calculate any transformOrigins at all; I'd prefer to simply concatenate it with the drawing matrix.
Sergey Y.
01/26/2024, 12:41 AMAnd in the case of the triangle with the handle at the center the transformOrigin should be 0.5, 0 indicating the middle of the triangle at the topI tried. That approach wouldn't work on rotated objects, as their orientation changes the dynamics of the transformation.
romainguy
01/26/2024, 12:42 AMgraphicsLayer
that takes a matrix directly as the transformromainguy
01/26/2024, 12:43 AMromainguy
01/26/2024, 12:43 AMSergey Y.
01/26/2024, 12:43 AMOne way we could address this is by having a version ofThat's exactly what I was looking for, and it's something SwiftUI already offers.that takes a matrix directly as the transforgraphicsLayer
Sergey Y.
01/26/2024, 12:44 AMExtracting scale/rotation/translation properly can be trickyCan't we just concatenate it as is?
romainguy
01/26/2024, 12:45 AMromainguy
01/26/2024, 12:45 AMromainguy
01/26/2024, 12:45 AMSergey Y.
01/26/2024, 12:46 AMromainguy
01/26/2024, 12:46 AMSergey Y.
01/26/2024, 12:47 AMromainguy
01/26/2024, 12:48 AMRenderNode
allowsSergey Y.
01/26/2024, 12:51 AMromainguy
01/26/2024, 12:52 AMdrawWithContent()
?romainguy
01/26/2024, 12:53 AMSergey Y.
01/26/2024, 12:53 AMSergey Y.
01/26/2024, 12:54 AMSergey Y.
01/26/2024, 12:55 AMromainguy
01/26/2024, 12:55 AMSergey Y.
01/26/2024, 12:57 AMNader Jawad
01/26/2024, 3:53 AMmohamed rejeb
01/26/2024, 8:08 AMSergey Y.
01/26/2024, 10:09 AMSergey Y.
01/26/2024, 2:38 PMdewildte
01/26/2024, 2:41 PMSergey Y.
01/26/2024, 2:54 PMdewildte
01/26/2024, 3:00 PMSergey Y.
01/26/2024, 3:01 PMromainguy
01/26/2024, 3:47 PMColton Idle
02/01/2024, 2:46 PMSergey Y.
02/01/2024, 3:11 PM