Changeset View
Changeset View
Standalone View
Standalone View
widgets/colorSimilarity/kpColorSimilarityCubeRenderer.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 46 | static QColor Color (int redOrGreenOrBlue, | |||
---|---|---|---|---|---|
48 | double colorSimilarity, | 48 | double colorSimilarity, | ||
49 | int similarityDirection, | 49 | int similarityDirection, | ||
50 | int highlight) | 50 | int highlight) | ||
51 | { | 51 | { | ||
52 | int brightness = int (baseBrightness + | 52 | int brightness = int (baseBrightness + | ||
53 | similarityDirection * | 53 | similarityDirection * | ||
54 | 0.5 * colorSimilarity * kpColorSimilarityHolder::ColorCubeDiagonalDistance); | 54 | 0.5 * colorSimilarity * kpColorSimilarityHolder::ColorCubeDiagonalDistance); | ||
55 | 55 | | |||
56 | if (brightness < 0) | 56 | if (brightness < 0) { | ||
57 | brightness = 0; | 57 | brightness = 0; | ||
58 | else if (brightness > 255) | 58 | } | ||
59 | else if (brightness > 255) { | ||||
59 | brightness = 255; | 60 | brightness = 255; | ||
61 | } | ||||
60 | 62 | | |||
61 | switch (redOrGreenOrBlue) | 63 | switch (redOrGreenOrBlue) | ||
62 | { | 64 | { | ||
63 | default: | 65 | default: | ||
64 | case 0: return QColor (brightness, highlight, highlight); | 66 | case 0: return {brightness, highlight, highlight}; | ||
65 | case 1: return QColor (highlight, brightness, highlight); | 67 | case 1: return {highlight, brightness, highlight}; | ||
66 | case 2: return QColor (highlight, highlight, brightness); | 68 | case 2: return {highlight, highlight, brightness}; | ||
67 | } | 69 | } | ||
68 | } | 70 | } | ||
69 | 71 | | |||
70 | //--------------------------------------------------------------------- | 72 | //--------------------------------------------------------------------- | ||
71 | 73 | | |||
72 | static QPointF PointBetween(const QPointF &p, const QPointF &q) | 74 | static QPointF PointBetween(const QPointF &p, const QPointF &q) | ||
73 | { | 75 | { | ||
74 | return QPointF((p.x() + q.x()) / 2.0, (p.y() + q.y()) / 2.0); | 76 | return {(p.x() + q.x()) / 2.0, (p.y() + q.y()) / 2.0}; | ||
75 | } | 77 | } | ||
76 | 78 | | |||
77 | //--------------------------------------------------------------------- | 79 | //--------------------------------------------------------------------- | ||
78 | 80 | | |||
79 | static void DrawQuadrant(QPaintDevice *target, | 81 | static void DrawQuadrant(QPaintDevice *target, | ||
80 | const QColor &col, | 82 | const QColor &col, | ||
81 | const QPointF &p1, const QPointF &p2, const QPointF &p3, | 83 | const QPointF &p1, const QPointF &p2, const QPointF &p3, | ||
82 | const QPointF &pointNotOnOutline) | 84 | const QPointF &pointNotOnOutline) | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 111 | { | |||
137 | QColor colors [2] = | 139 | QColor colors [2] = | ||
138 | { | 140 | { | ||
139 | ::Color (redOrGreenOrBlue, baseBrightness, colorSimilarity, -1, highlight), | 141 | ::Color (redOrGreenOrBlue, baseBrightness, colorSimilarity, -1, highlight), | ||
140 | ::Color (redOrGreenOrBlue, baseBrightness, colorSimilarity, +1, highlight) | 142 | ::Color (redOrGreenOrBlue, baseBrightness, colorSimilarity, +1, highlight) | ||
141 | }; | 143 | }; | ||
142 | 144 | | |||
143 | qCDebug(kpLogWidgets) << "\tmaxColorSimilarity=" << kpColorSimilarityHolder::MaxColorSimilarity | 145 | qCDebug(kpLogWidgets) << "\tmaxColorSimilarity=" << kpColorSimilarityHolder::MaxColorSimilarity | ||
144 | << " colorCubeDiagDist=" << kpColorSimilarityHolder::ColorCubeDiagonalDistance | 146 | << " colorCubeDiagDist=" << kpColorSimilarityHolder::ColorCubeDiagonalDistance | ||
145 | << endl | 147 | << "\n" | ||
146 | << "\tbaseBrightness=" << baseBrightness | 148 | << "\tbaseBrightness=" << baseBrightness | ||
147 | << " color[0]=" << ((colors [0].rgba() & RGB_MASK) >> ((2 - redOrGreenOrBlue) * 8)) | 149 | << " color[0]=" << ((colors [0].rgba() & RGB_MASK) >> ((2 - redOrGreenOrBlue) * 8)) | ||
148 | << " color[1]=" << ((colors [1].rgba() & RGB_MASK) >> ((2 - redOrGreenOrBlue) * 8)); | 150 | << " color[1]=" << ((colors [1].rgba() & RGB_MASK) >> ((2 - redOrGreenOrBlue) * 8)); | ||
149 | 151 | | |||
150 | ::DrawQuadrant(target, colors [0], tm, tl, ml, mm); | 152 | ::DrawQuadrant(target, colors [0], tm, tl, ml, mm); | ||
151 | ::DrawQuadrant(target, colors [1], tm, tr, mr, mm); | 153 | ::DrawQuadrant(target, colors [1], tm, tr, mr, mm); | ||
152 | ::DrawQuadrant(target, colors [1], ml, bl, bm, mm); | 154 | ::DrawQuadrant(target, colors [1], ml, bl, bm, mm); | ||
153 | ::DrawQuadrant(target, colors [0], bm, br, mr, mm); | 155 | ::DrawQuadrant(target, colors [0], bm, br, mr, mm); | ||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |