MakeRotation() public static method

public static MakeRotation ( float radians ) : SKMatrix
radians float
return SKMatrix
コード例 #1
0
        public static void BitmapShader(SKCanvas canvas, int width, int height)
        {
            var assembly  = typeof(Demos).GetTypeInfo().Assembly;
            var imageName = assembly.GetName().Name + ".color-wheel.png";

            // load the image from the embedded resource stream
            using (var resource = assembly.GetManifestResourceStream(imageName))
                using (var stream = new SKManagedStream(resource))
                    using (var source = SKBitmap.Decode(stream)) {
                        // create the shader and paint
                        //SkMatrix matrix;
                        //matrix.setScale(0.75f, 0.75f);
                        //matrix.preRotate(30.0f);
                        var matrix = SKMatrix.MakeRotation(30.0f);
                        using (var shader = SKShader.CreateBitmap(source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat, matrix))
                            using (var paint = new SKPaint()) {
                                paint.IsAntialias = true;
                                paint.Shader      = shader;

                                // tile the bitmap
                                canvas.Clear(SKColors.White);
                                canvas.DrawPaint(paint);
                            }
                    }
        }