cpalette 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d40bfe9d0b38763d6b7dfe7d2c1b82b41a34294
4
- data.tar.gz: 2a36e40db525cb1705c69622e69a8f29a50f9be9
3
+ metadata.gz: 9ca1166f80c44a1306383d46600b20f57ee7b5af
4
+ data.tar.gz: 58fada6e6e35dd4848f76ea2c865dd8e0ee3cb5d
5
5
  SHA512:
6
- metadata.gz: 27629063c4f455d27213f7cb30ad32de5419c8c634cc831a80d73fc96007cc2783635dafa92507b6ddad958a3548011a1b8de2b29c63d1e6f2376b98e3f9e638
7
- data.tar.gz: 58751f8806dbe9dc89f679debd3ce079d48d200a6e0558bcc4525e754a5b500a4f26be55f2c34c0f06030789c05c05a171a804f432323d10428cf3cab7f56025
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
@@ -1,3 +1,3 @@
1
1
  module Cpalette
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
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-17 00:00:00.000000000 Z
11
+ date: 2014-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler