cpalette 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/cpalette.rb +11 -1
- data/lib/cpalette/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ca1166f80c44a1306383d46600b20f57ee7b5af
|
4
|
+
data.tar.gz: 58fada6e6e35dd4848f76ea2c865dd8e0ee3cb5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30b0c436d6577743b11ae7592c9ecfd1cda56fdbc74bd0635e2e78dd088524e81bd8f372dd99568524b4b304cd2a7dc09a66515e653775e6644db25dd3781e9
|
7
|
+
data.tar.gz: e8f96bc900d787105827f07fdac16d1edb34dc31e48713014926fa8472eb91507ae28ab2d87666f9939ef6addebd6b777b5433f5b2a535fe52effe85c113c20c
|
data/README.md
CHANGED
@@ -20,13 +20,22 @@ Or install it yourself as:
|
|
20
20
|
$ gem install cpalette
|
21
21
|
|
22
22
|
## Usage
|
23
|
-
|
23
|
+
|
24
|
+
Case 1:
|
24
25
|
colors_array = Cpalette.palette(4)
|
25
26
|
|
26
27
|
=> [{"hsl"=>"359,62%,46%", "rgb"=>"190,45,47", "hex"=>"#be2d2f"}, {"hsl"=>"89,62%,80%", "rgb"=>"205,236,172", "hex"=>"#cdecac"}, {"hsl"=>"269,80%,71%", "rgb"=>"179,122,240", "hex"=>"#b37af0"}, {"hsl"=>"179,69%,79%", "rgb"=>"165,238,237", "hex"=>"#a5eeed"}]
|
27
28
|
|
28
29
|
colors_array returns you with an array of 4 hashes with hsl, rgb and hex values for each color.
|
29
30
|
|
31
|
+
Case 2:
|
32
|
+
You can pass an option :hex => true, which would return you an array containing only Hex values of required number of colors.
|
33
|
+
|
34
|
+
colors_array = Cpalette.palette(4, :hex => true)
|
35
|
+
|
36
|
+
=> ["#37e1de", "#a468e3", "#f0383b", "#a5e660"]
|
37
|
+
|
38
|
+
Returned colors_array contains only hex values of 4 different colors.
|
30
39
|
|
31
40
|
## Contributing
|
32
41
|
|
data/lib/cpalette.rb
CHANGED
@@ -43,10 +43,11 @@ module Cpalette
|
|
43
43
|
h3 = b.to_s(16).length == 2 ? b.to_s(16) : "0"+b.to_s(16)
|
44
44
|
return "##{h1}#{h2}#{h3}"
|
45
45
|
end
|
46
|
-
def self.palette(size)
|
46
|
+
def self.palette(size, args)
|
47
47
|
color_palette = []
|
48
48
|
hue_array = []
|
49
49
|
hue = 359
|
50
|
+
size = size.to_i
|
50
51
|
step_size = 360/size
|
51
52
|
for i in 0..size-1
|
52
53
|
hue_array.push(hue)
|
@@ -63,6 +64,15 @@ module Cpalette
|
|
63
64
|
color_codes["hex"] = rgb2hex(rgb[0].to_i, rgb[1].to_i, rgb[2].to_i)
|
64
65
|
color_palette.push(color_codes) unless color_palette.include?(color_codes)
|
65
66
|
end
|
67
|
+
if args[:hex] != nil
|
68
|
+
if args[:hex] == true
|
69
|
+
cpalette = []
|
70
|
+
color_palette.each do |color|
|
71
|
+
cpalette.push(color["hex"])
|
72
|
+
end
|
73
|
+
color_palette = cpalette
|
74
|
+
end
|
75
|
+
end
|
66
76
|
return color_palette
|
67
77
|
end
|
68
78
|
end
|
data/lib/cpalette/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpalette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- avinash-vllbh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|