Skip to content

How do I rotate something around the center? #1595

Answered by ghost
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

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.

  • I am calculating the center point of the original text layer
  • Rotating the text layer
  • Calculating the center point of the rotated text layer
  • Using two center points to calculate vector that is then used to offset where to draw (origin) of the text layer.
             var centerPointTranslationVector = new Vector2();

            if (text.Rotate.HasValue)
            {
                var originalLayerCenterPoint = new Point
                {
                    X = text.Boundaries.TopLeft.X + textLayer.Wid…

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
6 replies
@antonfirsov
Comment options

@JimBobSquarePants
Comment options

@JimBobSquarePants
Comment options

@antonfirsov
Comment options

@tocsoft
Comment options

Comment options

You must be logged in to vote
1 reply
@antonfirsov
Comment options

Comment options

You must be logged in to vote
2 replies
@ghost
Comment options

@ghost
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants