/*! * $ Simple glitching plugin * Author: Igor Brkic * Version 0.0.1 * Licensed under the MIT license */ (function($){ $.fn.glitch = function(options) { var s = $.extend({ bg: null, // background color maxint: 20, // max interval between glitchings minint: 2, // min interval between glitchings maxglitch: 5, // max number of twitches hshift: 3, // max horizontal shift vshift: 3, // max vertical shift direction: 'horizontal' // 'horizontal', 'vertical' or 'random' }, options); return this.each(function(){ $t=$(this); $t.wrap(''); var $s=$t.closest('span'); var $c=$t.clone(); var height=$t.height(); var width=$t.width(); if(s.bg===null){ s.bg=$t.css('background-color'); } $c.css({ position: 'absolute', top:0, left:0, height: height, width: width, overflow: 'hidden', 'background-color': s.bg }); $s.append($c); var rnd=function(a){return Math.floor(Math.random()*(a+1));} var g = function(){ var i; for(i=0;i