Color palette generator: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Categorize)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Little code snippet, that show how generate a
{{LangSwitch}}
color palette:
[[Category:Snippets::Misc]]
Little code snippet, that show how generate a color palette:


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


Taken from:
== External Links ==
http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
# [http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/ Marin Ankerl's blog]

Latest revision as of 11:52, 28 November 2016

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

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

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

External Links

  1. Marin Ankerl's blog