views:

795

answers:

4

I'd like to spruce up some of the user controls I use and thought some attractive fills should do the job (part of it perhaps). Like the fill in the background of iPhone buttons or the Office 2007 ribbon bar (perhaps you know a few more).

Edit: To clear things up, I don't need a simple gradient fill - there is a Windows API call for that. I am more interested in how the entire effect is achieved. Here is a link to an article that shows how to do it in PhotoShop, but I want to accomplish that in code.

Specifically, the glossy gradient at the top ends in a curve roughly in the middle of the button. I half expect that this will need to be rendered separately and blended somehow.

Any ideas?

+3  A: 

You're talking about gradient fills. You can get some code samples here to start with - search that page for "gradient" to find the relevant sections.

Ken White
+1  A: 

The easiest way to do this is probably by assembling images based on the button size. Create a base image, and resize some layers over top of it, rather than trying to procedurally generating a complex gradient.

Andrew Lewis
+1 I've found some examples and this seems to be the common way of doing it. I'm going to go with skamradt's answer though.
Cobus Kruger
+3  A: 

The "glass" effect is made simply by creating a white ellipse around 4x larger than tall, placing it over the image to be "glassed" so that the bottom arc is centered on the image then alpha blending. I believe this sample delphi code will be some help in performing the final portion.

skamradt
+2  A: 

You could try http://www.tmssoftware.com/site/advsmoothbutton.asp. As far as I know this control is included in a free Smooth Controls pack with D2009. For other Delphi versions you could buy the TAdvSmoothButton control itself or as part of a control pack.

RR-NL
The smooth Controls are really great components : just try them.
Hugues Van Landeghem