Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Underscore.js template for faded/cutoff text
- // usage: _.template($('#textFader').text())({'content' : WHATEV, 'max' : 25, 'colors' : 'grayscale'});
- <script id="textFader" type="text/html"><% if(colors=='grayscale') colors=new Array('rgb(0, 0, 0)','rgb(99, 99, 99)','rgb(189, 189, 189)','rgb(240, 240, 240)'); fade = max-colors.length+1; cutoff=content.length<=max?max:fade; for(var i = 0; i < cutoff; i++){ %><span style='color:<%= colors[0] %>'><%= content.substr(i,1) %></span><% } %><% for(var i = cutoff; i < max; i++){ %><span style='color:<%= colors[i-fade+1] %>'><%= content.substr(i,1) %></span><% } %></script>
- </head>
Advertisement
Add Comment
Please, Sign In to add comment