Skip to content

Commit

Permalink
first real commit // html generative config file project
Browse files Browse the repository at this point in the history
Todo:
Comments for description
Interactive settings for color choice (depends of the hour of the day??)
Settings is saved and used for real background..
  • Loading branch information
guilbep committed Nov 28, 2012
1 parent 7123022 commit 0880a55
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions colorsgenerator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<html>
<head>
<script type="text/javascript">
function c255ToHex(n)
{
var hexString = "0123456789ABCDEF";
firstpos = (n & 0xF0) >> 4;
secondpos = (n & 0x0F);
return hexString[firstpos] + hexString[secondpos];
}
function rgb2color(r,g,b)
{
return '#' + c255ToHex(r) + c255ToHex(g) + c255ToHex(b);
}


var i,r,g,b = g = r = i = 0;
var frequency = 0.001;
var amp = 90;
var center = 90;
var rmax = Math.floor(0.1*Math.PI / frequency);
var decalage = 1.5*Math.PI / frequency;

state = 1;
i = decalage;
function incrfreq(c)
{

if (c < decalage)
{
state = -state;
}
if (c > rmax + decalage)
{
state = -state;
}

c = c + state;

return c;

}

function incrementColor(c)
{
/* add a counter to slow down printing without changing rate */
if (c < rmax)
return c + 1;
else
return 0;
}

function colorchange()
{
i = incrfreq(i);
v = Math.sin(frequency*i) * amp + center;
r = Math.sin(frequency*i + 0) * amp + center;
g = Math.sin(frequency*i + 2) * amp + center;
b = Math.sin(frequency*i + 4) * amp + center;
color = rgb2color(r,g,b);

document.getElementById("test").style.color = 'black';
document.getElementById("test").innerHTML = color;
document.getElementById("lol").style.color = 'black';
document.getElementById("lol").innerHTML = rmax.toString();
document.body.style.background = color;
}
function load()
{
/* 40ms is 25hz :) 1000/25*/
window.setInterval(colorchange, 30);
}
</script>
</head>
<body onload="load();">
<div id="lol">
</div>
<div id="test">

</div>
</body>
</html>

0 comments on commit 0880a55

Please sign in to comment.