Advertisement
Guest User

Untitled

a guest
Aug 4th, 2010
1,460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <script>
  4. function shadeColor(color, shade) {
  5.     var colorInt = parseInt(color.substring(1),16);
  6.  
  7.     var R = (colorInt & 0xFF0000) >> 16;
  8.     var G = (colorInt & 0x00FF00) >> 8;
  9.     var B = (colorInt & 0x0000FF) >> 0;
  10.  
  11.     R = R + Math.floor((shade/255)*R);
  12.     G = G + Math.floor((shade/255)*G);
  13.     B = B + Math.floor((shade/255)*B);
  14.    
  15.     var newColorInt = (R<<16) + (G<<8) + (B);
  16.     var newColorStr = "#"+newColorInt.toString(16);
  17.    
  18.     return newColorStr;
  19. }
  20.  
  21. function printButtonClick() {
  22.     var textbox = document.getElementById("dynatext");
  23.     var color = textbox.value;
  24.     textbox.value = shadeColor(color, -10);
  25.     textbox.style.background=color;
  26. }
  27. </script>
  28. </head>
  29. <body>
  30.     <input type="text" id="dynatext">
  31.     <input type="button" value="Print" onclick="printButtonClick();"/>
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement