Gradient

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Gradient

Post by Silvio »

Antonio,

where I can found gradient function ?

I can create Horizontal gradient or vertical gradient also ?

Thanks
Best Regards, Saludos

Falconi Silvio
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

You can create both of them, just use .T. or .F. as the last parameter when calling Gradient()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurilio Viana
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil
Contact:

Post by Maurilio Viana »

How can I create a gradient like Windows Vista buttons?
The gradient top is clear, the middle of object is darker and bottom is clear

Regards
Maurilio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

Antonio,
thanks but which is the file ?
where i can found the function gradient source code ?
Best Regards, Saludos

Falconi Silvio
User avatar
toya
Posts: 34
Joined: Sat Dec 31, 2005 10:08 am
Location: Brasil
Contact:

Post by toya »

Maurilio, para teres uma idéia, faça uma pequena alteração nos exemplos do link acima:

Code: Select all

...
for i = 255 TO 0 STEP -1


   DEFINE BRUSH oBrush COLOR RGB( 0, i, 0 ) //<--- aqui


   FILLRECT( hDC, aRect, oBrush:hBrush )
   RELEASE BRUSH oBrush
   aRect[ 1 ] += nStep
   aRect[ 3 ] += nStep
next
...
toya
Ahora en la version 6.6
Consultoria e Desenvolvimento - NF-e/NFC-e
http://www.toyanet.com.br
https://www.facebook.com/profile.php?id=100009195956044
toyasis@gmail.com
FWH 10.8+PellesC+xHarbour.org 1.2.1
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Maurilio,

Two calls to Gradient() functions are done:

1. From clear to dark
2. From dark to clear
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

We have not published the Gradient() source code yet
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Antonio,

It would be nice to have gradient capability added to the TWindow class. You could add a couple of parameters to the setColor() method to handle the extra needed color and the vertical/horzontal parameter. Then all the subclasses would inherit the gradient capability.

But, I expect you have already thought of that.

Regards,
James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

James,

Gradient() should not be used intensively because it is a very slow function that creates lots of brushes (pushing the GDI to its limits) and takes too long to do its work.

The right way is to copy a bitmap (stretching it) instead of using gradients. We have used this technique in FWH 7.12 to paint the message bar and now it works much more faster.

Keep in mind that copying a bitmap you can use any drawing design, so the final result is much richer in details :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Antonio,

>Gradient() should not be used intensively because it is a very slow function that creates lots of brushes (pushing the GDI to its limits) and takes too long to do its work.

Good point. Are you using a C function for this. I have tried gradients with a few test programs and it didn't seem too slow, but these were very small programs like with one dialog.

>The right way is to copy a bitmap (stretching it) instead of using gradients. We have used this technique in FWH 7.12 to paint the message bar and now it works much more faster.

So where is the bitmap stored? Is it embedded in the FW code somehow?

I have used bitmaps to do this also, but my bitmaps are stored in the RC file and I did not know we could stretch them to fit so it was very tedious making a bitmap of the proper size. Can you show us how to stretch a bitmap to fit a dialog or window?

>Keep in mind that copying a bitmap you can use any drawing design, so the final result is much richer in details.

I like that idea.

James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

James,

> Are you using a C function for this.

Yes, and even using C code, it is slow. Thats why we should try to avoid it and use StretchBlt().

> So where is the bitmap stored? Is it embedded in the FW code somehow?

Yes, it is embedded in a C module. Its quite simple: You open the bitmap with the Borland resources workshop, edit it as text, and then copy the bytes to a C array. From that C array, the bitmap is dinamically created in memory.

> I did not know we could stretch them to fit

Thats what StretchBlt() is for.

> Can you show us how to stretch a bitmap to fit a dialog or window?

In just few days FWH 7.12 will be published and the source code for stretching a bitmap will be available, and a working sample: the Class TMsgBar.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Antonio,

Got it. Thanks.

James
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Dear friends,

I wrote a little tool that manages the conversion from a bitmap into a C array . So you can embed the bitmap in your C file very easily.

May be it´s useful.

You can download it here:
BmpInfo.zip (1.66 MB)

Image
kind regards
Stefan
Post Reply