Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script>
- function shadeColor(color, shade) {
- var colorInt = parseInt(color.substring(1),16);
- var R = (colorInt & 0xFF0000) >> 16;
- var G = (colorInt & 0x00FF00) >> 8;
- var B = (colorInt & 0x0000FF) >> 0;
- R = R + Math.floor((shade/255)*R);
- G = G + Math.floor((shade/255)*G);
- B = B + Math.floor((shade/255)*B);
- var newColorInt = (R<<16) + (G<<8) + (B);
- var newColorStr = "#"+newColorInt.toString(16);
- return newColorStr;
- }
- function printButtonClick() {
- var textbox = document.getElementById("dynatext");
- var color = textbox.value;
- textbox.value = shadeColor(color, -10);
- textbox.style.background=color;
- }
- </script>
- </head>
- <body>
- <input type="text" id="dynatext">
- <input type="button" value="Print" onclick="printButtonClick();"/>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement