@chris fullmer said:
Thom gave a great example with some if loops I think that let you blend the entire rainbow smoothly from red to pink to purple to blue to cyan to green to yellow then orange and back to red. I'd have to search a ways back to think where that was posted though.
I couldn't find the example I posted earlier either, so here it is again:
<span class="syntaxdefault"><br /></span><span class="syntaxcomment"># Soft Selection Colour Map<br /># Colours to translate to. First is max, last is bottom.<br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[]<br />@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># 100%<br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># 75%<br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># 50%<br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># 25%<br /></span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">255</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># 0%<br /></span><span class="syntaxdefault">def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">clr</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># Accessor<br /># (?) Should this be done by CExt?<br /></span><span class="syntaxdefault">def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">value_to_color</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> max </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 100</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> min </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> clr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">clr</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Cap value to range.<br /></span><span class="syntaxdefault"> value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">min</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> value</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">max<br /> value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">max</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> value</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">min<br /> </span><span class="syntaxcomment"># Calculate what colours to blend between and the blending ratio.<br /></span><span class="syntaxdefault"> n </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">value</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">min</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">/</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">max</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">min</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">/</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">clr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1.0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> index1 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> n</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i<br /> index2 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">index1</span><span class="syntaxkeyword">+</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> clr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">min<br /> ratio </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> n </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> index1<br /> return clr</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">index2</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">blend</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">clr</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">index1</span><span class="syntaxkeyword">],</span><span class="syntaxdefault"> ratio</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /></span>That's the method I use in Vertex Tools to colour the soft selection:
clr.png