-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
38 lines (27 loc) · 805 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var colorApp = angular.module('colorApp', []);
colorApp.controller('colorCtrl', ['$scope', function($scope){
$scope.show = false;
function getColor(color){
$scope.outputColor = color;
if (color.charAt(0)=="#") {
$scope.show = true;
}
else $scope.show = false;
$scope.R = hexToR(color);
$scope.G = hexToG(color);
$scope.B = hexToB(color);
function hexToR(h) {
return parseInt((cutHex(h)).substring(0, 2), 16)
}
function hexToG(h) {
return parseInt((cutHex(h)).substring(2, 4), 16)
}
function hexToB(h) {
return parseInt((cutHex(h)).substring(4, 6), 16)
}
function cutHex(h) {
return (h.charAt(0) == "#") ? h.substring(1, 7) : h
}
}
$scope.getColor = getColor;
}]);