<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to convert Pd&#x27;s color numbers for data structures to RGB]]></title><description><![CDATA[<p>I could not find this on the web so i figured it out myself. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";)" alt=";)" /></p>
<p>Here is how you can convert the numbers used in data structures to represent colors to RGB values and vice versa:</p>
<p><a href="/uploads/files/1509643554027-pdcolor2rgb.pd">pdcolor2rgb.pd</a></p>
<p>The numbers 0 - 888 represent RGB values where every digit stands for one color. So 870 would be 8 for red, 7 for green and 0 for blue. This is equivalent to RGB (255, 223, 0). A digit 9 is the same as digit 8, so 858 = 959. The exact calculation is in the patch:<img src="/uploads/files/1509644309581-screenshot-from-2017-11-02-18-35-05.png" alt="Screenshot from 2017-11-02 18:35:05.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 08:45:56 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/11085.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Nov 2017 17:40:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to convert Pd&#x27;s color numbers for data structures to RGB on Thu, 02 Nov 2017 17:40:34 GMT]]></title><description><![CDATA[<p>I could not find this on the web so i figured it out myself. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";)" alt=";)" /></p>
<p>Here is how you can convert the numbers used in data structures to represent colors to RGB values and vice versa:</p>
<p><a href="/uploads/files/1509643554027-pdcolor2rgb.pd">pdcolor2rgb.pd</a></p>
<p>The numbers 0 - 888 represent RGB values where every digit stands for one color. So 870 would be 8 for red, 7 for green and 0 for blue. This is equivalent to RGB (255, 223, 0). A digit 9 is the same as digit 8, so 858 = 959. The exact calculation is in the patch:<img src="/uploads/files/1509644309581-screenshot-from-2017-11-02-18-35-05.png" alt="Screenshot from 2017-11-02 18:35:05.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb</guid><dc:creator><![CDATA[ingox]]></dc:creator><pubDate>Thu, 02 Nov 2017 17:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to How to convert Pd&#x27;s color numbers for data structures to RGB on Thu, 02 Nov 2017 17:46:15 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/ingox">@ingox</a> This is great, thanks alot!</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/2</guid><dc:creator><![CDATA[weightless]]></dc:creator><pubDate>Thu, 02 Nov 2017 17:46:15 GMT</pubDate></item><item><title><![CDATA[Reply to How to convert Pd&#x27;s color numbers for data structures to RGB on Thu, 02 Nov 2017 18:23:42 GMT]]></title><description><![CDATA[<p>Haha, in hindsight it looks so simple, but it took hours for me to figure it out, so i thought i'd better share it. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";)" alt=";)" /></p>
<p>Some additional notes:</p>
<p>The conversion from RGB to Pd number is obviously not always exact, because the Pd numbers represent far less values, so the conversion only finds somewhat near colors.</p>
<p>From this <a href="https://forum.pdpatchrepo.info/topic/9965/canvas-colors" rel="nofollow">thread about canvas RGB values</a> i learned that PD calculates numbers internally with double-precision but saves them only in single-precision, which is the reason that the RGB values can actually be calculated, but the result can not be saved. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";)" alt=";)" /></p>
<p>For everyone working with colors in data structures i highly recommend the jmmmp library which contains some very nice vanilla abstractions, including a color picker. You can find it at <a href="https://puredata.info/downloads/jmmmp" rel="nofollow">https://puredata.info/downloads/jmmmp</a> and in Deken/Find externals. The objects are [ds-color-sel], [pd-colors] and [rgb-color]. <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/grinning.png" title=":)" alt=":)" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/3</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/3</guid><dc:creator><![CDATA[ingox]]></dc:creator><pubDate>Thu, 02 Nov 2017 18:23:42 GMT</pubDate></item><item><title><![CDATA[Reply to How to convert Pd&#x27;s color numbers for data structures to RGB on Thu, 02 Nov 2017 20:10:00 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/ingox">@ingox</a> It's a shame Extended is so denigrated.  It is dripping with patches that do the same....... but well done though....... it is far from an obvious how to resolve colours in Pd.....!<br />
David.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/4</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/4</guid><dc:creator><![CDATA[whale-av]]></dc:creator><pubDate>Thu, 02 Nov 2017 20:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to How to convert Pd&#x27;s color numbers for data structures to RGB on Thu, 02 Nov 2017 20:33:40 GMT]]></title><description><![CDATA[<p>With the <code>[draw]</code> command in Purr Data there are methods to set colors:</p>
<pre><code>[struct demo float x float y symbol foo float v1 float v2 float v3]

[fill blue(
|
[draw rect 40 40]

[demo]
</code></pre>
<p>You can use English words to set a static color as above.<br />
You can also do</p>
<pre><code>[fill v1 v2 v3( &lt;- rgb colors

[fill hsl v1 v2 v3( &lt;- hsl colorspace

[fill hcl v1 v2 v3( &lt;- hcl colorspace

[fill lab v1 v2 v3( &lt;- lab colorspace

[fill symbol foo( &lt;- variable color name
</code></pre>
<p>The fields can also be constants, like <code>[fill rgb 0 255 0(</code></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/5</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11085/how-to-convert-pd-s-color-numbers-for-data-structures-to-rgb/5</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Thu, 02 Nov 2017 20:33:40 GMT</pubDate></item></channel></rss>