<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Intrepid Blog &#187; rgb</title>
	<atom:link href="http://blog.affien.com/archives/tag/rgb/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.affien.com</link>
	<description>A few thoughts</description>
	<lastBuildDate>Mon, 23 Jan 2012 08:47:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>RGB to Hex (and why the python interactive mode is so damned handy)</title>
		<link>http://blog.affien.com/archives/2004/12/20/rgb-to-hex-and-why-the-python-interactive-mode-is-so-damned-handy/</link>
		<comments>http://blog.affien.com/archives/2004/12/20/rgb-to-hex-and-why-the-python-interactive-mode-is-so-damned-handy/#comments</comments>
		<pubDate>Sun, 19 Dec 2004 23:18:52 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[Code sniplets]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rgb]]></category>

		<guid isPermaLink="false">http://blog.w-nz.com/archives/2004/12/20/rgb-to-hex-and-why-the-python-interactive-mode-is-so-damned-handy/</guid>
		<description><![CDATA[Update 2010-02-01 Thanks to Sameer for pointing out the [...]]]></description>
			<content:encoded><![CDATA[<p><ins>Update 2010-02-01</ins> Thanks to Sameer for pointing out the short way of doing this: <code>return “#%02X%02X%02X” % (r,g,b)</code></p>
<blockquote><pre>def tohex(r,g,b):
	hexchars = "0123456789ABCDEF"
	return "#" + hexchars[r / 16] + hexchars[r % 16] + hexchars[g / 16] + hexchars[g % 16] + hexchars[b / 16] + hexchars[b % 16]</pre>
</blockquote>
<p><a href="http://python.org">Python</a> is very convenient when you need to program a simple algorithm. I programmed this RGB to Hex converter in less than 1 minute, including using the function for a few RGB values I needed to convert.</p>
<p>Usualy I just grab a pen and a paper and do the calculations myself for getting either the calculator of windows itself to show up and actually calculate stuff properly (looking to screen, writing down, forgetting to press C, starting again&#8230;), or writing a program in a language like C# would just take too much time.</p>
<p>I&#8217;ve been using Idle for quite some time as a very good replacement for both my calculator and my pen and paper.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2004/12/20/rgb-to-hex-and-why-the-python-interactive-mode-is-so-damned-handy/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

