Пример #1
0
        public void Prepend()
        {
            var m = new Matrix (1, 2, 3, 4, 5, 6);
            m.Prepend (new Matrix (2, 4, 6, 8, 10, 12));

            CheckMatrix (new Matrix (14, 20, 30, 44, 51, 74), m);
        }
Пример #2
0
		public void Prepend ()
		{
			// NB pick matrices so that Append and Prepend give different results
			var m = new Matrix (1, 2, 3, 4, 5, 6);
			m.Prepend (new Matrix (6, 5, 4, 3, 2, 1));
			CheckMatrix (new Matrix (21, 32, 13, 20, 10, 14), m);
		}
Пример #3
0
		/// <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 ();
		}