color-palette 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/color-palette.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 788d0ba6d3480c7ff5a1ed1ce0ed90d32bb4d171
|
4
|
+
data.tar.gz: 55585bf0d97aefe2bd76284556072b3a372ca117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8de5d5a91865641c724e6df6571848371b0b6d706311b375da6eee6d06bf2648ddfa24efe40c9696d5bf092862458a0a7eb466e70f9aec20c6c7f99deaa45e3
|
7
|
+
data.tar.gz: a749236b21ba06e855940f4e475bb5c294fc0aa94fc2e010b53f939b22e4ef01a816f0e2314fbcb10ecfe23d2f3053e984e39cf5ca22b5219b3c7c48ecf76458
|
data/lib/color-palette.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#color-palette.rb
|
2
|
-
require 'pry'
|
3
2
|
class ColorPalette
|
4
|
-
|
3
|
+
def get_hsl_values_decimal(color)
|
5
4
|
|
6
5
|
end
|
7
6
|
def get_color_codes_in_hex(h, s, l)
|
@@ -43,10 +42,11 @@ class ColorPalette
|
|
43
42
|
h3 = b.to_s(16).length == 2 ? b.to_s(16) : "0"+b.to_s(16)
|
44
43
|
return "##{h1}#{h2}#{h3}"
|
45
44
|
end
|
46
|
-
|
45
|
+
def self.palette(size, options = {})
|
47
46
|
color_palette = []
|
48
47
|
hue_array = []
|
49
48
|
hue = 359
|
49
|
+
size = size.to_i
|
50
50
|
step_size = 360/size
|
51
51
|
for i in 0..size-1
|
52
52
|
hue_array.push(hue)
|
@@ -63,10 +63,15 @@ class ColorPalette
|
|
63
63
|
color_codes["hex"] = rgb2hex(rgb[0].to_i, rgb[1].to_i, rgb[2].to_i)
|
64
64
|
color_palette.push(color_codes) unless color_palette.include?(color_codes)
|
65
65
|
end
|
66
|
+
if options[:hex] != nil
|
67
|
+
if options[:hex] == true
|
68
|
+
cpalette = []
|
69
|
+
color_palette.each do |color|
|
70
|
+
cpalette.push(color["hex"])
|
71
|
+
end
|
72
|
+
color_palette = cpalette
|
73
|
+
end
|
74
|
+
end
|
66
75
|
return color_palette
|
67
76
|
end
|
68
77
|
end
|
69
|
-
|
70
|
-
# cp = ColorPalette.new
|
71
|
-
# colors = cp.get_colors_arrays(20)
|
72
|
-
# puts ColorPalette.palette(4)
|