protected override void OnDraw(Android.Graphics.Canvas canvas) { var linearGradient = new Styles.Color.LinearGradient( new IRgb[] { ColorSwatches.FlatMint, ColorSwatches.FlatBlue }, 45 ); var radialGradient = new Styles.Color.RadialGradient( new IRgb[] { ColorSwatches.FlatMint, ColorSwatches.FlatBlue }, .5f, .5f ); var ellipticalGradient = new EllipticalGradient( new IRgb[] { ColorSwatches.FlatMint, ColorSwatches.FlatBlue, ColorSwatches.DeepPurple }, .5f, .5f ); ellipticalGradient.SetScale(1f, 2f); ellipticalGradient.Rotation = 45; var bounds = canvas.ClipBounds; var shader = ellipticalGradient.Draw(new RectF(bounds.Left, bounds.Top, bounds.Right, bounds.Bottom)); var paint = new Paint(); paint.SetShader(shader); canvas.DrawPaint(paint); }
public static Shader Draw(this RadialGradient target, PointF position, float radius) { target.Update(); var grad = new Android.Graphics.RadialGradient( position.X, position.Y, radius, target.Colors.ToInt(), target.Locations, Shader.TileMode.Clamp ); return(grad); }
public GradientLayer(RadialGradient gradient) { this.radialGradient = gradient; Type = GradientType.Radial; Initalize(); }
public GradientView(RadialGradient gradient) { this.radialGradient = gradient; Type = GradientType.Radial; BackgroundColor = UIColor.Clear; }