public void SetGradient(GradientBrush gradientBrush) { _dirty = true; _gradientProvider?.Dispose(); _gradientProvider = GradientProvidersContainer.Resolve( gradientBrush.GetType()); _gradientProvider?.SetGradient(gradientBrush); SetNeedsDisplay(); }
public void SetGradient(GradientBrush gradientBrush) { _dirty = true; _gradientProvider?.Dispose(); _gradientProvider = GradientProvidersContainer.Resolve( gradientBrush.GetType()); _gradientProvider?.SetGradient(gradientBrush); InvalidateSelf(); }
public void SetBorder(double strokeWidth, Color strokeColor, GradientBrush gradientBrush) { _dirty = true; _strokeWidth = (float)strokeWidth; _strokeColor = strokeColor.ToUIColor(); _strokeGradientProvider?.Dispose(); _strokeGradientProvider = GradientProvidersContainer.Resolve( gradientBrush.GetType()); _strokeGradientProvider?.SetGradient(gradientBrush); SetNeedsDisplay(); }
private static Microsoft.Xna.Framework.Color GetColor(Vector2 position, GradientBrush brush) { if (brush is LinearGradientBrush linear) { return(GetColor(position, linear)); } else if (brush is RadialGradientBrush radial) { return(GetColor(position, radial)); } else { throw new NotImplementedException("Does not recognize " + brush.GetType()); } }
public static Texture2D GradientToTexture(GradientBrush gradient, Rectangle source, Rectangle destination) { if (gradient is LinearGradientBrush linearGradient) { return(LinearGradientToTexture(linearGradient, source, destination)); } else if (gradient is RadialGradientBrush radialGradient) { return(RadialGradientToTexture(radialGradient, source, destination)); } else { throw new NotImplementedException("Cannot render " + gradient.GetType()); } }
public void SetBorderGradient(GradientBrush gradientBrush) { _dirty = true; _strokeGradientProvider?.Dispose(); _strokeGradientProvider = GradientProvidersContainer.Resolve( gradientBrush.GetType()); _strokeGradientProvider?.SetGradient(gradientBrush); InvalidateSelf(); if (_strokeGradientProvider == null || !_strokeGradientProvider.HasGradient) { return; } _strokePaint.Color = Color.White.ToAndroid(); }
private static TextureFilter RenderBrushToTextureFilter(GradientBrush brush, Point uvMin, Point uvMax) { // Special Case 0 - acts as transparent solid color if (brush.GradientStops == null || brush.GradientStops.Count == 0) { return(new SolidColorTextureFilter(Colors.Transparent)); } // Special Case 1 - acts as solid color of the only stop if (brush.GradientStops.Count == 1) { return(new SolidColorTextureFilter(brush.GradientStops[0].Color)); } if (brush is LinearGradientBrush) { return(RenderBrushToTextureFilter((LinearGradientBrush)brush, uvMin, uvMax)); } else if (brush is RadialGradientBrush) { return(RenderBrushToTextureFilter((RadialGradientBrush)brush, uvMin, uvMax)); } throw new NotSupportedException(brush.GetType().Name + " is not a supported GradientBrush"); }