comparison layer/ColourMapper.cpp @ 1417:2487521e857b

Merge
author Chris Cannam
date Wed, 23 Jan 2019 14:44:16 +0000
parents c8a6fd3f9dff
children
comparison
equal deleted inserted replaced
1416:d794630429a7 1417:2487521e857b
109 static void 109 static void
110 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b) 110 mapDiscrete(double norm, vector<QColor> &colours, double &r, double &g, double &b)
111 { 111 {
112 int n = int(colours.size()); 112 int n = int(colours.size());
113 double m = norm * (n-1); 113 double m = norm * (n-1);
114 if (m >= n-1) { colours[n-1].getRgbF(&r, &g, &b, 0); return; } 114 if (m >= n-1) { colours[n-1].getRgbF(&r, &g, &b, nullptr); return; }
115 if (m <= 0) { colours[0].getRgbF(&r, &g, &b, 0); return; } 115 if (m <= 0) { colours[0].getRgbF(&r, &g, &b, nullptr); return; }
116 int base(int(floor(m))); 116 int base(int(floor(m)));
117 double prop0 = (base + 1.0) - m, prop1 = m - base; 117 double prop0 = (base + 1.0) - m, prop1 = m - base;
118 QColor c0(colours[base]), c1(colours[base+1]); 118 QColor c0(colours[base]), c1(colours[base+1]);
119 r = c0.redF() * prop0 + c1.redF() * prop1; 119 r = c0.redF() * prop0 + c1.redF() * prop1;
120 g = c0.greenF() * prop0 + c1.greenF() * prop1; 120 g = c0.greenF() * prop0 + c1.greenF() * prop1;