색상코드값을 입력하면 반대되는 색을 찾아줍니다
페이지 정보
작성자 서방님 댓글 0건 조회 73회 작성일 07-08-11 15:54본문
<html>
<head>
<title>BLUEB</title>
<script language="javascript">
function inverse(theString) {
if(theString.length<6||theString.length>6){
window.alert('정확한 칼라코드값을 입력하세요..n(#은 빼고 코드만 입력해야 합니다.)')
document.rin.reset();
return false;
}
a=theString.slice(0,2);
b=theString.slice(2,4);
c=theString.slice(4,6);
a1=16*giveHex(a.slice(0,1));
a2=giveHex(a.slice(1,2));
a=a1+a2;
b1=16*giveHex(b.slice(0,1));
b2=giveHex(b.slice(1,2));
b=b1+b2;
c1=16*giveHex(c.slice(0,1));
c2=giveHex(c.slice(1,2));
c=c1+c2;
newColor=DecToHex(255-a)+""+DecToHex(255-b)+""+DecToHex(255-c)
alert("You Entered "+theString+" and nYour inversed Color is n"+newColor);
myText="<table cellspacing='4' bgColor='#efefef' border='0' width='50%'><tr><td bgcolor='#"
+""+newColor+"'><font color='#"+theString+"' size=2>Background='#"+newColor+"'<"
+"/font></td><td bgColor='#"+newColor+"'><font color='#"+theString+"' face=arial"
+">Snippet1</font></td></tr><tr><td bgcolor='#"+theString+"'><font color='#"
+""+newColor+"' size=2>Background='#"+theString+"'</font></td><td bgColor="
+"'#"+theString+"'><font color='#"+newColor+"'>Snippet2</font></td></tr></table>"
stat.innerHTML=myText
}
var hexbase="0123456789ABCDEF";
function DecToHex(number) {
return hexbase.charAt((number>> 4)& 0xf)+ hexbase.charAt(number& 0xf);
}
function giveHex(s){
s=s.toUpperCase();
return parseInt(s,16);
}
</script>
</head>
<body>
칼라 코드값을 #을 뺀 나머지를 입력하세요..<br>
<B>예) EFEFEF</B>
<form name="rin">
<input type="text" name="Luc"><input type="button" value="Inverse Color" onclick="inverse(this.form.Luc.value)"><input type="reset" value="Reset">
</form>
<div id="stat"></div>
</body>
</html>
댓글목록
등록된 댓글이 없습니다.