~macslow/unity/phablet-integrate-notification-backend

« back to all changes in this revision

Viewing changes to Greeter/Gradient.js

Initial implementation of Infographic with stubbed LightDM infographic API.

Approved by PS Jenkins bot, Michael Zanetti.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 */
 
16
 
 
17
function twoColorByIndex(index, total, colors) {
 
18
    var red, green, blue
 
19
    var p = index / total
 
20
 
 
21
    if (p < 0.5) {
 
22
        red = (colors.main.r * p * 2.0) + colors.start.r * (0.5 - p) * 2.0;
 
23
        green = (colors.main.g * p * 2.0) + colors.start.g * (0.5 - p) * 2.0;
 
24
        blue = (colors.main.b * p * 2.0) + colors.start.b * (0.5 - p) * 2.0;
 
25
    } else {
 
26
        red = colors.end.r * (p - 0.5) * 2.0 + colors.main.r * (1.0 - p) * 2.0;
 
27
        green = colors.end.g * (p - 0.5) * 2.0 + colors.main.g * (1.0 - p) * 2.0;
 
28
        blue = colors.end.b * (p - 0.5) * 2.0 + colors.main.b * (1.0 - p) * 2.0;
 
29
    }
 
30
 
 
31
    return Qt.rgba(red, green, blue, 1)
 
32
}