Example #1
0
 /// <summary>
 /// Multiplies two matrices together and returns the resulting matrix.
 /// </summary>
 /// <param name="value1">The first source matrix.</param>
 /// <param name="value2">The second source matrix.</param>
 /// <returns>The product matrix.</returns>
 public static SKMatrix Multiply(SKMatrix value1, SKMatrix value2)
 {
     return ToSKMatrix(
         (value1.ScaleX * value2.ScaleX) + (value1.SkewY * value2.SkewX),
         (value1.ScaleX * value2.SkewY) + (value1.SkewY * value2.ScaleY),
         (value1.SkewX * value2.ScaleX) + (value1.ScaleY * value2.SkewX),
         (value1.SkewX * value2.SkewY) + (value1.ScaleY * value2.ScaleY),
         (value1.TransX * value2.ScaleX) + (value1.TransY * value2.SkewX) + value2.TransX,
         (value1.TransX * value2.SkewY) + (value1.TransY * value2.ScaleY) + value2.TransY);
 }
Example #2
0
		public static SKShader CreateLinearGradient (SKPoint start, SKPoint end, SKColor [] colors, float [] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
		{
			if (colors == null)
				throw new ArgumentNullException (nameof (colors));
			if (colorPos == null) {
				return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient (new SKPoint [] { start, end }, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
			} else {
				if (colors.Length != colorPos.Length)
					throw new ArgumentException ("The number of colors must match the number of color positions.");
				return GetObject<SKShader> (SkiaApi.sk_shader_new_linear_gradient (new SKPoint [] { start, end }, colors, colorPos, colors.Length, mode, ref localMatrix));
			}
		}
        public static SKMatrix ToSKMatrix(this Matrix m)
        {
            var sm = new SKMatrix
            {
                ScaleX = (float)m.M11,
                SkewX = (float)m.M21,
                TransX = (float)m.M31,
                SkewY = (float)m.M12,
                ScaleY = (float)m.M22,
                TransY = (float)m.M32,
                Persp0 = 0,
                Persp1 = 0,
                Persp2 = 1
            };

            return sm;
        }
Example #4
0
		public extern static sk_shader_t sk_shader_new_sweep_gradient(ref SKPoint center, [In] SKColor[] colors, IntPtr colorPosZero, int count, ref SKMatrix matrixZero);
Example #5
0
 public static void Concat(ref SKMatrix target, ref SKMatrix first, ref SKMatrix second)
 {
     SkiaApi.sk_matrix_concat(ref target, ref first, ref second);
 }
Example #6
0
        static void SetSinCos(ref SKMatrix matrix, float sin, float cos, float pivotx, float pivoty)
        {
            float oneMinusCos = 1 - cos;

            matrix.scaleX = cos;
            matrix.skewX = -sin;
            matrix.transX = sdot(sin, pivoty, oneMinusCos, pivotx);
            matrix.skewY = sin;
            matrix.scaleY = cos;
            matrix.transY = sdot(-sin, pivotx, oneMinusCos, pivoty);
            matrix.persp0 = 0;
            matrix.persp1 = 0;
            matrix.persp2 = 1;
#if OPTIMIZED_SKMATRIX
			matrix.typeMask = Mask.Unknown | Mask.OnlyPerspectiveValid;
#endif
        }
Example #7
0
		public static SKPathEffect Create2DLine(float width, SKMatrix matrix)
		{
			return GetObject<SKPathEffect>(SkiaApi.sk_path_effect_create_2d_line(width, ref matrix));
		}
Example #8
0
		public bool GetMatrix (float distance, out SKMatrix matrix, MatrixFlags flags)
		{
			return SkiaApi.sk_pathmeasure_get_matrix (Handle, distance, out matrix, flags);
		}
Example #9
0
 /// <summary>
 /// Transforms a point by this matrix.
 /// </summary>
 /// <param name="matrix">The matrix to use as a transformation matrix.</param>
 /// <param name="point">>The original point to apply the transformation.</param>
 /// <returns>The result of the transformation for the input point.</returns>
 public static SKPoint TransformPoint(SKMatrix matrix, SKPoint point)
 {
     return new SKPoint(
         (point.X * matrix.ScaleX) + (point.Y * matrix.SkewX) + matrix.TransX,
         (point.X * matrix.SkewY) + (point.Y * matrix.ScaleY) + matrix.TransY);
 }
Example #10
0
 public void Transform(SKMatrix matrix)
 {
     SkiaApi.sk_path_transform(Handle, ref matrix);
 }
Example #11
0
		public static SKShader CreateLocalMatrix (SKShader shader, SKMatrix localMatrix)
		{
			if (shader == null)
				throw new ArgumentNullException (nameof (shader));
			return GetObject<SKShader> (SkiaApi.sk_shader_new_local_matrix (shader.Handle, ref localMatrix));
		}
Example #12
0
		public static SKShader CreateBitmap (SKBitmap src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix)
		{
			if (src == null)
				throw new ArgumentNullException (nameof (src));
			return GetObject<SKShader> (SkiaApi.sk_shader_new_bitmap (src.Handle, tmx, tmy, ref localMatrix));
		}
Example #13
0
		public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor [] colors, float [] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
		{
			if (colors == null)
				throw new ArgumentNullException (nameof (colors));
			if (colorPos == null) {
				return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, IntPtr.Zero, colors.Length, mode, ref localMatrix));
			} else {
				if (colors.Length != colorPos.Length)
					throw new ArgumentException ("The number of colors must match the number of color positions.");
				return GetObject<SKShader> (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, colorPos, colors.Length, mode, ref localMatrix));
			}
		}
