admin管理员组

文章数量:1124803

I'm trying to create a text effect like in the iconic Star Wars opening sequence using Skia (or SkiaSharp, but that doesn't matter).

Using the following code I can get the text to appear tilted backwards:

// Center of canvas
var xCenter = 1280.0f / 2;
var yCenter = 720.0f / 2;

// Translate center to origin
var matrix = SKMatrix44.CreateIdentity();
matrix = matrix.PreConcat(SKMatrix44.CreateTranslation(-xCenter, -yCenter,0));
matrix = matrix.PostConcat(SKMatrix44.CreateRotationDegrees(1, 0, 0, 45f));

// TODO Perspective transformation 

// Translate back to center
matrix = matrix.PostConcat(SKMatrix44.CreateTranslation(xCenter, yCenter, 0));

// Set the matrix
canvas.Concat(matrix);

But the perspective distortion (the text gets smaller “towards the back”) doesn't work for me.

本文标签: cSkia perspective matrix transformationStack Overflow