*!* 颜色串到RGB颜色
lparameters tcColor
if vartype(tcColor) # 'C' or len(tcColor) # 6
return rgb(0,0,0)
endif
Local lcLine, lcColor
lcLine = '0123456789ABCDEF'
lcColor = upper(tcColor)
lc1 = substr(lcColor, 1, 1)
lc2 = substr(lcColor, 2, 1)
lc3 = substr(lcColor, 3, 1)
lc4 = substr(lcColor, 4, 1)
lc5 = substr(lcColor, 5, 1)
lc6 = substr(lcColor, 6, 1)
lnR = (atc(lc1, lcLine) - 1) * 16 + atc(lc1, lcLine) - 1
lnG = (atc(lc3, lcLine) - 1) * 16 + atc(lc4, lcLine) - 1
lnB = (atc(lc5, lcLine) - 1) * 16 + atc(lc6, lcLine) - 1
return rgb(lnR, lnG, lnB)
*!* rgb颜色转换成为颜色串
lparameters tnRgb
if vartype(tnRgb) # 'N'
return '000000'
endif
Local lcLine, lnR, lnG, lnB, lcR, lcG, lcB
lcLine = '0123456789ABCDEF'
lnB = floor(tnRgb/65536)
lnB = iif(lnB > 255, 255, lnB)
lnG = floor((tnRgb % 65536)/256)
lnR = (tnRgb % 65536)%256
lcR = substr(lcLine, floor(lnR/16) + 1, 1) + substr(lcLine, floor(lnR%16) + 1, 1)
lcG = substr(lcLine, floor(lnG/16) + 1, 1) + substr(lcLine, floor(lnG%16) + 1, 1)
lcB = substr(lcLine, floor(lnB/16) + 1, 1) + substr(lcLine, floor(lnB%16) + 1, 1)
return (lcR + lcG + lcB)