[Gambas-user] Image.Gradient help please

manuel viet gambas at ...1828...
Fri Jan 11 19:01:33 CET 2008



M0E Lnx wrote:
> 
> I'm trying to create a text label with a gradient background
> (white-to-blue, left to right)
> I've been reading abotu image.gradient in the gb.image section of the
> wiki, but I'm having a hard time understanding how this is supposed to
> work
> 
> 

Hello,

It's unclear how proficient with gambas you're already,
so bear with me if what I say seems simplimistic. You 
should understand an 'image' in gambas meaning is
just a square Object, and you have special methods
to use it. 

So first you declare your Image by a name, ie 

Public myButImg AS Image
or
Dim myButImg AS Image

And then you instanciate it :
myButImg = New Image(width(*), height(*), [transparent])

(*)You can calculate the height and the width in 
relation to another Object, like the button where the
image will be displayed.

After that you can use all the native methods of the
Image class on your 'image' which at this point is
merely a black square in memory.

Especially, you can set the gradient :

myButImg.Gradient (myButImg.Width, myButImg.Height, Color.White, Color.Blue,
Image.horizontal)

To set text upon that background, tou then have to
use the draw methods, and they are a bit peculiar.

First, you need to declarre you want to draw on
your object, so you :

Draw.begin(myButImg)

You can set various colors and such with some
draw methods, they will apply to the current object
being drawn, here, your image.

Then, you

Draw.text("your label", X,Y,[W,H,ALIGN]) 

where X Y are the coordinates in pixel inside the
object myButImg where to place the beginning of the 
text. Mind the clipping if the text is bigger than the
image !

Then you end drawing :

Draw.end() 'easy one isn't it

And you place your image object inside a button
by using the myButImg.picture property.

Button.picture = myButImg.picture

Have fun !





-----
-- 
Manuel Viet
-- 
View this message in context: http://www.nabble.com/Image.Gradient-help-please-tp14759465p14761731.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list