Gradient

Gradient

Postby Silvio » Wed Nov 28, 2007 12:21 am

Antonio,

where I can found gradient function ?

I can create Horizontal gradient or vertical gradient also ?

Thanks
Best Regards, Saludos

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

Postby James Bott » Wed Nov 28, 2007 5:07 am

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

Postby Antonio Linares » Wed Nov 28, 2007 8:20 am

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
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Maurilio Viana » Wed Nov 28, 2007 12:46 pm

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
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Postby Silvio » Thu Nov 29, 2007 12:33 am

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

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

Postby toya » Thu Nov 29, 2007 12:44 am

Maurilio, para teres uma idéia, faça uma pequena alteração nos exemplos do link acima:
Code: Select all  Expand view  RUN
...
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
toya
 
Posts: 38
Joined: Sat Dec 31, 2005 10:08 am
Location: Brasil

Postby Antonio Linares » Thu Nov 29, 2007 12:45 am

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: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Nov 29, 2007 12:45 am

Silvio,

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

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

Postby James Bott » Thu Nov 29, 2007 5:27 am

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Nov 29, 2007 10:16 am

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
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Nov 29, 2007 3:30 pm

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Nov 29, 2007 3:53 pm

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
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Nov 29, 2007 3:58 pm

Antonio,

Got it. Thanks.

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

Postby StefanHaupt » Fri Dec 07, 2007 9:17 am

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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 60 guests