Tech Tip: Utility Method to Convert 4D RGB Color to CSS2 Hex Color
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: May 7, 2020
The command OBJECT GET RGB COLORS is one example of receiving a longint 4D color value. The method below can be used to convert this longint color value to a CSS2 Hex color format for compatibility purposes.
Example of 4D longint color value : 16777215 (white)
Example of CSS2 Hex color value : #FFFFFF (white)
$1 accepts the 4D longint value
$0 returns the Hex color value
C_LONGINT($1) C_TEXT($char_t;$color_t;$0) $color_t:=String($1;"&x") $char_t:=Substring($color_t;3;1) If ($char_t="0") $color_t:=Substring($color_t;5) $color_t:=Insert string($color_t;"#";1) Else $color_t:=Substring($color_t;3) $color_t:=Insert string($color_t;"#00";1) End if $0:=$color_t |