2 * Copyright (C) 2014 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19/*! \brief Calculate average luminance of the passed colors
21 \note If not fully opaque, luminance is dependant on blending.
25 // TODO this was originally
26 // for (var k in arguments) {
27 // but for some unkown reason was causing crashes in testDash/testDashContent
28 // investigate when we have some time
29 for (var k = 0; k < arguments.length; ++k) {
30 // only way to convert string to color
31 var c = Qt.lighter(arguments[k], 1.0);
33 sum += 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b;
36 return sum / arguments.length;