Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

GDI+ complex gradients

$
0
0
Hi guys,
I'm new to GDI+ and with the graphics libraries and now I'm facing one serious problem with the gradients. I'm dveloping simple game where you have two or more ellipses that move around, each ellipse have a gradient with black for the surrounding color and transparent for the inner color. How to make the gradients to merge instead of step on each other:
Posted Image

Please to excuse me for the bad explanation but english is not my native language so it's little hard to me to explain the problem better, I hope you understand what I mean, here is the code i wrote, I'm using graphics path for storing the ellipses(I code it in VB .NET):


Public Sub FadeEllipse(e As PaintEventArgs, clrSurround As Color, clrCenter As Color, booToCenter As Boolean, _
                                  intX As Integer, intY As Integer, intW As Integer, intH As Integer)
        Dim pth As New GraphicsPath()
        pth.AddEllipse(intX, intY, intW, intH)
        Dim pgb As New PathGradientBrush(pth)
        Select Case booToCenter
            Case True
                pgb.SurroundColors = New Color() {clrSurround}
                pgb.CenterColor = clrCenter
            Case False
                pgb.SurroundColors = New Color() {clrCenter}
                pgb.CenterColor = clrSurround
        End Select
        e.Graphics.FillRectangle(pgb, intX, intY, intW, intH)
    End Sub



Thank You in advance.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>