Given a chunk of text, assign that text a constant colour

0 comments

Some lovely classic asp



function writeColor(str)
	writeColor=writeColorEx(str,str)
end function 
function writeColorEx(coloursrc,str)
 
	dim sc:sc=0
	dim ar1:ar1=0
	dim ar2:ar2=0
	dim ar3:ar3=0
	'response.Write "len(coloursrc)["&len(coloursrc)&"]"
	for sc=1 to len(coloursrc)
		'response.Write sc
		'response.Write Mid(coloursrc, sc, 1) &"
"
		'response.Write asc(Mid(coloursrc, sc, 1)) &"
"
		if(sc<len(coloursrc)/3)then
			ar1=ar1+ asc(Mid(coloursrc, sc, 1)) 
		end if
		if(sc<(len(coloursrc)/3)*2)then
			ar2=ar2+ asc(Mid(coloursrc, sc, 1)) 
		end if
		if(sc>(len(coloursrc)/3)*2)then
			ar3=ar3+ asc(Mid(coloursrc, sc, 1)) 
		end if
	next
	'response.Write "
ar1["&ar1&"]"
	'response.Write "
ar2["&ar2&"]"
	'response.Write "
ar3["&ar3&"]"
	'response.Write "
mod1["& (ar1 mod 255)&"]"
	'response.Write "
mod2["& (ar2 mod 255)&"]"
	'response.Write "
mod3["& (ar3 mod 255)&"]"
	'response.Write "
mod1["& hex(ar1 mod 255)&"]"
	'response.Write "
mod2["& hex(ar2 mod 255)&"]"
	'response.Write "
mod3["& hex(ar3 mod 255)&"]"
	'dim inverse:inverse=hexPad(255-ar1 mod 255)& hexPad(255-ar2 mod 255)& hexPad(255-ar3 mod 255)
	dim color:color="fff"
	response.Write ""&amp;str&amp;""
end function
 
function hexPad(str)
	hexPad = right("0"&str,2)
end function
 

Comments


Leave a Comment