-
Hi. I want to be able to draw text and rotate it around the center, rather than around the origin. What I am currently doing:
Is anyone able to help me with this, so I get the desired behavior? What I want to achieve is the below:What I am getting when using the Rotate function is the below (which is not what I want): |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
@nikolaimaximilian the
AffineTransformBuilder bld = new AffineTransformBuilder();
Vector2 origin = new Vector2(textLayer.Width, textLayer.Height) / 2;
bld.AppendTranslation(-origin );
bld.AppendRotationDegrees(degrees);
bld.AppendTranslation(origin);
textLayer.Mutate(c => c.Transform(bld)); @JimBobSquarePants I think there is space for API improvement. At least we could introduce an |
Beta Was this translation helpful? Give feedback.
-
Thank you all for the quick replies and help!! I am going to try using the AffineTransformBuilder tomorrow and let you know how I go! Thank you very much - love the support here!! |
Beta Was this translation helpful? Give feedback.
-
So I am getting closer now, but still not 100% there... Probably me just missing something or not using the correct center? This is what I am doing nowThe text without rotation is drawn in the specified X/Y from the text object:
The rotated text is now using the AffineTransformBuilder, but I am struggling to draw it at the right point so that it rotates around the center point of the original (non rotated) text. If you look at the image below (which is what I am getting), you can see that the rotated text still needs to move further up (and probably left a little bit too).
This is what I am getting now |
Beta Was this translation helpful? Give feedback.
-
The solution was very simple in the end, and something I tried doing form the start (but I must have missed or miscalculated something then)... Anyways, the below works perfectly fine.
Outcome is exactly what I was after.. Text that rotates around the center. |
Beta Was this translation helpful? Give feedback.
The solution was very simple in the end, and something I tried doing form the start (but I must have missed or miscalculated something then)...
Anyways, the below works perfectly fine.