Complimentary hex color calculator
How do I make an complimentary hex color calculator?
Breaks color input into an array of 6 characters, then loops through each element and converts it to a hex value while subtracting it from hex 'f' (this returns the compliment). Still inside the loop, the element is then converted to a string. The result is then printed by looping through each element of the same array and appending it to the variable bodyColor.. What is a complimentary hex color calculator? How do you make a complimentary hex color calculator? This script and codes were developed by Drew Adams on 04 October 2022, Tuesday.
Complimentary hex color calculator - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>complimentary hex color calculator</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="outer-container"> <div id="inner-container"> <div class="color-input-container"> <h2>Input hex color:</h2> <input id="color-input" type="text" name="inputColor" placeholder="e.g. edcba9"></input> <div id="submit-btn" class="no-select">Check It</div> <h2>Complementary hex color:</h2> <input id="color-output" type="text" name="outputColor" value="123456" disabled></input> </div> </div>
</div>
<p class="description">Determines the complement of an input hex color - input the 6 character hex color (0-9, a-f) without the hashtag/pound sign/number sign/whatever you want to call it. The complementary hex value will display in the lower text field.</p> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Complimentary hex color calculator - Script Codes CSS Codes
/* https://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section { display: block;
}
body { line-height: 1;
}
ol, ul { list-style: none;
}
blockquote, q { quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after { content: ''; content: none;
}
table { border-collapse: collapse; border-spacing: 0;
}
body { font-family: helvetica;
}
h2 { font-size: 20px; margin: 5px 0;
}
.no-select { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
}
#outer-container { background-color: #123456; height: 100%; width: 100%; padding: 100px 0;
}
#outer-container #inner-container { background-color: #edcba9; border: 1px solid black; height: 400px; width: 400px; margin: 0 auto; text-align: center;
}
#outer-container #inner-container .color-input-container { background: white; border: 1px solid black; margin: 20% auto; padding: 20px; width: 200px;
}
#outer-container #inner-container .color-input-container input[type=text] { text-align: center;
}
#outer-container #inner-container .color-input-container #submit-btn { background: #c0c0c0; border-radius: 5px; cursor: pointer; height: 25px; width: 100px; margin: 10px auto; padding-top: 8px;
}
.description { margin: 20px 30px; text-align: justify;
}
Complimentary hex color calculator - Script Codes JS Codes
$(document).ready(function() { $('#submit-btn').click(function() { checkInput(); });
});
//
function checkInput() { var input = $('#color-input').val(); // check if input is 6 chars long if(input.length != 6) { alert('invalid color, please try again (hex requires 6 characters).'); return; } // store each char from input in an array var inputHexArray = input.split(''); // check for valid hex values for(var i = 0; i < inputHexArray.length; i++) { if(((0 % inputHexArray[i] != 0) && inputHexArray[i] != 0) && // check for values 0-9 ((inputHexArray[i] != 'a') && (inputHexArray[i] != 'b') && // check for a or b (inputHexArray[i] != 'c') && (inputHexArray[i] != 'd') && // check for c or d (inputHexArray[i] != 'e') && (inputHexArray[i] != 'f'))) { // check for e or f alert('invalid hex value: ' + inputHexArray[i]); return; } else { var resultArray = []; // convert user input to hex value and do the math for(var i = 0; i < inputHexArray.length; i++) { resultArray.push(parseInt('f', 16) - parseInt(inputHexArray[i], 16)); resultArray[i] = resultArray[i].toString(16); }// end for-loop } }// end for-loop var bodyColor = ''; for(var i = 0; i < resultArray.length; i++) { bodyColor += resultArray[i]; } // change body and container background colors $('#inner-container').css({'background-color': '#' + input}); $('#outer-container').css({'background-color': '#' + bodyColor}); // update complementary color text $('#color-output').val(bodyColor);
}// end checkInput()
Developer | Drew Adams |
Username | drewtadams |
Uploaded | October 04, 2022 |
Rating | 3 |
Size | 4,557 Kb |
Views | 38,456 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Text banner | 1,955 Kb |
Binary clock | 2,930 Kb |
A Pen by Drew Adams | 1,741 Kb |
A lot of Alerts - Exercise | 2,444 Kb |
Amchart column graph | 2,246 Kb |
Gsap carousel | 3,394 Kb |
Tabbed widget | 3,986 Kb |
Jquery to-do list | 7,354 Kb |
Generic button | 2,046 Kb |
Parallax scrolling | 2,694 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Eunice A | Ejbronze | 2,203 Kb |
Long Shadow Button | Uixcrazy | 3,550 Kb |
Weather App | Kw7oe | 3,162 Kb |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
Basic jQuery Filter list | Mtedwards | 2,464 Kb |
Zip Button test | Lje7462 | 1,932 Kb |
Heatmap Color Scales | Stevepepple | 2,331 Kb |
Twitch JSON API | Jvhti | 2,808 Kb |
Parallax scrolling scene | Iharosi | 2,485 Kb |
Caputre Cam with JS | KimmoCommit | 2,795 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!