rand_palette 0.1.0 → 0.1.1

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: fd0e6c0f4aedd100d6816288473e0c6ea278ef51
4
- data.tar.gz: c5195779d2aa60ac5979059e687b13b91d4e13b9
3
+ metadata.gz: 03236522cecb33ba31371d45b6a2c8ad1645bdbf
4
+ data.tar.gz: 3a4fa073e20cc75df25b598de162b80d9497e93b
5
5
  SHA512:
6
- metadata.gz: 7ebd17c08b89ba7512b65302c08729ff0f803bbcd32f791c7a5ba43189309b062671a0031d336d6804d4c4069c9e3c330a66a5c9ea99935da8f262c1298c5323
7
- data.tar.gz: 456ff31ca504c9fda789072a937fd3df56c24cd76ab9b88587206fc50ae73383e75d49c429823f2667abf26447a1b236224f962910fc9ce45b191d3e391b392b
6
+ metadata.gz: bb855c140c604d0556cec26a3c7c1316cefa223e8087bbc63fa5586bf1d370b629f5ba396393fe733d7686266554417940f6e12ae3816ab7de57d0faa51a9dca
7
+ data.tar.gz: 36d4b7a20340de9026147bc9b8e7a01a2913438af658797ea677911e9a93725046e59af57a521df162266180238f772061b1a04b76d6429c5fcfc3e1bdef11d5
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # RandPalette
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rand_palette`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Randomly pick distinct color
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,20 +20,10 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/ken/rand_palette. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
23
+ ```ruby
24
+ irb(main):001:0> RandPalette.random 5
25
+ => ["rgba(255,0,221,1)", "rgba(255,85,0,1)", "rgba(119,255,0,1)", "rgba(0,255,187,1)", "rgba(0,17,255,1)"]
26
+ irb(main):002:0> RandPalette.random 3, alpha: 0.2
27
+ => ["rgba(0,255,153,0.2)", "rgba(153,0,255,0.2)", "rgba(255,153,0,0.2)"]
28
+ ```
41
29
 
@@ -13,17 +13,22 @@ module RandPalette
13
13
  ScalarDesc.map{|c| [255, 0, c] }].flatten 1
14
14
 
15
15
  def self.random n, alpha: 1
16
- picked = rand Palette.size
17
- steps = Palette.size / n
16
+ raise RangeError, "No more than #{range} kinds od color" if n > range
17
+ picked = rand range
18
+ steps = range / n
18
19
  n.times.map do |t|
19
20
  picked = picked + steps
20
- picked = picked - Palette.size if picked >= Palette.size
21
+ picked = picked - range if picked >= range
21
22
  picked
22
23
  end.map do |picked|
23
24
  RGBA.new(Palette[picked] + [alpha]).to_s
24
25
  end
25
26
  end
26
27
 
28
+ def self.range
29
+ Palette.size
30
+ end
31
+
27
32
  class RGBA
28
33
 
29
34
  def initialize rgba
@@ -1,3 +1,3 @@
1
1
  module RandPalette
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rand_palette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler