CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    112

    Linear Gradient Brush with Alpha

    I am using a Linear Gradient Brush.

    I want to do something like Fade from Solid Green to Transparent Yellow (or some other similar combinations)

    What this means is that you should start out green and slowly fade to yellow, but as the fade is going, the alpha also decreases.

    Now if I just set up a Linear gradient brush, what I get looks more like Solid Green to Transparent Green. There is no appearance of the yellow. The gradient should start to take on a yellow tinge as it fades out but this doesn't happen.

    Anyone know how I can achieve this effect?
    Eggman
    Using: VS 2008 w. Net 3.5

  2. #2
    Join Date
    Nov 2007
    Posts
    24

    Re: Linear Gradient Brush with Alpha

    You'll need to have two gradient brushes overlapping each other as far as I know.
    The gradient brush doesn't support more than one colour so in essence it's two brushes to do the transition, how ever I might be remembering this incorrectly so you can either double-check the Gradient brush definition on MSDN or wait for a second confirmation with possibly an easier solution.

  3. #3
    Join Date
    Mar 2008
    Posts
    72

    Re: Linear Gradient Brush with Alpha

    Depending on your .NET version, you can set up multiple colors.

    You didn't say what version you're using, however.

  4. #4
    Join Date
    Dec 2003
    Posts
    112

    Re: Linear Gradient Brush with Alpha

    Quote Originally Posted by MikeVallotton
    Depending on your .NET version, you can set up multiple colors.

    You didn't say what version you're using, however.
    FYI It does say in my signature what version I am using (.Net 2.0)

    Regardless, the ability to use multiple colors isn't the problem. A fade from Green to Blue works fine. A fade from Green to Transparent Blue however does not.

    It appears as though if you set the Alpha to 0, it basically ignores the RGB values during the fade.
    Eggman
    Using: VS 2008 w. Net 3.5

  5. #5
    Join Date
    Mar 2008
    Location
    Atlanta, GA
    Posts
    49

    Re: Linear Gradient Brush with Alpha

    Quote Originally Posted by Eggman002
    FYI It does say in my signature what version I am using (.Net 2.0)
    Your signature doesn't display for me.

  6. #6
    Join Date
    Mar 2008
    Posts
    72

    Re: Linear Gradient Brush with Alpha

    Your sig doesn't display for me, either.

    You can't have multiple colors in .NET 2.0.

    You could do a fade from green to yellow across half the image, then from yellow to transparent yellow across the other half.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured