Skip to content

Instantly share code, notes, and snippets.

Created October 20, 2016 19:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Tygodniowe wyzwanie programistyczne #7 - Creative coding challenge
#textedit {
width: 100%;
height: 100%;
background: transparent;
margin: 0px;
padding: 0px;
border: 0px none;
font-size: 2em;
<textarea id="textedit" onkeydown="keyPressed()"></textarea>
var lastTimeKeyPressed = 0;
var speed = 1000;
function keyPressed() {
lastTimeKeyPressed = (new Date).getTime();
function updateColor() {
var diff = (new Date).getTime()-lastTimeKeyPressed;
var r = 255-Math.floor((255-135)*Math.min(1, diff/speed));
var g = 105+Math.floor((206-105)*Math.min(1, diff/speed));
var b = 97+Math.floor((250-97)*Math.min(1, diff/speed));
var rgb = '#'+r.toString(16)+g.toString(16)+b.toString(16); = rgb;
setInterval(function(){ updateColor(); }, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment