mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
329 stars 171 forks source link

`PathGradientBrush` not working properly #720

Open Piripe opened 2 years ago

Piripe commented 2 years ago

I think the PathGradientBrush is not supported by libgdiplus

At the left libgdiplus on Ubuntu 20.04 | At the right GDI+ of Windows 10 Screenshot 2021-10-11 002712

The code I used

Public Function MonoShadow() As Image
        Dim flag As New Bitmap(500, 500)
        Using g = Graphics.FromImage(flag)
            Dim path As New GraphicsPath
            path.AddArc(New Rectangle(0, 0, 100, 100), 90, 180)
            path.AddLine(50, 0, 350, 0)
            path.AddArc(New Rectangle(300, 0, 100, 100), -90, 180)
            path.AddLine(50, 100, 350, 100)

            Dim shadowpath As New GraphicsPath()
            shadowpath.AddPath(path, False)
            Dim Matrix = New Matrix()

            Matrix.Translate(10, 10)

            shadowpath.Transform(Matrix)

            Using Brush As PathGradientBrush = New PathGradientBrush(shadowpath)
                Brush.WrapMode = WrapMode.Clamp

                Dim ColorBlend = New ColorBlend(3)

                ColorBlend.Colors = New Drawing.Color() {Drawing.Color.Transparent, Drawing.Color.FromArgb(96, 0, 0, 0), Drawing.Color.FromArgb(96, 0, 0, 0)}
                ColorBlend.Positions = New Single() {0F, 0.1F, 1.0F}

                Brush.InterpolationColors = ColorBlend

                g.FillPath(Brush, shadowpath)
            End Using
        End Using
        Return flag
    End Function