Example #14
0
		public static SKShader CreateSweepGradient (SKPoint center, SKColor [] colors, float [] colorPos, SKMatrix localMatrix)
		{
			if (colors == null)
				throw new ArgumentNullException (nameof (colors));
			if (colorPos == null) {
				return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, IntPtr.Zero, colors.Length, ref localMatrix));
			} else {
				if (colors.Length != colorPos.Length)
					throw new ArgumentException ("The number of colors must match the number of color positions.");
				return GetObject<SKShader> (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, colorPos, colors.Length, ref localMatrix));
			}
		}
Example #15
0
		public extern static sk_shader_t sk_shader_new_two_point_conical_gradient(ref SKPoint start, float startRadius, ref SKPoint end, float endRadius, [In] SKColor[] colors, IntPtr colorPosZero, int count, SKShaderTileMode mode, ref SKMatrix matrix);
Example #16
0
 public extern static sk_shader_t sk_shader_new_radial_gradient(ref SKPoint center, float radius, [In] SKColor[] colors, float[] colorPos, int count, SKShaderTileMode mode, ref SKMatrix matrix);
Example #17
0
 public extern static sk_shader_t sk_shader_new_two_point_conical_gradient(ref SKPoint start, float startRadius, ref SKPoint end, float endRadius, [In] SKColor[] colors, float[] colorPos, int count, SKShaderTileMode mode, ref SKMatrix matrix);
Example #18
0
 public bool GetMatrix(float distance, out SKMatrix matrix, MatrixFlags flags)
 {
     return(SkiaApi.sk_pathmeasure_get_matrix(Handle, distance, out matrix, flags));
 }
Example #19
0
        public void DrawPicture(SKPicture picture, float x, float y, SKPaint paint = null)
        {
            var matrix = SKMatrix.MakeTranslation(x, y);

            DrawPicture(picture, ref matrix, paint);
        }
Example #20
0
 public bool TryInvert(out SKMatrix inverse)
 {
     return(SkiaApi.sk_matrix_try_invert(ref this, out inverse) != 0);
 }
Example #21
0
 /// <summary>
 /// Prepends a translation around the center of provided matrix.
 /// </summary>
 /// <param name="matrix">The matrix to prepend translation.</param>
 /// <param name="offsetX">X-coordinate offset.</param>
 /// <param name="offsetY">Y-coordinate offset.</param>
 /// <returns>The created translation matrix.</returns>
 public static SKMatrix TranslatePrepend(SKMatrix matrix, double offsetX, double offsetY)
 {
     return Multiply(Translate(offsetX, offsetY), matrix);
 }
Example #22
0
 public static void Concat(ref SKMatrix target, ref SKMatrix first, ref SKMatrix second)
 {
     SkiaApi.sk_matrix_concat(ref target, ref first, ref second);
 }
Example #23
0
 public void DrawPicture(SKPicture picture, ref SKMatrix matrix, SKPaint paint = null)
 {
     if (picture == null)
         throw new ArgumentNullException ("picture");
     SkiaApi.sk_canvas_draw_picture (Handle, picture.Handle, ref matrix, paint == null ? IntPtr.Zero : paint.Handle);
 }
