Option Strict On
Option Explicit On

Imports System
Imports SkiaSharp

Namespace Nexamas.UI.Rendering

    ''' <summary>
    ''' Studio Porcelain media shell material. The shell is the physical body of the media
    ''' viewer: calm neutral porcelain, subtle depth, and a restrained theme accent signature.
    ''' </summary>
    Friend NotInheritable Class MASMediaShellSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaShell
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)
            Dim dpi As Single = Math.Max(1.0F, context.Dpi)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.56F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            ' Porcelain top light: short and restrained, not icy glass.
            Using liftShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.24F)),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 50), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  liftPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = liftShader}

                canvas.DrawRect(rectPx, liftPaint)
            End Using

            ' Low grounding so the shell feels like one object without becoming heavy.
            Using lowerShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Bottom - Math.Max(1.0F, rectPx.Height * 0.28F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Bottom, 0), MASSurfaceMaterialPaintUtils.Mix(palette.Bottom, SKColors.Black, 0.035F, 34)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  lowerPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = lowerShader}

                canvas.DrawRect(rectPx, lowerPaint)
            End Using

            canvas.Restore()

            Using rimPaint As New SKPaint With {.IsAntialias = True, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 78)}
                canvas.DrawRoundRect(rr, rimPaint)
            End Using
        End Sub
    End Class

    ''' <summary>
    ''' Media chrome material retained for registry compatibility. ImageViewer now uses the
    ''' dedicated MediaToolbarGlass and MediaFooterChrome rails for toolbar/footer separation.
    ''' </summary>
    Friend NotInheritable Class MASMediaChromeSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaChrome
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)
            Dim dpi As Single = Math.Max(1.0F, context.Dpi)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.52F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            ' Manufactured bevel: gives the rail structure while keeping it calm.
            Using bevelShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.36F)),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 62), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  bevelPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = bevelShader}

                canvas.DrawRect(rectPx, bevelPaint)
            End Using

            Using lowerShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Bottom - Math.Max(1.0F, rectPx.Height * 0.36F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Bottom, 0), MASSurfaceMaterialPaintUtils.Mix(palette.Bottom, SKColors.Black, 0.032F, 36)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  lowerPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = lowerShader}

                canvas.DrawRect(rectPx, lowerPaint)
            End Using

            canvas.Restore()

            Using topEdge As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 78)}
                canvas.DrawLine(rectPx.Left, rectPx.Top + 0.5F * dpi, rectPx.Right, rectPx.Top + 0.5F * dpi, topEdge)
            End Using

            Using bottomEdge As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 64)}
                canvas.DrawLine(rectPx.Left, rectPx.Bottom - 0.5F * dpi, rectPx.Right, rectPx.Bottom - 0.5F * dpi, bottomEdge)
            End Using
        End Sub
    End Class

    ''' <summary>
    ''' Semi-transparent toolbar glass for media surfaces. It keeps the command rail light
    ''' and lets the frosted viewer body show through with restrained opacity.
    ''' </summary>
    Friend NotInheritable Class MASMediaToolbarGlassSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaToolbarGlass
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)
            Dim dpi As Single = Math.Max(1.0F, context.Dpi)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.54F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            Using upperGlass As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.46F)),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 18), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  upperPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = upperGlass}

                canvas.DrawRect(rectPx, upperPaint)
            End Using

            canvas.Restore()

            Using bottomEdge As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 26)}
                canvas.DrawLine(rectPx.Left, rectPx.Bottom - 0.5F * dpi, rectPx.Right, rectPx.Bottom - 0.5F * dpi, bottomEdge)
            End Using
        End Sub
    End Class

    ''' <summary>
    ''' Dedicated theme-native command rail for media viewers. The material is authored as a
    ''' command surface, not a generic glass/card: its colors are resolved from the active
    ''' surface theme palette while its geometry adds a restrained media-specific accent seam.
    ''' </summary>
    Friend NotInheritable Class MASMediaCommandRailSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaCommandRail
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)
            Dim dpi As Single = Math.Max(1.0F, context.Dpi)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.46F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            ' Glass cap: theme-derived highlight that creates a lighter transparent upper band.
            Using capShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.42F)),
                    New SKColor() {
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 78),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 18),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)
                    },
                    New Single() {0.0F, 0.34F, 1.0F},
                    SKShaderTileMode.Clamp),
                  capPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = capShader}

                canvas.DrawRect(rectPx, capPaint)
            End Using

            ' Soft center haze helps the rail read as glass rather than as an opaque card.
            Dim hazeTop As Single = rectPx.Top + rectPx.Height * 0.18F
            Dim hazeBottom As Single = rectPx.Top + rectPx.Height * 0.82F
            Using hazeShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, hazeTop),
                    New SKPoint(rectPx.Left, hazeBottom),
                    New SKColor() {
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 18),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Accent, 10),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)
                    },
                    New Single() {0.0F, 0.34F, 0.72F, 1.0F},
                    SKShaderTileMode.Clamp),
                  hazePaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = hazeShader}

                canvas.DrawRect(rectPx, hazePaint)
            End Using

            ' Subtle lower grounding so the toolbar still sits on the stage without becoming heavy.
            Using groundingShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Bottom - Math.Max(1.0F, rectPx.Height * 0.28F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 0),
                        MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 12)
                    },
                    Nothing,
                    SKShaderTileMode.Clamp),
                  groundingPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = groundingShader}

                canvas.DrawRect(rectPx, groundingPaint)
            End Using

            canvas.Restore()

            ' Authored glass details: one top inner glint and one calm bottom seam.
            Using topGlint As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = Math.Max(1.0F, 0.75F * dpi), .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 52)}
                canvas.DrawLine(rectPx.Left + radiusPx * 0.20F, rectPx.Top + 0.85F * dpi, rectPx.Right - radiusPx * 0.20F, rectPx.Top + 0.85F * dpi, topGlint)
            End Using

            Using bottomEdge As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 34)}
                canvas.DrawLine(rectPx.Left, rectPx.Bottom - 0.5F * dpi, rectPx.Right, rectPx.Bottom - 0.5F * dpi, bottomEdge)
            End Using
        End Sub
    End Class

    ''' <summary>
    ''' Grounded footer chrome for media surfaces. This rail intentionally sits a step deeper
    ''' than the top command strip so metadata and zoom state feel anchored to the shell.
    ''' </summary>
    Friend NotInheritable Class MASMediaFooterChromeSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaFooterChrome
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)
            Dim dpi As Single = Math.Max(1.0F, context.Dpi)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.56F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            Using liftShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.26F)),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 16), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  liftPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = liftShader}

                canvas.DrawRect(rectPx, liftPaint)
            End Using

            Using lowerShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Bottom - Math.Max(1.0F, rectPx.Height * 0.44F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Bottom, 0), MASSurfaceMaterialPaintUtils.Mix(palette.Bottom, SKColors.Black, 0.030F, 24)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  lowerPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = lowerShader}

                canvas.DrawRect(rectPx, lowerPaint)
            End Using

            canvas.Restore()

            Using bottomEdge As New SKPaint With {.IsAntialias = False, .Style = SKPaintStyle.Stroke, .StrokeWidth = dpi, .Color = MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 32)}
                canvas.DrawLine(rectPx.Left, rectPx.Bottom - 0.5F * dpi, rectPx.Right, rectPx.Bottom - 0.5F * dpi, bottomEdge)
            End Using
        End Sub
    End Class

    ''' <summary>
    ''' Studio Porcelain media stage material. The stage is a neutral recessed gallery well behind
    ''' the bitmap so the image stays dominant and empty margins never become a second card.
    ''' </summary>
    Friend NotInheritable Class MASMediaStageSurfaceMaterial
        Implements IMASSurfaceMaterial

        Public ReadOnly Property Id As String Implements IMASSurfaceMaterial.Id
            Get
                Return MASSurfaceMaterialIds.MediaStage
            End Get
        End Property

        Friend Sub Draw(canvas As SKCanvas,
                        context As MASSurfaceMaterialContext) Implements IMASSurfaceMaterial.Draw

            If canvas Is Nothing OrElse context Is Nothing Then Return

            Dim rectPx As SKRect = context.BoundsPx
            Dim radiusPx As Single = context.CornerRadiusPx
            If rectPx.Width <= 0.5F OrElse rectPx.Height <= 0.5F Then Return

            Dim palette As MASSurfaceMaterialPalette =
                MASSurfaceMaterialThemeResolver.Resolve(Me.Id, context)

            Dim rr As SKRoundRect = MASSurfaceMaterialPaintUtils.RoundRect(rectPx, radiusPx)

            Using shader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {palette.Top, palette.Mid, palette.Bottom},
                    New Single() {0.0F, 0.60F, 1.0F},
                    SKShaderTileMode.Clamp),
                  paint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = shader}

                canvas.DrawRoundRect(rr, paint)
            End Using

            canvas.Save()
            canvas.ClipRoundRect(rr, SKClipOperation.Intersect, True)

            ' Recessed top shade; this replaces the old decorative inner-card feeling.
            Using topShadeShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top),
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.22F)),
                    New SKColor() {MASSurfaceMaterialPaintUtils.Mix(palette.Line, SKColors.Black, 0.05F, 28), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Line, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  topShadePaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = topShadeShader}

                canvas.DrawRect(rectPx, topShadePaint)
            End Using

            Using softLiftShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Top + Math.Max(1.0F, rectPx.Height * 0.12F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 12), MASSurfaceMaterialPaintUtils.WithAlpha(palette.Glow, 0)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  softLiftPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = softLiftShader}

                canvas.DrawRect(rectPx, softLiftPaint)
            End Using

            Using lowerShader As SKShader = SKShader.CreateLinearGradient(
                    New SKPoint(rectPx.Left, rectPx.Bottom - Math.Max(1.0F, rectPx.Height * 0.20F)),
                    New SKPoint(rectPx.Left, rectPx.Bottom),
                    New SKColor() {MASSurfaceMaterialPaintUtils.WithAlpha(palette.Bottom, 0), MASSurfaceMaterialPaintUtils.Mix(palette.Bottom, SKColors.Black, 0.04F, 26)},
                    Nothing,
                    SKShaderTileMode.Clamp),
                  lowerPaint As New SKPaint With {.IsAntialias = True, .IsDither = True, .Style = SKPaintStyle.Fill, .Shader = lowerShader}

                canvas.DrawRect(rectPx, lowerPaint)
            End Using

            canvas.Restore()
        End Sub
    End Class

End Namespace
