-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglitch.html
66 lines (59 loc) · 1.73 KB
/
glitch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
layout: post
title: "glitch text"
type: "experiment"
date: 2013-11-22 23:00:00
---
<style>
.glitchText span {
position: static;
}
</style>
<p>Move your mouse over the text below to get random unicode symbols. Warning: this might slow your computer down a bit.</p>
<p>
<p>
<p class="first-paragraph glitchText">For a few weeks now I've been interested in glitch art. For a few weeks now I've been interested in glitch art. For a few weeks now I've been interested in glitch art. For a few weeks now I've been interested in glitch art. For a few weeks now I've been interested in glitch art. For a few weeks now I've been interested in glitch art.</p>
<script src="/js/jquery.lettering-0.6.1.min.js"></script>
<script type="text/javascript">
$(function() {
$(".glitchText").lettering();
var $el = $('.glitchText span');
var spanX = new Array( $el.length );
var spanY = new Array( $el.length );
var origArr = [];
var charLoop = {};
var $this;
var mouseX = 0;
var mouseY = 0;
$el.each(function(k,v){
origArr[k] = v.innerHTML;
});
$('body').mousemove(function(e) {
mouseX = e.pageX;
mouseY = e.pageY;
$el.each(function(k, v) {
var offset = $(this).offset();
spanX[k] = offset.left + $(this).width()/2;
spanY[k] = offset.top + $(this).height()/2;
v = $(v);
var x = spanX[k] - mouseX;
var y = spanY[k] - mouseY;
var d = Math.round(Math.sqrt( x*x + y*y )*4);
if (d < 200) {
charLoop[k] = setInterval(function () {
randomChar(v);
}, d*2);
} else {
if(charLoop[k]) {
clearInterval( charLoop[k] );
$el[k].innerHTML = origArr[k];
}
}
});
});
var randomChar = function (char) {
var uni = Math.random() * (9999 - 127) + 127;
return char.text(String.fromCharCode(uni));
};
});
</script>