converts from one type of color values to another
type pixel
R as float
G as float
B as float
H as float
S as float
L as float
endtype
dim pixel(0) as pixel
sync on:sync rate 0
do
rgb2hsl(255,0,0)
text 10,10,"H:"+str$(pixel(0).H)+" S:"+str$(pixel(0).S)+" L:"+str$(pixel(0).L)
sync
loop
function rgb2hsl(R,G,B)
var_R# = ( R / 255.0 ) `Where RGB values = 0 ÷ 255
var_G# = ( G / 255.0 )
var_B# = ( B / 255.0 )
`find max and min vals
if var_R# > var_G# and var_R# > var_B# then max# = var_R#
if var_G# > var_R# and var_G# > var_B# then max# = var_G#
if var_B# > var_G# and var_B# > var_R# then max# = var_B#
`min
if var_R# < var_G# and var_R# < var_B# then min# = var_R#
if var_G# < var_R# and var_G# < var_B# then min# = var_G#
if var_B# < var_R# and vaR_B# < var_G# then min# = var_B#
var_Min# = min# `Min. value of RGB
var_Max# = max# `Max. value of RGB
del_Max# = var_Max# - var_Min# `Delta RGB value
L# = ( var_Max# + var_Min# ) / 2.0
if ( del_Max# = 0 ) `This is a gray, no chroma...
H# = 0 `HSL results = 0 ÷ 1
S# = 0
else `Chromatic data...
if ( L# < 0.5 )
S# = del_Max# / ( var_Max# + var_Min# )
else
S# = del_Max# / ( 2 - var_Max# - var_Min# )
endif
del_R# = ( ( ( var_Max# - var_R# ) / 6.0 ) + ( del_Max# / 2.0 ) ) / del_Max#
del_G# = ( ( ( var_Max# - var_G# ) / 6.0 ) + ( del_Max# / 2.0 ) ) / del_Max#
del_B# = ( ( ( var_Max# - var_B# ) / 6.0 ) + ( del_Max# / 2.0 ) ) / del_Max#
if ( var_R# = var_Max# )
H# = del_B# - del_G#
else
if ( var_G# = var_Max# )
H# = ( 1.0 / 3.0 ) + del_R# - del_B#
else
if ( var_B# = var_Max# )
H# = ( 2.0 / 3.0 ) + del_G# - del_R#
endif
endif
endif
if ( H# < 0 ) then H# = H# + 1
if ( H# > 1 ) then H# = H# - 1
endif
pixel(0).H = H#
pixel(0).S = S#
pixel(0).L = L#
endfunction
A study done by William Speyer, who was a victim of prison rape in 1989, shows that 34% of [prison] rape victims released from prison become child molestors.