gradiants ?

gradiants ?

Postby Detlef » Wed Jun 01, 2022 8:51 pm

Hi all,

could someone tell me where to find information about how to build gradiants?

Thanks,
Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: gradiants ?

Postby nageswaragunupudi » Thu Jun 02, 2022 3:12 am

aGradient := { ;
{ size1, clrStart1, clrEnd1 }, ;
{ size2, clrStart2, clrEnd2 }, ;
....
{ sizeN, clrStartN, clrEndN } [, lOrient] }


All sizes are fractions less than 1 and total of all sizes should be 1.0

Optionsl lOrient: .T. for Vertical ( default )
.F. for Horizontal
"RING" for ring gradient


We can fill parts of window/dialog/control with

FillRectEx( hDC, aRect, aGrad )

We can also define gradient brush and assign to a window

DEFINE BRUSH oBrush GRADIENT aGrad

Brushes get automatically resized when window gets resized
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: gradiants ?

Postby nageswaragunupudi » Thu Jun 02, 2022 3:16 am

Sample:
Code: Select all  Expand view
#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd
   local aGradV   := ;
      {  { 0.20, CLR_BLUE,    CLR_HBLUE   } ;
      ,  { 0.30, CLR_HBLUE,   CLR_WHITE   } ;
      ,  { 0.30, CLR_WHITE,   CLR_HGREEN  } ;
      ,  { 0.20, CLR_HGREEN,  CLR_GREEN   } ;
      ,  .T.  ; // .t. for vertical and .f. for horizontal (defaul .t.)
      }

   local aGradH   := ;
      {  { 0.20, CLR_BLUE,    CLR_HBLUE   } ;
      ,  { 0.30, CLR_HBLUE,   CLR_WHITE   } ;
      ,  { 0.30, CLR_WHITE,   CLR_HGREEN  } ;
      ,  { 0.20, CLR_HGREEN,  CLR_GREEN   } ;
      ,  .F.  ; // .t. for vertical and .f. for horizontal (defaul .t.)
      }

   local aGradR   := ;
      {  { 0.20, CLR_BLUE,    CLR_HBLUE   } ;
      ,  { 0.30, CLR_HBLUE,   CLR_WHITE   } ;
      ,  { 0.30, CLR_WHITE,   CLR_HGREEN  } ;
      ,  { 0.20, CLR_HGREEN,  CLR_GREEN   } ;
      ,  "RING" ;
      }


   DEFINE WINDOW oWnd FROM 0,0 TO 800,800 PIXEL

   oWnd:bPainted := < |hDC|
      FillRectEx( hDC, { 100, 100, 200, 300 }, aGradV )
      FillRectEx( hDC, { 100, 400, 200, 600 }, aGradH )
      FillRectEx( hDC, { 300, 100, 500, 300 }, aGradR )
      return nil
      >

  ACTIVATE WINDOW oWnd CENTERED

return nil

//----------------------------------------------------------------------------//
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: gradiants ?

Postby Detlef » Thu Jun 02, 2022 7:25 am

Many thanks, Mr. Rao for this excellent information.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: gradiants ?

Postby Rick Lipkin » Thu Jun 02, 2022 1:44 pm

Here are a few functions I have created and use ...

Code: Select all  Expand view

//-------------------
Func GreyButtonGrad()

// 2010 grey button skin

Local bGrad

bGrad := { | lInvert | If( ! lInvert, ;
         { { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
         { { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
         { 2/3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) } } ) }

Return( bGrad )

//---------------------------
Func BlueGreenGrad()

Local xGrad4 :=  {{ 1.00,14671839,   7419904 }, { 1.00,7419904,  14671839 }}   // med blue
SetDlgGradient( xGrad4 )

Return(nil)

//---------------------
Func SolidGreenBlue()

SetDlgGradient({ { 0.01,9994298,9994298 },{ 0.01,9994298,9994298 } })
Return(nil)


//-------------
Func SolidDarkBlue()

SetDlgGradient( { { 0.50,4720905,4720905 },{ 0.50,4720905,4720905 } })
Return(nil)

//-------------------
Func SolidBlue()

SetDlgGradient( { { 0.01,16711680,16711680 },{ 0.01,16711680,16711680 } })
Return(nil)

//------------------
Func DarkBlueGrad()

SetDlgGradient({ { 0.0,8388608,13619151 },{ 0.0,13619151,8388608 } })

Return(nil)


//--------------
Func LightGreenGrad()

SetDlgGradient( { { .50, nRGB(210,235,216), nRGB( 255, 255, 255 ) } } )

Return(nil)

//------------------
Func LightBlueGrad()

SetDlgGradient( { { .50, nRGB( 201, 217, 237 ), nRGB( 231, 242, 255 ) } } )

Return(nil)

//------------------
Func LightGreyGrad()

SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )

Return(nil)

//-----------------
Func StandardGrad()

SetDlgGradient( { { .50, nRGB( 236, 233, 216 ), nRGB( 255, 255, 255 ) } } )

Return(nil)

//--------------------
Func DarkGreyGrad()

SetDlgGradient({{ 005.9000, 14671839, 4144959  },{ 0.1, 4144959, 14671839  }})          // .80


Return(nil)

//------------------------------------
Func SolidWhite()

SetDlgGradient( { { 0.01,16777215,16777215 },{ 0.01,16777215,16777215 } })

Return(nil)

//--------------------
Func SolidGrey()

SetDlgGradient( { { .50, nRGB( 233, 233, 233 ), nRGB( 233, 233, 233 ) } } )

Return(nil)

//--------------------
Func SolidChoral()

SetDlgGradient(aGrad := { { 0.01,8388736,8388736 },{ 0.01,8388736,8388736 } })

Return(nil)

//-----------------
Func LightYellow()

SetDlgGradient( { { 0.01,8440801,16777215 },{ 0.75,16777215,8440801 } })

Return(nil)

//-------------------
Func GreenBlueGrad()

SetDlgGradient( { { .50, nRGB( 192, 192, 192 ), nRGB( 45, 121, 147 ) } } )

Return(nil)

 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: gradiants ?

Postby Detlef » Thu Jun 02, 2022 9:25 pm

Thank you, Rick.
There are some nice and useful gradiants in your post.
Your gradients and the profound explanations of Mr. Rao helped me a lot to understand and use gradients.
But I just can't understand that when Mr. Rao stated
All sizes are fractions less than 1 and total of all sizes should be 1.0

But your gradients don't care about. Do you have a certain reason for that?

Regards, Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: gradiants ?

Postby Rick Lipkin » Fri Jun 03, 2022 1:05 pm

Detlef

I use the built in FiveWin SetDlgGradient() function .. not much info on the function itself but it works quite nicely ... once you issue SetDlgGradient() it becomes the default windows and dialog background.. I have given you several different gradients .. I use different gradient backgrounds throughout my programs ..

Very easy to create your own functions .. sometime back Uwe created Gradient painter .. I have the program but not the source ... you might search for "Gradient Painter" in the FW Forums and find his contribution ..

Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: gradiants ?

Postby ukoenig » Mon Jun 06, 2022 11:58 am

The extended version :
Adjusted links for images and downloads from the changed website.

viewtopic.php?f=3&t=29016

create any gradient You need from selected colours :

Image

best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests