public void Scale () { var m = Matrix.Identity; m.Scale (5, 6); CheckMatrix (new Matrix (5, 0, 0, 6, 0, 0), m); m = new Matrix (1, 2, 2, 1, 3, 3); m.Scale (5, 5); CheckMatrix (new Matrix (5, 10, 10, 5, 3, 3), m); }
/// <summary> /// Illustrates the use of matrix transforms to skew and reflect text /// </summary> public void Reflect (Context ctx, double x, double y) { ctx.Save (); ctx.SetLineWidth (1); TextLayout layout = new TextLayout (); layout.Text = "Reflected and Skewed Text"; layout.Font = Font.WithSize (16); Size size = layout.GetSize (); Rectangle r = new Rectangle (Point.Zero, size); // Draw text with no transformations at (x+0.5, y+0.5) ctx.Translate (x+0.5, y+0.5); // final move to specified location ctx.SetColor (Colors.Blue); ctx.DrawTextLayout (layout, 0, 0); // Use Matrix transforms to reflect Y-values and skew X-values by -0.5*Y // Note that transforms are prepended, so are actioned in reverse order // This is the same order that Backend Context transforms are applied Matrix m = new Matrix (); // Identity matrix Matrix s = new Matrix (1.0, 0.0, // new skew matrix -0.5, 1.0, 0.0, 0.0); m.Translate (0, size.Height); // Shift text back to place m.Prepend (s); // Skew X-values m.Scale (1, -1); // Reflect text Y-values m.Translate (0, -size.Height); // Shift text base to (0,0) ctx.ModifyCTM (m); // NB ctx.Translate (x+0.5, y+0.5) still active ctx.SetColor (Colors.DarkGray); ctx.Rectangle (r); ctx.Fill (); ctx.SetColor (Colors.LightBlue); ctx.DrawTextLayout (layout, 0, 0); ctx.Restore (); }