Skip to content

Instantly share code, notes, and snippets.

@gregtatum
Created March 4, 2015 21:22
Show Gist options
  • Select an option

  • Save gregtatum/700348203b6033c829ab to your computer and use it in GitHub Desktop.

Select an option

Save gregtatum/700348203b6033c829ab to your computer and use it in GitHub Desktop.
Sine wave in the URL bar
//Copy/paste into your console
(function() {
var t = 0
var values = []
var msg = []
function loop() {
t++
if( t % 3 === 0 ) {
for( var i=0; i < 80; i++ ) {
values[i] = Math.sin( (t + i) * 0.4 )
var msg = values.map(function( v ) {
if( v >= -1 && v < -0.66 ) {
return "▁"
} else if( v >= -0.66 && v < -0.33 ) {
return "▃"
} else if( v >= -0.33 && v < 0 ) {
return "▅"
} else if( v >= 0 && v < 0.33 ) {
return "▆"
} else if( v >= 0.33 && v < 0.66 ) {
return "▇"
} else {
return "█"
}
})
}
window.history.replaceState( {} , 'wavey', msg.join('') )
}
requestAnimationFrame(loop)
}
loop()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment