Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ColorFromHTML
#1
For dealing with many HTML colors.

Function ColorFromHTML
Code:
Copy      Help
;/
function# $RRGGBB

;Returns color value in format BBGGRR

;0xa75c4 -> C4750A

if empty(RRGGBB)
,ret 0xFFFFFF

if findrx(RRGGBB "^(0x|0X)?[0-9A-Fa-f]+$" 0 0 _s 1)<0
,end "error: 'RRGGBB' notation"

if empty(_s)
,_s.from("0x" RRGGBB)
else _s=RRGGBB

_i=val(_s)

ret (_i&0xFF<<16) | (_i&0xFF00) | (_i&0xFF0000>>16)


Macro Use ColorFromHTML
Code:
Copy      Help
str HTMLcolor="0x5c4"

out

out "0x%X" ColorFromHTML(HTMLcolor)


Forum Jump:


Users browsing this thread: 1 Guest(s)