CreateRadialGradient() 공개 정적인 메소드

public static CreateRadialGradient ( SKPoint center, float radius, SKColor colors, float colorPos, SKShaderTileMode mode ) : SKShader
center SKPoint
radius float
colors SKColor
colorPos float
mode SKShaderTileMode
리턴 SKShader
예제 #1
0
        public static void ComposeShader(SKCanvas canvas, int width, int height)
        {
            var colors = new [] { SKColors.Blue, SKColors.Yellow };
            var center = new SKPoint(width / 2f, height / 2f);

            using (var shader1 = SKShader.CreateRadialGradient(center, 180.0f, colors, null, SKShaderTileMode.Clamp))
                using (var shader2 = SKShader.CreatePerlinNoiseTurbulence(0.025f, 0.025f, 2, 0.0f))
                    using (var shader = SKShader.CreateCompose(shader1, shader2))
                        using (var paint = new SKPaint())
                        {
                            paint.Shader = shader;
                            canvas.DrawPaint(paint);
                        }
        }
예제 #2
0
        private SKShader ReadRadialGradient(XElement e)
        {
            var centerX = ReadNumber(e.Attribute("cx"));
            var centerY = ReadNumber(e.Attribute("cy"));
            //var focusX = ReadOptionalNumber(e.Attribute("fx")) ?? centerX;
            //var focusY = ReadOptionalNumber(e.Attribute("fy")) ?? centerY;
            var radius   = ReadNumber(e.Attribute("r"));
            var absolute = e.Attribute("gradientUnits")?.Value == "userSpaceOnUse";
            var tileMode = ReadSpreadMethod(e);
            var stops    = ReadStops(e);

            // TODO: check gradientTransform attribute
            // TODO: use absolute

            return(SKShader.CreateRadialGradient(
                       new SKPoint(centerX, centerY),
                       radius,
                       stops.Values.ToArray(),
                       stops.Keys.ToArray(),
                       tileMode));
        }