Skip to content
⌘ NSIS Forum Archive

Hex codes for common colors

8 posts

rsegal#

Hex codes for common colors

Some common colors I make use of in my installer. It just makes working with colors alot easier.

!define WHITE "FFFFFF"
!define BLACK "000000"
!define YELLOW "FFFF00"
!define RED "FF0000"
!define GREEN "00FF00"
!define BLUE "0000FF"
!define PURPLE "FF00FF"

Visually it makes more sense to see this...

SetCtlColors $R1 ${BLACK} ${YELLOW}

rather than this...

SetCtlColors $R1 000000 FFFF00

Any chance of this getting added to a common NSIS header file?
zimsms#
You can find a complete list of the True Color Hex Values here. This should probably be stripped, each given a name and added into colors.nsh. Just to be complete 😁
Yathosho#
"FF00FF" is actually MAGENTA, and while you're at it, you should add "00FFFF" for CYAN aswell. then you have all base-colors for RGB and CMY, plus black and white.
Joel#
I made this macro for convert RGB values into web Hex, hope it helps in something:

# macro function:
!macro rgb2hex R G B
Exch $0
IntFmt $1 "%02X" ${R} # $1 have the Hex value of "R"
IntFmt $2 "%02X" ${G} # $2 have the Hex value of "G"
IntFmt $3 "%02X" ${B} # $3 have the Hex value of "B"
StrCpy $0 "$1$2$3"
Push $0
!macroend

# example:
Push $0 # output var for the hex.
!insertmacro rgb2hex 0 255 255
Pop $0
DetailPrint $0 # display it
kichik#
!macro rgb2hex output R G B
IntFmt "${output}" "%02X" "${R}"
IntFmt "${output}" "${output}%02X" "${G}"
IntFmt "${output}" "${output}%02X" "${B}"
!macroend