Skip to content

Instantly share code, notes, and snippets.

@kentliau
Last active August 28, 2016 21:14
Show Gist options
  • Save kentliau/4916b5f9a8958cc2cc45e0dd1755aa95 to your computer and use it in GitHub Desktop.
Save kentliau/4916b5f9a8958cc2cc45e0dd1755aa95 to your computer and use it in GitHub Desktop.
Quick and dirty LCD screen color test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Screen test</title>
<style>
html, body {
width: 100%;
height: 100%;
}
</style>
</head>
<body onclick="changeColor()" ondblclick="autoChangeColor()">
<script>
var colors = [
"rgb(0,0,0)", // Black
"rgb(255,255,255)", // White
"rgb(127,127,127)", // Gray
"rgb(255,0,0)", // Red
"rgb(0,255,0)", // Green
"rgb(0,0,255)", // Blue
"rgb(0,255,255)", // Cyan
"rgb(255,255,0)", // Yellow
"rgb(255,0,255)" // Magenta
];
var count = colors.length;
var current = 0;
var intervalId;
function changeColor() {
document.body.style.backgroundColor = colors[current];
current++;
if (current >= count) {
current = 0;
}
}
function autoChangeColor() {
if (intervalId == undefined) {
intervalId = setInterval(function() {
changeColor()
}, 500);
} else {
clearInterval(intervalId);
intervalId = undefined;
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment