Krita Source Code Documentation
Loading...
Searching...
No Matches
PaletteGeneratorConfig Struct Reference

#include <palettegeneratorconfig.h>

Public Member Functions

void fromByteArray (const QByteArray &str)
 
IndexColorPalette generate ()
 
 PaletteGeneratorConfig ()
 
QByteArray toByteArray ()
 

Public Attributes

QColor colors [4][4]
 
bool colorsEnabled [4][4]
 
bool diagonalGradients
 
int gradientSteps [3]
 
int inbetweenRampSteps
 

Detailed Description

Definition at line 12 of file palettegeneratorconfig.h.

Constructor & Destructor Documentation

◆ PaletteGeneratorConfig()

PaletteGeneratorConfig::PaletteGeneratorConfig ( )

Definition at line 11 of file palettegeneratorconfig.cpp.

12{
13 for(int j = 0; j < 4; ++j)
14 {
15 colors[0][j] = QColor(Qt::white);
16 colors[1][j] = QColor(Qt::yellow);
17 colors[2][j] = QColor(Qt::gray);
18 colors[3][j] = QColor(Qt::black);
19 }
20
21 for(int i = 0; i < 4; ++i)
22 for(int j = 0; j < 4; ++j)
23 colorsEnabled[i][j] = (j == 0);
24
25 for(int i = 0; i < 3; ++i)
26 gradientSteps[i] = 4;
27
29 diagonalGradients = false;
30}

References colors, colorsEnabled, diagonalGradients, gradientSteps, and inbetweenRampSteps.

Member Function Documentation

◆ fromByteArray()

void PaletteGeneratorConfig::fromByteArray ( const QByteArray & str)

Definition at line 58 of file palettegeneratorconfig.cpp.

59{
60 QDataStream stream(str);
61 stream.setVersion(QDataStream::Qt_4_6);
62 stream.setByteOrder(QDataStream::BigEndian);
63
64 int version;
65 stream >> version;
66 if(version == 0)
67 {
68 for(int i = 0; i < 4; ++i)
69 for(int j = 0; j < 4; ++j)
70 stream >> colors[i][j];
71
72 for(int i = 0; i < 4; ++i)
73 for(int j = 0; j < 4; ++j)
74 stream >> colorsEnabled[i][j];
75
76 for(int i = 0; i < 3; ++i)
77 stream >> gradientSteps[i];
78
79 stream >> inbetweenRampSteps;
80 stream >> diagonalGradients;
81 }
82 else
83 qDebug("PaletteGeneratorConfig::FromByteArray: Unsupported data version");
84}

References colors, colorsEnabled, diagonalGradients, gradientSteps, and inbetweenRampSteps.

◆ generate()

IndexColorPalette PaletteGeneratorConfig::generate ( )

Definition at line 86 of file palettegeneratorconfig.cpp.

87{
89 // Add all colors to the palette
90 for(int y = 0; y < 4; ++y)
91 for(int x = 0; x < 4; ++x)
92 if(colorsEnabled[y][x])
93 pal.insertColor(colors[y][x]);
94
95 for(int y = 0; y < 3; ++y)
96 {
97 for(int x = 0; x < 4; ++x)
98 if(colorsEnabled[y][x] && colorsEnabled[y+1][x])
99 pal.insertShades(colors[y][x], colors[y+1][x], gradientSteps[y]);
100 }
101
103 {
104 for(int y = 0; y < 4; ++y)
105 for(int x = 0; x < 3; ++x)
106 if(colorsEnabled[y][x] && colorsEnabled[y][x+1])
107 pal.insertShades(colors[y][x], colors[y][x+1], inbetweenRampSteps);
108 }
109
111 {
112 for(int y = 0; y < 3; ++y)
113 for(int x = 0; x < 4; ++x)
114 {
115 if(x+1 < 4)
116 if(colorsEnabled[y][x+1] && colorsEnabled[y+1][x])
117 pal.insertShades(colors[y][x+1], colors[y+1][x], gradientSteps[y]);
118 if(x-1 >= 0)
119 if(colorsEnabled[y][x-1] && colorsEnabled[y+1][x])
120 pal.insertShades(colors[y][x-1], colors[y+1][x], gradientSteps[y]);
121 }
122 }
123 return pal;
124}
void insertColor(QColor clr)
void insertShades(QColor clrA, QColor clrB, int shades)

References colors, colorsEnabled, diagonalGradients, gradientSteps, inbetweenRampSteps, IndexColorPalette::insertColor(), and IndexColorPalette::insertShades().

◆ toByteArray()

QByteArray PaletteGeneratorConfig::toByteArray ( )

Definition at line 32 of file palettegeneratorconfig.cpp.

33{
34 QByteArray retVal;
35 QDataStream stream(&retVal, QIODevice::WriteOnly);
36 stream.setVersion(QDataStream::Qt_4_6);
37 stream.setByteOrder(QDataStream::BigEndian);
38
39 // Version int
40 stream << 0;
41
42 for(int i = 0; i < 4; ++i)
43 for(int j = 0; j < 4; ++j)
44 stream << colors[i][j];
45
46 for(int i = 0; i < 4; ++i)
47 for(int j = 0; j < 4; ++j)
48 stream << colorsEnabled[i][j];
49
50 for(int i = 0; i < 3; ++i)
51 stream << gradientSteps[i];
52
53 stream << inbetweenRampSteps;
54 stream << diagonalGradients;
55 return retVal;
56}

References colors, colorsEnabled, diagonalGradients, gradientSteps, and inbetweenRampSteps.

Member Data Documentation

◆ colors

QColor PaletteGeneratorConfig::colors[4][4]

Definition at line 14 of file palettegeneratorconfig.h.

◆ colorsEnabled

bool PaletteGeneratorConfig::colorsEnabled[4][4]

Definition at line 15 of file palettegeneratorconfig.h.

◆ diagonalGradients

bool PaletteGeneratorConfig::diagonalGradients

Definition at line 18 of file palettegeneratorconfig.h.

◆ gradientSteps

int PaletteGeneratorConfig::gradientSteps[3]

Definition at line 16 of file palettegeneratorconfig.h.

◆ inbetweenRampSteps

int PaletteGeneratorConfig::inbetweenRampSteps

Definition at line 17 of file palettegeneratorconfig.h.


The documentation for this struct was generated from the following files: