sugarcube 0.13.2 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sugarcube/to_s/uicolor.rb +19 -13
- data/lib/sugarcube/uicolor.rb +6 -4
- data/lib/sugarcube/version.rb +1 -1
- metadata +1 -1
@@ -13,23 +13,29 @@ class UIColor
|
|
13
13
|
end
|
14
14
|
return system_color if system_color
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
if self.red && self.green && self.blue
|
17
|
+
red = (self.red * 255).round << 16
|
18
|
+
green = (self.green * 255).round << 8
|
19
|
+
blue = (self.blue * 255).round
|
20
|
+
my_color = red + green + blue
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
inside = my_color.to_s(16)
|
23
|
+
inside = '0x' + '0' * (6 - inside.length)
|
24
|
+
|
25
|
+
Symbol.css_colors.each_pair do |color, hex|
|
26
|
+
if hex == my_color
|
27
|
+
inside = color.inspect
|
28
|
+
break
|
29
|
+
end
|
26
30
|
end
|
27
|
-
end
|
28
31
|
|
29
|
-
|
30
|
-
|
32
|
+
if self.alpha < 1
|
33
|
+
return "UIColor.color(#{inside}, #{alpha})"
|
34
|
+
else
|
35
|
+
return "UIColor.color(#{inside})"
|
36
|
+
end
|
31
37
|
else
|
32
|
-
|
38
|
+
super
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
data/lib/sugarcube/uicolor.rb
CHANGED
@@ -2,7 +2,7 @@ class UIColor
|
|
2
2
|
def uicolor ; self ; end
|
3
3
|
|
4
4
|
def red
|
5
|
-
_sugarcube_colors[:red]
|
5
|
+
_sugarcube_colors && _sugarcube_colors[:red]
|
6
6
|
end
|
7
7
|
|
8
8
|
def cgcolor
|
@@ -10,15 +10,15 @@ class UIColor
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def green
|
13
|
-
_sugarcube_colors[:green]
|
13
|
+
_sugarcube_colors && _sugarcube_colors[:green]
|
14
14
|
end
|
15
15
|
|
16
16
|
def blue
|
17
|
-
_sugarcube_colors[:blue]
|
17
|
+
_sugarcube_colors && _sugarcube_colors[:blue]
|
18
18
|
end
|
19
19
|
|
20
20
|
def alpha
|
21
|
-
_sugarcube_colors[:alpha]
|
21
|
+
_sugarcube_colors && _sugarcube_colors[:alpha]
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -43,6 +43,8 @@ private
|
|
43
43
|
blue: white[0],
|
44
44
|
alpha: alpha[0],
|
45
45
|
}
|
46
|
+
else
|
47
|
+
nil
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
data/lib/sugarcube/version.rb
CHANGED