Exemple #1
0
        public void SetGradient(GradientBrush gradientBrush)
        {
            _dirty = true;

            _gradientProvider?.Dispose();
            _gradientProvider = GradientProvidersContainer.Resolve(
                gradientBrush.GetType());
            _gradientProvider?.SetGradient(gradientBrush);

            SetNeedsDisplay();
        }
Exemple #2
0
        public void SetGradient(GradientBrush gradientBrush)
        {
            _dirty = true;

            _gradientProvider?.Dispose();
            _gradientProvider = GradientProvidersContainer.Resolve(
                gradientBrush.GetType());
            _gradientProvider?.SetGradient(gradientBrush);

            InvalidateSelf();
        }
Exemple #3
0
        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();
        }
Exemple #4
0
 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());
     }
 }
Exemple #5
0
 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());
     }
 }
Exemple #6
0
        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();
        }
Exemple #7
0
        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");
        }