Color palette generator: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Little code snippet, that show how generate a<br /> color palette:
Little code snippet, that show how generate a<br /> color palette:


<code> QList&amp;lt;QBrush&amp;gt; brushScale;<br /> double h=0;<br /> double golden_ratio = 0.618033988749895;<br /> int ColorCount = 20;<br /> for (int i=0;i&amp;lt;ColorCount;i+'')<br /> {<br /> h''= golden_ratio * 360/ColorCount * i;<br /> h =(int)h60;<br /> brushScale.append(QBrush(QColor::fromHsv(int(h),245,245,255)));<br /> }</code>
<code> QList<QBrush> brushScale;<br /> double h=0;<br /> double golden_ratio = 0.618033988749895;<br /> int ColorCount = 20;<br /> for (int i=0;i<ColorCount;i+'')<br /> {<br /> h''= golden_ratio * 360/ColorCount * i;<br /> h =(int)h60;<br /> brushScale.append(QBrush(QColor::fromHsv(int(h),245,245,255)));<br /> }</code>


Taken from:<br /> http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
Taken from:<br /> http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/

Revision as of 06:42, 25 February 2015

Little code snippet, that show how generate a
color palette:

 QList<QBrush> brushScale;<br /> double h=0;<br /> double golden_ratio = 0.618033988749895;<br /> int ColorCount = 20;<br /> for (int i=0;i<ColorCount;i+'')<br /> {<br /> h''= golden_ratio * 360/ColorCount * i;<br /> h =(int)h60;<br /> brushScale.append(QBrush(QColor::fromHsv(int(h),245,245,255)));<br /> }

Taken from:
http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/