In this article I shall be presenting a method of changing the RGB colours used
in HTML. The examples presented in this article related to a requirement to be
able to adjust the colour to be illustrated in a <td>, to show a series
of stripes getting either lighter or darker.
The first function shown is used to darken the colour. For a given colour and
modifier value it will return a darker colour.
<%
function colourDarker(myColour, modifier)
thisColour=""
item1=""
item2=""
item3=""
for i = 1 to 6 step 2
item1=mid(replace(myColour, "#",
""), i, 2)
item2=mid(modifier, i, 2)
item1 = CInt("&h"&item1)
item2 = CInt("&h"&item2)
item3=(item1-item2)
if item3<0 then
item3=0
end if
item3=CSTR(HEX(item3))
if Len(item3)=1 then item3="0"+item3
thisColour=thisColour+CStr(item3)
next
colourDarker=replace(thisColour, "&H", "")
end function
%>
and finally a short piece of HTML to product some stripes:
<table
width="100">
<%
For i = 2
to 8 step
2
showColour=colourDarker("eeeeee", cStr(i
& "0" & i & "0" & i & "0"))
%>
<tr>
<td width="100"
bgcolor="<%=showColour%>"> </td>
</tr>
<%next
'i%>
</table>
| This article viewed: 936 times | Back |
Copyright © 2004-2007 Janet Systems Ltd.