Mercurial > hg > svgui
comparison layer/ColourMapper.cpp @ 1013:ac69043f82b6 colourschemes
Provide a sensible name for this colour scheme
author | Chris Cannam |
---|---|
date | Tue, 19 Jan 2016 12:56:19 +0000 |
parents | 2a85ab180d08 |
children | 6338d7dc3b6d |
comparison
equal
deleted
inserted
replaced
1012:2a85ab180d08 | 1013:ac69043f82b6 |
---|---|
23 | 23 |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 using namespace std; | 26 using namespace std; |
27 | 27 |
28 static vector<QString> ylGnBuS { | |
29 // this is ylGnBu 9 | |
30 // "#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081" | |
31 | |
32 "#ffffff", "#ffff00", "#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081","#042040" | |
33 | |
34 // this is PuOr 11 | |
35 // "#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b" | |
36 }; | |
37 | |
38 | |
39 static vector<QColor> convertStrings(const vector<QString> &strs) | 28 static vector<QColor> convertStrings(const vector<QString> &strs) |
40 { | 29 { |
41 vector<QColor> converted; | 30 vector<QColor> converted; |
42 for (const auto &s: strs) converted.push_back(QColor(s)); | 31 for (const auto &s: strs) converted.push_back(QColor(s)); |
43 reverse(converted.begin(), converted.end()); | 32 reverse(converted.begin(), converted.end()); |
44 return converted; | 33 return converted; |
45 } | 34 } |
46 | 35 |
47 static vector<QColor> ylGnBu = convertStrings(ylGnBuS); | 36 static vector<QColor> xRay = convertStrings({ |
37 // Based on ColorBrewer ylGnBu scale | |
38 "#ffffff", "#ffff00", "#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081","#042040" | |
39 }); | |
48 | 40 |
49 static void | 41 static void |
50 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b) | 42 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b) |
51 { | 43 { |
52 int n = colours.size(); | 44 int n = colours.size(); |
102 case FruitSalad: return tr("Fruit Salad"); | 94 case FruitSalad: return tr("Fruit Salad"); |
103 case Banded: return tr("Banded"); | 95 case Banded: return tr("Banded"); |
104 case Highlight: return tr("Highlight"); | 96 case Highlight: return tr("Highlight"); |
105 case Printer: return tr("Printer"); | 97 case Printer: return tr("Printer"); |
106 case HighGain: return tr("High Gain"); | 98 case HighGain: return tr("High Gain"); |
107 case YlGnBu: return tr("YlGnBu"); | 99 case XRay: return tr("X-Ray"); |
108 } | 100 } |
109 | 101 |
110 return tr("<unknown>"); | 102 return tr("<unknown>"); |
111 } | 103 } |
112 | 104 |
248 r = g = b = 1.0 - r; | 240 r = g = b = 1.0 - r; |
249 hsv = false; | 241 hsv = false; |
250 */ | 242 */ |
251 break; | 243 break; |
252 | 244 |
253 case YlGnBu: | 245 case XRay: |
254 hsv = false; | 246 hsv = false; |
255 mapDiscrete(norm, ylGnBu, r, g, b); | 247 mapDiscrete(norm, xRay, r, g, b); |
256 } | 248 } |
257 | 249 |
258 if (hsv) { | 250 if (hsv) { |
259 return QColor::fromHsvF(h, s, v); | 251 return QColor::fromHsvF(h, s, v); |
260 } else { | 252 } else { |