<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Making annoying rainbows in javascript</title>
	<atom:link href="http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/</link>
	<description>Interactive art, experimental software toys, screensavers and games by Jim Bumgardner.</description>
	<lastBuildDate>Sun, 15 Nov 2009 18:46:13 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Henry</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-42484</link>
		<dc:creator>Henry</dc:creator>
		<pubDate>Thu, 27 Aug 2009 02:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-42484</guid>
		<description>This will cycle the bgColor!




var t;
var i=0;
function RGB2Color(r,g,b)
  {
    return &#039;#&#039; + byte2Hex(r) + byte2Hex(g) + byte2Hex(b);
  }
function byte2Hex(n)
{
    var nybHexString = &quot;0123456789ABCDEF&quot;;
    return String(nybHexString.substr((n &gt;&gt; 4) &amp; 0x0F,1)) + nybHexString.substr(n &amp; 0x0F,1);
}

function timedCount()
{
frequency = .01;
amplitude = 255/2;
center = 255/2;
red   = Math.sin(frequency*i + 0*Math.PI/3) * amplitude + center;
green = Math.sin(frequency*i + 2*Math.PI/3) * amplitude + center;
blue  = Math.sin(frequency*i + 4*Math.PI/3) * amplitude + center;
document.bgColor=RGB2Color(red,green,blue);
i=i+1;
t=setTimeout(&quot;timedCount()&quot;,.01);
}





