Exemple #1
0
        public static void DrawBackground(this SKCanvas canvas, SKRect rect, bool inset, double offsetX, double offsetY, double blurRadius, double spreadRadius, Xamarin.Forms.Color color)
        {
            Console.WriteLine($"shadow rect = {rect}, {offsetX}, {offsetY}");

            using (var paint = new SKPaint())
            {
                paint.Color       = SKColors.Blue;
                paint.ImageFilter = SKImageFilter.CreateDropShadow(
                    (float)offsetX,
                    (float)offsetY,
                    (float)blurRadius,
                    (float)blurRadius,
                    color.ToSK(),
                    SKDropShadowImageFilterShadowMode.DrawShadowAndForeground);

                rect.Inflate((float)spreadRadius, (float)spreadRadius);
                canvas.DrawRect(rect, paint);
            }
        }
Exemple #2
0
        public static void DrawBackground(this SKCanvas canvas, SKRect rect, double width, LineStyle style, Xamarin.Forms.Color color, BorderRadius round)
        {
            if (width == 0)
            {
                return;
            }
            using (var paint = new SKPaint())
            {
                paint.Style       = SKPaintStyle.Stroke;
                paint.StrokeWidth = (float)width;
                paint.Color       = color.ToSK();
                //paint.PathEffect = border.Style.ToSK();
                var half = (float)(width / 2);
                rect.Left   -= half;
                rect.Top    -= half;
                rect.Right  += half;
                rect.Bottom += half;

                float x = round.Horizontal != null ? (float)(round.Horizontal is IRelativeNumber rx ? rx.RelateTo(rect.Width) : round.Horizontal.Value) : 0;
                float y = round.Vertical != null ? (float)(round.Vertical is IRelativeNumber ry ? ry.RelateTo(rect.Height) : round.Vertical.Value) : 0;

                canvas.DrawRoundRect(rect, new SKSize(x, y), paint);
            }
        }