Example #24
0
 public static void PreConcat(ref SKMatrix target, SKMatrix matrix)
 {
     SkiaApi.sk_matrix_pre_concat(ref target, ref matrix);
 }
Example #25
0
        public static SKMatrix MakeRotation(float radians, float pivotx, float pivoty)
        {
            var sin = (float)Math.Sin(radians);
            var cos = (float)Math.Cos(radians);

            var matrix = new SKMatrix();
            SetSinCos(ref matrix, sin, cos, pivotx, pivoty);
            return matrix;
        }
Example #26
0
 public static void PostConcat(ref SKMatrix target, ref SKMatrix matrix)
 {
     SkiaApi.sk_matrix_post_concat(ref target, ref matrix);
 }
Example #27
0
 public static void RotateDegrees(ref SKMatrix matrix, float degrees)
 {
     var sin = (float)Math.Sin(degrees * degToRad);
     var cos = (float)Math.Cos(degrees * degToRad);
     SetSinCos(ref matrix, sin, cos);
 }
Example #28
0
 public static void MapRect(ref SKMatrix matrix, out SKRect dest, ref SKRect source)
 {
     SkiaApi.sk_matrix_map_rect(ref matrix, out dest, ref source);
 }
Example #29
0
 public static void PostConcat(ref SKMatrix target, ref SKMatrix matrix)
 {
     SkiaApi.sk_matrix_post_concat(ref target, ref matrix);
 }
Example #30
0
 public void GetMatrix(ref SKMatrix matrix)
 {
     SkiaApi.sk_3dview_get_matrix(Handle, ref matrix);
 }
Example #31
0
 public extern static sk_shader_t sk_shader_new_linear_gradient([In] SKPoint[] points, [In] SKColor[] colors, float[] colorPos, int count, SKShaderTileMode mode, ref SKMatrix matrix);
Example #32
0
 public void SetMatrix(SKMatrix matrix)
 {
     SkiaApi.sk_canvas_set_matrix(Handle, &matrix);
 }
Example #33
0
 public extern static sk_shader_t sk_shader_new_sweep_gradient(ref SKPoint center, [In] SKColor[] colors, float[] colorPos, int count, ref SKMatrix matrixZero);
Example #34
0
        // CreateMatrix

        public static SKImageFilter CreateMatrix(SKMatrix matrix, SKFilterQuality quality, SKImageFilter input = null)
        {
            return(GetObject <SKImageFilter>(SkiaApi.sk_imagefilter_new_matrix(&matrix, quality, input == null ? IntPtr.Zero : input.Handle)));
        }
Example #35
0
 public void Offset(float dx, float dy)
 {
     Transform(SKMatrix.MakeTranslation(dx, dy));
 }
Example #36
0
 public static SKPathEffect Create2DLine(float width, SKMatrix matrix)
 {
     return(GetObject <SKPathEffect>(SkiaApi.sk_path_effect_create_2d_line(width, ref matrix)));
 }
Example #37
0
 public void AddPath(SKPath other, ref SKMatrix matrix, AddMode mode)
 {
     AddPath(other, ref matrix, (SKPathAddMode)mode);
 }
Example #38
0
 public void Draw(SKCanvas canvas, ref SKMatrix matrix) =>
 SkiaApi.sk_drawable_draw(Handle, canvas.Handle, ref matrix);
Example #39
0
 /// <summary>
 /// Prepends a scale around the center of provided matrix.
 /// </summary>
 /// <param name="matrix">The matrix to prepend scale.</param>
 /// <param name="scaleX">Scaling factor that is applied along the x-axis.</param>
 /// <param name="scaleY">Scaling factor that is applied along the y-axis.</param>
 /// <param name="centerX">The center X-coordinate of the scaling.</param>
 /// <param name="centerY">The center Y-coordinate of the scaling.</param>
 /// <returns>The created scaling matrix.</returns>
 public static SKMatrix ScaleAtPrepend(SKMatrix matrix, double scaleX, double scaleY, double centerX, double centerY)
 {
     return Multiply(ScaleAt(scaleX, scaleY, centerX, centerY), matrix);
 }