</description>
		<content:encoded><![CDATA[<p>This will cycle the bgColor!</p>
<p>var t;<br />
var i=0;<br />
function RGB2Color(r,g,b)<br />
  {<br />
    return &#8216;#&#8217; + byte2Hex(r) + byte2Hex(g) + byte2Hex(b);<br />
  }<br />
function byte2Hex(n)<br />
{<br />
    var nybHexString = &#8220;0123456789ABCDEF&#8221;;<br />
    return String(nybHexString.substr((n &gt;&gt; 4) &amp; 0&#215;0F,1)) + nybHexString.substr(n &amp; 0&#215;0F,1);<br />
}</p>
<p>function timedCount()<br />
{<br />
frequency = .01;<br />
amplitude = 255/2;<br />
center = 255/2;<br />
red   = Math.sin(frequency*i + 0*Math.PI/3) * amplitude + center;<br />
green = Math.sin(frequency*i + 2*Math.PI/3) * amplitude + center;<br />
blue  = Math.sin(frequency*i + 4*Math.PI/3) * amplitude + center;<br />
document.bgColor=RGB2Color(red,green,blue);<br />
i=i+1;<br />
t=setTimeout(&#8221;timedCount()&#8221;,.01);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anton</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-42354</link>
		<dc:creator>anton</dc:creator>
		<pubDate>Thu, 25 Dec 2008 11:04:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-42354</guid>
		<description>hey jbum thanx I ll try this one !
u are right HSB might be better way...</description>
		<content:encoded><![CDATA[<p>hey jbum thanx I ll try this one !<br />
u are right HSB might be better way&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbum</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-42353</link>
		<dc:creator>jbum</dc:creator>
		<pubDate>Wed, 24 Dec 2008 19:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-42353</guid>
		<description>Anton,

Certainly.  If you want to draw a line from blue to red in RGB space, the code would like something like this:

for (i = 0; i &lt; 255; ++i)
{
   var color = RGB2Color(i,0,255-i);
   document.write( &#039;&lt;font color=&quot;&#039; + color + &#039;&quot;&gt;&#9608;&#039;);
}

You could also do similar things with HSB space, which enable you to maintain the saturation of the color while changing the hue...</description>
		<content:encoded><![CDATA[<p>Anton,</p>
<p>Certainly.  If you want to draw a line from blue to red in RGB space, the code would like something like this:</p>
<p>for (i = 0; i < 255; ++i)<br />
{<br />
   var color = RGB2Color(i,0,255-i);<br />
   document.write( '<font color="' + color + '">&#9608;&#8217;);<br />
}</p>
<p>You could also do similar things with HSB space, which enable you to maintain the saturation of the color while changing the hue&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anton</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-42352</link>
		<dc:creator>anton</dc:creator>
		<pubDate>Mon, 22 Dec 2008 11:16:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-42352</guid>
		<description>Great tutorial man! I am trying to work out the settings for a 2-color gradient. Starting from blue ending to red... Any suggestion?? 
thanx!!</description>
		<content:encoded><![CDATA[<p>Great tutorial man! I am trying to work out the settings for a 2-color gradient. Starting from blue ending to red&#8230; Any suggestion??<br />
thanx!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbum</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-41285</link>
		<dc:creator>jbum</dc:creator>
		<pubDate>Sun, 09 Mar 2008 05:16:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-41285</guid>
		<description>Stoyen: True, but there is still a need to add the leading zero padding when producing hex digits for single digit numbers.  A sprintf() function would make things much easier, since you can use &quot;%02x&quot; to specify a 2-digit hex number with zero-padding.</description>
		<content:encoded><![CDATA[<p>Stoyen: True, but there is still a need to add the leading zero padding when producing hex digits for single digit numbers.  A sprintf() function would make things much easier, since you can use &#8220;%02x&#8221; to specify a 2-digit hex number with zero-padding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stoyan</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-41283</link>
		<dc:creator>stoyan</dc:creator>
		<pubDate>Sun, 09 Mar 2008 04:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-41283</guid>
		<description>This article is really cool!

BTW, to convert hex-to-dec in JavaScript you can also use:

var num = 170;
num.toString(16);

or 

(170).toString(16)

To binary? &lt;code&gt;toString(2)&lt;/code&gt;.</description>
		<content:encoded><![CDATA[<p>This article is really cool!</p>
<p>BTW, to convert hex-to-dec in JavaScript you can also use:</p>
<p>var num = 170;<br />
num.toString(16);</p>
<p>or </p>
<p>(170).toString(16)</p>
<p>To binary? <code>toString(2)</code>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KrazyDad &#187; Blog Archive &#187; Lucky Charms</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-5767</link>
		<dc:creator>KrazyDad &#187; Blog Archive &#187; Lucky Charms</dc:creator>
		<pubDate>Sun, 18 Mar 2007 00:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-5767</guid>
		<description>[...] A little something I made for my students during today&#8217;s actionscript class. Here&#8217;s the flash source code, and here&#8217;s an article that explains the technique I use to generate those groooovy colors. [...]</description>
		<content:encoded><![CDATA[<p>[...] A little something I made for my students during today&#8217;s actionscript class. Here&#8217;s the flash source code, and here&#8217;s an article that explains the technique I use to generate those groooovy colors. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Japh</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-1690</link>
		<dc:creator>Japh</dc:creator>
		<pubDate>Wed, 08 Nov 2006 12:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-1690</guid>
		<description>I believe the setTimeout() and setInterval() functions will allow you to do just that  :)</description>
		<content:encoded><![CDATA[<p>I believe the setTimeout() and setInterval() functions will allow you to do just that  :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbum</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-1628</link>
		<dc:creator>jbum</dc:creator>
		<pubDate>Sat, 28 Oct 2006 11:11:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-1628</guid>
		<description>Agreed.</description>
		<content:encoded><![CDATA[<p>Agreed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gemini6Ice</title>
		<link>http://www.krazydad.com/blog/2006/10/making-annoying-rainbows-in-javascript/comment-page-1/#comment-1600</link>
		<dc:creator>Gemini6Ice</dc:creator>
		<pubDate>Sat, 21 Oct 2006 17:55:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.krazydad.com/blog/2006/10/13/making-annoying-rainbows-in-javascript/#comment-1600</guid>
		<description>To further generalize, I would set up the function to allow different centers and widths for each color component, which would allow us to produce a rainbow of greens-blues, for example. 

I&#039;m curious to look up a way to make a web page&#039;s javascript run on timed intervals after loading, so that one could make a background with fluctuating colors. Or maybe white-on-black to black-on-white fluctuating. That would be fun and annoying! :D</description>
		<content:encoded><![CDATA[<p>To further generalize, I would set up the function to allow different centers and widths for each color component, which would allow us to produce a rainbow of greens-blues, for example. </p>
<p>I&#8217;m curious to look up a way to make a web page&#8217;s javascript run on timed intervals after loading, so that one could make a background with fluctuating colors. Or maybe white-on-black to black-on-white fluctuating. That would be fun and annoying! :D</p>
]]></content:encoded>
	</item>
</channel>
</rss>
