2006-10-12

javascript gradient discretizer

<html>
<body>

<table bgcolor="#333" cellspacing="1"><tr>
<script>
var
r1="00"; g1="31"; b1="63";
r2="ee"; g2="ee"; b2="ee";
nn=4;
hexx= new Array(
"0", "1", "2", "3", "4","5", "6", "7", "8",
"9", "a", "b", "c", "d", "e", "f")


r1d=parseInt(r1,16);g1d=parseInt(g1,16);b1d=parseInt(b1,16);
r2d=parseInt(r2,16);g2d=parseInt(g2,16);b2d=parseInt(b2,16);
dr=Math.floor(r2d/nn-r1d/nn);dg=Math.floor(g2d/nn-g1d/nn);db=Math.floor(b2d/n
n-b1d/nn);

for (var j=0; j<=nn; j++) {
document.writeln("<td width=166 height=55 bgcolor=#"+
hexx[Math.floor((r1d +j*dr)/ 16)]+hexx[(r1d +j*dr)% 16]+
hexx[Math.floor((g1d +j*dg)/ 16)]+hexx[(g1d +j*dg)% 16]+
hexx[Math.floor((b1d +j*db)/ 16)]+hexx[(b1d +j*db)% 16]+"></td>" );
}

// document.writeln(r1d );
</script>
</tr></table>

</body>
</html>

Comments on "javascript gradient discretizer"

 

post a comment