Example #40
0
        public void Draw(SKCanvas canvas, float x, float y)
        {
            var matrix = SKMatrix.MakeTranslation(x, y);

            Draw(canvas, ref matrix);
        }
Example #41
0
 public SKShader ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) =>
 SKShader.GetObject(SkiaApi.sk_bitmap_make_shader(Handle, tmx, tmy, &localMatrix));
Example #42
0
 public static SKImage FromPicture(SKPicture picture, SKSizeI dimensions, SKMatrix matrix)
 {
     return(FromPicture(picture, dimensions, matrix, null));
 }
Example #43
0
		public static SKImageFilter CreateMatrix(SKMatrix matrix, SKFilterQuality quality, SKImageFilter input = null)
		{
			return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_matrix(ref matrix, quality, input == null ? IntPtr.Zero : input.Handle));
		}
Example #44
0
 public SKShader ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKMatrix localMatrix)
 {
     return(GetObject <SKShader> (SkiaApi.sk_image_make_shader(Handle, tileX, tileY, ref localMatrix)));
 }
Example #45
0
 public void Concat(ref SKMatrix m)
 {
     SkiaApi.sk_canvas_concat (Handle, ref m);
 }
Example #46
0
 public extern static void sk_canvas_concat(sk_canvas_t t, ref SKMatrix m);
Example #47
0
 public void SetMatrix(SKMatrix matrix)
 {
     SkiaApi.sk_canvas_set_matrix (Handle, ref matrix);
 }
Example #48
0
 public extern static void sk_canvas_draw_picture(sk_canvas_t t, sk_picture_t pict, ref SKMatrix mat, sk_paint_t paint);
Example #49
0
		public static SKPathEffect Create2DPath(SKMatrix matrix, SKPath path)
		{
			if (path == null)
				throw new ArgumentNullException(nameof(path));
			return GetObject<SKPathEffect>(SkiaApi.sk_path_effect_create_2d_path(ref matrix, path.Handle));
		}
Example #50
0
 public extern static void sk_canvas_set_matrix(sk_canvas_t canvas, ref SKMatrix matrix);
Example #51
0
        static void SetSinCos(ref SKMatrix matrix, float sin, float cos)
        {
            matrix.scaleX = cos;
            matrix.skewX = -sin;
            matrix.transX = 0;
            matrix.skewY = sin;
            matrix.scaleY = cos;
            matrix.transY = 0;
            matrix.persp0 = 0;
            matrix.persp1 = 0;
            matrix.persp2 = 1;
#if OPTIMIZED_SKMATRIX
			matrix.typeMask = Mask.Unknown | Mask.OnlyPerspectiveValid;
#endif
        }
Example #52
0
 public extern static void sk_canvas_get_total_matrix(sk_canvas_t canvas, ref SKMatrix matrix);
Example #53
0
 public static void Rotate(ref SKMatrix matrix, float radians)
 {
     var sin = (float)Math.Sin(radians);
     var cos = (float)Math.Cos(radians);
     SetSinCos(ref matrix, sin, cos);
 }
Example #54
0
 public extern static sk_imagefilter_t sk_imagefilter_new_matrix(ref SKMatrix matrix, SKFilterQuality quality, sk_imagefilter_t input /*NULL*/);
Example #55
0
 public bool TryInvert(out SKMatrix inverse)
 {
     return SkiaApi.sk_matrix_try_invert(ref this, out inverse) != 0;
 }
Example #56
0
 public extern static sk_shader_t sk_shader_new_local_matrix(sk_shader_t proxy, ref SKMatrix matrix);
Example #57
0
 public static void PreConcat(ref SKMatrix target, SKMatrix matrix)
 {
     SkiaApi.sk_matrix_pre_concat(ref target, ref matrix);
 }
Example #58
0
 public extern static sk_shader_t sk_shader_new_bitmap(sk_bitmap_t src, SKShaderTileMode tmx, SKShaderTileMode tmy, ref SKMatrix matrix);
Example #59
0
 public static void MapRect(ref SKMatrix matrix, out SKRect dest, ref SKRect source)
 {
     SkiaApi.sk_matrix_map_rect(ref matrix, out dest, ref source);
 }
Example #60
0
		public extern static sk_shader_t sk_shader_new_radial_gradient(ref SKPoint center, float radius, [In] SKColor[] colors, IntPtr colorPosZero, int count, SKShaderTileMode mode, ref SKMatrix matrix);