/// <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); }
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; }
public extern static sk_shader_t sk_shader_new_sweep_gradient(ref SKPoint center, [In] SKColor[] colors, IntPtr colorPosZero, int count, ref SKMatrix matrixZero);
public static void Concat(ref SKMatrix target, ref SKMatrix first, ref SKMatrix second) { SkiaApi.sk_matrix_concat(ref target, ref first, ref second); }
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 }
public static SKPathEffect Create2DLine(float width, SKMatrix matrix) { return GetObject<SKPathEffect>(SkiaApi.sk_path_effect_create_2d_line(width, ref matrix)); }
public bool GetMatrix (float distance, out SKMatrix matrix, MatrixFlags flags) { return SkiaApi.sk_pathmeasure_get_matrix (Handle, distance, out matrix, flags); }
/// <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); }
public void Transform(SKMatrix matrix) { SkiaApi.sk_path_transform(Handle, ref matrix); }
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)); }
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)); }
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)); } }
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)); } }
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);
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);
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);
public bool GetMatrix(float distance, out SKMatrix matrix, MatrixFlags flags) { return(SkiaApi.sk_pathmeasure_get_matrix(Handle, distance, out matrix, flags)); }
public void DrawPicture(SKPicture picture, float x, float y, SKPaint paint = null) { var matrix = SKMatrix.MakeTranslation(x, y); DrawPicture(picture, ref matrix, paint); }
public bool TryInvert(out SKMatrix inverse) { return(SkiaApi.sk_matrix_try_invert(ref this, out inverse) != 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); }
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); }
public static void PreConcat(ref SKMatrix target, SKMatrix matrix) { SkiaApi.sk_matrix_pre_concat(ref target, ref matrix); }
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; }
public static void PostConcat(ref SKMatrix target, ref SKMatrix matrix) { SkiaApi.sk_matrix_post_concat(ref target, ref matrix); }
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); }
public static void MapRect(ref SKMatrix matrix, out SKRect dest, ref SKRect source) { SkiaApi.sk_matrix_map_rect(ref matrix, out dest, ref source); }
public void GetMatrix(ref SKMatrix matrix) { SkiaApi.sk_3dview_get_matrix(Handle, ref matrix); }
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);
public void SetMatrix(SKMatrix matrix) { SkiaApi.sk_canvas_set_matrix(Handle, &matrix); }
public extern static sk_shader_t sk_shader_new_sweep_gradient(ref SKPoint center, [In] SKColor[] colors, float[] colorPos, int count, ref SKMatrix matrixZero);
// 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))); }
public void Offset(float dx, float dy) { Transform(SKMatrix.MakeTranslation(dx, dy)); }
public static SKPathEffect Create2DLine(float width, SKMatrix matrix) { return(GetObject <SKPathEffect>(SkiaApi.sk_path_effect_create_2d_line(width, ref matrix))); }
public void AddPath(SKPath other, ref SKMatrix matrix, AddMode mode) { AddPath(other, ref matrix, (SKPathAddMode)mode); }
public void Draw(SKCanvas canvas, ref SKMatrix matrix) => SkiaApi.sk_drawable_draw(Handle, canvas.Handle, ref matrix);
/// <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); }
public void Draw(SKCanvas canvas, float x, float y) { var matrix = SKMatrix.MakeTranslation(x, y); Draw(canvas, ref matrix); }
public SKShader ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) => SKShader.GetObject(SkiaApi.sk_bitmap_make_shader(Handle, tmx, tmy, &localMatrix));
public static SKImage FromPicture(SKPicture picture, SKSizeI dimensions, SKMatrix matrix) { return(FromPicture(picture, dimensions, matrix, null)); }
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)); }
public SKShader ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKMatrix localMatrix) { return(GetObject <SKShader> (SkiaApi.sk_image_make_shader(Handle, tileX, tileY, ref localMatrix))); }
public void Concat(ref SKMatrix m) { SkiaApi.sk_canvas_concat (Handle, ref m); }
public extern static void sk_canvas_concat(sk_canvas_t t, ref SKMatrix m);
public void SetMatrix(SKMatrix matrix) { SkiaApi.sk_canvas_set_matrix (Handle, ref matrix); }
public extern static void sk_canvas_draw_picture(sk_canvas_t t, sk_picture_t pict, ref SKMatrix mat, sk_paint_t paint);
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)); }
public extern static void sk_canvas_set_matrix(sk_canvas_t canvas, ref SKMatrix matrix);
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 }
public extern static void sk_canvas_get_total_matrix(sk_canvas_t canvas, ref SKMatrix matrix);
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); }
public extern static sk_imagefilter_t sk_imagefilter_new_matrix(ref SKMatrix matrix, SKFilterQuality quality, sk_imagefilter_t input /*NULL*/);
public bool TryInvert(out SKMatrix inverse) { return SkiaApi.sk_matrix_try_invert(ref this, out inverse) != 0; }
public extern static sk_shader_t sk_shader_new_local_matrix(sk_shader_t proxy, ref SKMatrix matrix);
public extern static sk_shader_t sk_shader_new_bitmap(sk_bitmap_t src, SKShaderTileMode tmx, SKShaderTileMode tmy, ref SKMatrix matrix);
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);