Skip to content

Instantly share code, notes, and snippets.

@johnciacia
Last active December 14, 2017 15:36
Show Gist options
  • Save johnciacia/4539592 to your computer and use it in GitHub Desktop.
Save johnciacia/4539592 to your computer and use it in GitHub Desktop.
Animated ASCII Penis
<!DOCTYPE html>
<html>
<head>
<title>Animated ASCII Penis</title>
</head>
<body>
<span id="pen">8====================D</span>
<span id="is"> </span>
<script>
String.prototype.replaceAt = function(index, char) {
return this.substr(0, index) + char + this.substr(index+char.length);
}
var count = 5,
max = 15,
min = 5,
direction = 0,
time = 200,
pen = document.getElementById("pen").innerHTML;
window.setInterval(function() {
if(count < max && direction == 0) {
document.getElementById("pen").innerHTML = pen.replaceAt(count, 'jjjj');
count++;
if(count == max-1) {
direction = 1;
}
}
if(count > min && direction == 1) {
document.getElementById("pen").innerHTML = pen.replaceAt(count, 'jjjj');
count--;
if(count == min) {
direction = 0;
}
}
}, time)
window.setInterval(function() {
document.getElementById("is").innerHTML = document.getElementById("is").innerHTML.replaceAt(0, '~~~');
}, time*20);
window.setInterval(function() {
document.getElementById("is").innerHTML = '';
}, time*30);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment