Skip to content

How to rotate a text before drawing #146

Answered by tocsoft
ggolda asked this question in Q&A
Discussion options

You must be logged in to vote
image.Mutate(x => x
          .SetDrawingTransform(Matrix3x2Extensions.CreateRotationDegrees(45, new PointF(50, 50))) // set a transform to be applied to all drawing operations
          .DrawText("foo bar", font, Color.Black, new PointF(50, 50))); // draw the text

The one gotcha you might hit is the rotation origin of the matrix thus you will most likely need/want to set the point in the CreateRotationDegrees(angle, point) call to the same as the text drawing point to get the result you expect otherwise we will end up rotating around 0,0 (top left) and you can end up with text in odd places.

This API can be used to apply full matrix transforms to the items being drawn so can also be used…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@tocsoft
Comment options

@ggolda
Comment options

@vrmvgf
Comment options

@tocsoft
Comment options

@vrmvgf
Comment options

Answer selected by ggolda
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