in ExampleGallery/TextDirectionControl.cs [136:179]
Matrix3x2 GetDirectionTransform(CanvasTextDirection direction)
{
var arrowBounds = arrow.ComputeStrokeBounds(4);
var arrowCenter = new Size(arrowBounds.Width, arrowBounds.Height).ToVector2() / 2;
Matrix3x2 directionTransform = Matrix3x2.Identity;
switch (direction)
{
case CanvasTextDirection.LeftToRightThenTopToBottom:
directionTransform = Matrix3x2.Identity;
break;
case CanvasTextDirection.RightToLeftThenTopToBottom:
directionTransform = Matrix3x2.CreateScale(-1, 1);
break;
case CanvasTextDirection.LeftToRightThenBottomToTop:
directionTransform = Matrix3x2.CreateScale(1, -1);
break;
case CanvasTextDirection.RightToLeftThenBottomToTop:
directionTransform = Matrix3x2.CreateScale(-1, -1);
break;
case CanvasTextDirection.TopToBottomThenLeftToRight:
directionTransform = Matrix3x2.CreateRotation((float)Math.PI / 2) * Matrix3x2.CreateScale(-1, 1);
break;
case CanvasTextDirection.BottomToTopThenLeftToRight:
directionTransform = Matrix3x2.CreateRotation((float)-Math.PI / 2);
break;
case CanvasTextDirection.TopToBottomThenRightToLeft:
directionTransform = Matrix3x2.CreateRotation((float)Math.PI / 2);
break;
case CanvasTextDirection.BottomToTopThenRightToLeft:
directionTransform = Matrix3x2.CreateRotation((float)-Math.PI / 2) * Matrix3x2.CreateScale(-1, 1);
break;
}
directionTransform = Matrix3x2.CreateTranslation(-arrowCenter) * directionTransform * Matrix3x2.CreateTranslation(arrowCenter);
return directionTransform;
}