Forum de discussion
Forum « Programmation Javascript » (archives)
Re: Palette de couleur
Envoyé: 29 octobre 2004, 8h38 par SpaceFrog
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nouvelle page 1</title>
<style type="text/css">
td {width:50px;
font-family:verdana;
font-size:12px;
text-align:center;
}
.buttons {cursor:pointer;
width:100%;
height:100%;
}
</style>
<script Language="JavaScript">
/***************************
* Color Scrip by SpaceFrog *
***************************/
var RColor=255;
var GColor=255;
var BColor=255;
var speed=50;
var Ctimer;
function RUp(){
if (RColor<256){
RColor++;
document.getElementById('RedIndex').innerHTML=RColor;
UpDateColor();
}
}
function RDn(){
if (RColor>0){
RColor--;}
document.getElementById('RedIndex').innerHTML=RColor;
UpDateColor();
}
function GUp(){
if (GColor<256){
GColor++;
document.getElementById('GreenIndex').innerHTML=GColor;
UpDateColor();
}
}
function GDn(){
if (GColor>0){
GColor--;}
document.getElementById('GreenIndex').innerHTML=GColor;
UpDateColor();
}
function BUp(){
if (BColor<256){
BColor++;
document.getElementById('BlueIndex').innerHTML=BColor;
UpDateColor();
}
}
function BDn(){
if (BColor>0){
BColor--;}
document.getElementById('BlueIndex').innerHTML=BColor;
UpDateColor();
}
function UpDateColor(){
var divcolor ='rgb\('+RColor+'\,'+GColor+'\,'+BColor+'\)'
document.getElementById('Screen').style.backgroundColor=divcolor;
return;
}
</script>
</head>
<body>
<table>
<tr>
<td style="background-color:rgb(255,0,0);"><div class="buttons" onmousedown="Ctimer= setInterval('RUp()',speed);" onmouseup="clearInterval(Ctimer);" width="100%"> + </div></td>
<td style="background-color:rgb(0,255,0);"><div class="buttons" onmousedown="Ctimer= setInterval('GUp()',speed);" onmouseup="clearInterval(Ctimer);"> + </div></td>
<td style="background-color:rgb(0,0,255);"><div class="buttons" onmousedown="Ctimer= setInterval('BUp()',speed);" onmouseup="clearInterval(Ctimer);"> + </div></td>
</tr>
<tr>
<td style="background-color:rgb(255,0,0);"><div class="buttons" onmousedown="Ctimer= setInterval('RDn()',speed);" onmouseup="clearInterval(Ctimer);"> - </div></td>
<td style="background-color:rgb(0,255,0);"><div class="buttons" onmousedown="Ctimer= setInterval('GDn()',speed);" onmouseup="clearInterval(Ctimer);"> - </div></td>
<td style="background-color:rgb(0,0,255);"><div class="buttons" onmousedown="Ctimer= setInterval('BDn()',speed);" onmouseup="clearInterval(Ctimer);"> - </div></td>
</tr>
<tr>
<td style="color:rgb(255,0,0); border:solid 1px;"><div id="RedIndex"> 250 </div></td>
<td style="color:rgb(0,255,0); border:solid 1px;"><div id="GreenIndex"> 250 </div></td>
<td style="color:rgb(0,0,255);border:solid 1px;"><div id="BlueIndex"> 250 </div></td>
</tr>
</table>
<div id="Screen" style="position:absolute;top:20%;left:10%;height:60%;width:80%;border:solid 1px;background-color:rgb(255,255,255);"> </div>
</body>
</html>
Réponses
|