hex color

hex color

Postby Silvio.Falconi » Mon Feb 29, 2016 11:27 am

Can I use a hex color sample 0xFFFF00
How I can converte it into rgb color ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: hex color

Postby karinha » Mon Feb 29, 2016 2:00 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7801
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: hex color

Postby mastintin » Mon Feb 29, 2016 2:15 pm

Code: Select all  Expand view


function cHex2aRgb( cHexColor )
local nR,nG,nB
local aRgb

   if  left(cHexColor,1) == "#"
      cHexColor := substr(cHexColor,2,len(cHexColor) )
   endif

     if len(cHexColor) == 3
      nR = ft_Hex2Dec( substr(cHexColor,1,1))
      nG = ft_Hex2Dec( substr(cHexColor,2,1))
      nB = ft_Hex2Dec( substr(cHexColor,3,1))
   else
      nR = ft_Hex2Dec( substr(cHexColor,1,2))
      nG = ft_Hex2Dec( substr(cHexColor,3,2))
      nB = ft_Hex2Dec( substr(cHexColor,5,2))
   endif
   aRgb := {nR, nG, nB }

  return aRgb; // returns an array with the rgb values

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: hex color

Postby Carlos Mora » Mon Feb 29, 2016 2:47 pm

Ciao Silvio,

Silvio.Falconi wrote:Can I use a hex color sample 0xFFFF00
How I can converte it into rgb color ?

Colors are longs with 3 components. Written in Hexadecimal the look like 0x<BB><GG><RR>, because longs are stores with less significan bytes first.
Have you tried to use it 'as is', changing the order? I mean

Code: Select all  Expand view

    DEFINE WINDOW oWnd FROM 0, 0 TO 100, 100 PIXEL TITLE "My color test" COLORS 0, 0x00FFFF

 
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: hex color

Postby karinha » Mon Feb 29, 2016 3:13 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7801
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests