colour 0.3 → 0.4.0

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.
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ red = StandardColoursRGB.red
4
+ white = StandardColoursRGB.white
5
+
6
+ describe Gradient do
7
+ it "should be initialized with two colours" do
8
+ Gradient.new(red, white)
9
+ end
10
+
11
+ it "should provide a colour at distance between two colours" do
12
+ c = Gradient.new(red,white).colour_at(0.5)
13
+ c.to_rgb.g.should eql(0.5)
14
+ c.to_rgb.b.should eql(0.5)
15
+ c.to_rgb.r.should eql(1.0)
16
+ end
17
+ end
data/spec/hsv_spec.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe "HSV Colours" do
4
+ it_behaves_like "every colour representation"
5
+
6
+ before(:each) do
7
+ @green = HSV.new(120, 1.0,1.0)
8
+ end
9
+ end
data/spec/rgb_spec.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe "RGB Colours" do
4
+ it_behaves_like "every colour representation"
5
+
6
+ before(:each) do
7
+ @green = RGB.new(0,1.0,0)
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ Dir["./lib/**/*.rb"].each do |d| require d end
2
+ Dir["./spec/support/**/*.rb"].each do |d| require d end
3
+
@@ -0,0 +1,86 @@
1
+ require 'rspec'
2
+ green = StandardColoursRGB.green
3
+
4
+
5
+ shared_examples "every colour representation", :shared => true do
6
+ it "should convert to RGB" do
7
+ green.should respond_to(:to_rgb)
8
+ green.to_rgb.g.should eql(1.0)
9
+ green.to_rgb.b.should eql(0.0)
10
+ green.to_rgb.r.should eql(0.0)
11
+ end
12
+
13
+ it "should convert to HSV" do
14
+ green.should respond_to(:to_hsv)
15
+ green.to_hsv.h.should eql(120.0)
16
+ green.to_hsv.s.should eql(1.0)
17
+ green.to_hsv.v.should eql(1.0)
18
+ end
19
+
20
+ it "should provide a Web Safe Hex" do
21
+ green.web_safe.should eql("#0F0")
22
+ end
23
+
24
+ it "should walk a gradient through the RGB space towards another colour" do
25
+ gradient = green.gradient_to(RGB.new(1,0,1), steps=3)
26
+ gradient.size.should eql(3)
27
+ gradient[0].hex.should eql(green.hex)
28
+ gradient[1].hex.should eql(RGB.new(0.5, 0.5, 0.5).hex)
29
+ gradient[2].hex.should eql(RGB.new(1,0,1).hex)
30
+ end
31
+
32
+ it "should accept a gradient walk of one step and return the origin" do
33
+ gradient = green.gradient_to(RGB.new(1,0,1), steps = 1)
34
+ gradient.size.should eql(1)
35
+ gradient[0].hex.should eql(green.hex)
36
+ end
37
+
38
+ it "should accept a gradient walk for two steps and return the endpoints" do
39
+ blue = StandardColoursRGB.blue
40
+ gradient = green.gradient_to(blue, steps = 2)
41
+ gradient.size.should eql(2)
42
+ gradient[0].hex.should eql(green.hex)
43
+ gradient[1].hex.should eql(blue.hex)
44
+ end
45
+
46
+ it "should default to a 10 step gradient" do
47
+ blue = StandardColoursRGB.blue
48
+ gradient = green.gradient_to(blue)
49
+ gradient.size.should eql(10)
50
+ end
51
+
52
+ it "should provide a complementary colour" do
53
+ c = green.complementary
54
+ c.nil?.should eql(false)
55
+ c.hex.should eql(0xFF00FF)
56
+ end
57
+
58
+ it "should provide a split complementary set of colours" do
59
+ colours = green.split_complementary
60
+ colours.size.should eql(2)
61
+ colours[0].hex.should eql(0x7F00FF)
62
+ colours[1].hex.should eql(0xFF007F)
63
+ end
64
+
65
+
66
+ it "should apply a block when generating a split complementary set of colours if one is provided" do
67
+ i = 0
68
+ #TODO it would be nice to use the .should_recieve(:blah).and_yeild(:check)
69
+ # but because this is a shared test, one time we will get RGB, another we get HSV
70
+ green.split_complementary do |c|
71
+ if c.hex == 0x7F00FF or c.hex == 0xFF007F then
72
+ i += 1
73
+ end
74
+ end
75
+ i.should eql(2)
76
+ end
77
+
78
+ it "should provide a series of colours rotating around the Hue wheel" do
79
+ colours = green.rotate_hue(degrees = 36, steps = 11)
80
+ colours.size.should eql(11)
81
+ colours[0].hex.should eql(colours[10].hex)
82
+ colours[4].hex.should eql(0xFF00FF)
83
+ end
84
+ end
85
+
86
+
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colour
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ prerelease:
5
+ version: 0.4.0
5
6
  platform: ruby
6
7
  authors:
7
8
  - Wes Devauld
@@ -9,67 +10,110 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-01-13 00:00:00 -07:00
13
+ date: 2011-09-07 00:00:00 -06:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: bones
17
+ name: bundler
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.4
17
35
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "2.6"
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rcov
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
20
53
  requirements:
21
54
  - - ">="
22
55
  - !ruby/object:Gem::Version
23
- version: 2.2.0
24
- version:
25
- description: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ description: Support for computation of colour swatches in both the RGB and HSV colour representations
26
61
  email: wes@devauld.ca
27
62
  executables: []
28
63
 
29
64
  extensions: []
30
65
 
31
66
  extra_rdoc_files:
32
- - History.txt
67
+ - LICENSE.txt
33
68
  - README.txt
34
69
  files:
35
- - History.txt
36
- - Manifest.txt
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - LICENSE.txt
37
73
  - README.txt
38
74
  - Rakefile
75
+ - VERSION
39
76
  - colour.gemspec
40
- - colour.rb
41
77
  - lib/colour.rb
78
+ - lib/gradient.rb
42
79
  - lib/hsv.rb
43
80
  - lib/rgb.rb
44
81
  - lib/standard_colours.rb
82
+ - spec/gradient_spec.rb
83
+ - spec/hsv_spec.rb
84
+ - spec/rgb_spec.rb
85
+ - spec/spec_helper.rb
86
+ - spec/support/color_representation.rb
45
87
  has_rdoc: true
46
- homepage: http://code.devauld.ca/git/colour/
88
+ homepage: http://github.com/wdevauld/colour
89
+ licenses:
90
+ - MIT
47
91
  post_install_message:
48
- rdoc_options:
49
- - --main
50
- - README.txt
92
+ rdoc_options: []
93
+
51
94
  require_paths:
52
95
  - lib
53
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
54
98
  requirements:
55
99
  - - ">="
56
100
  - !ruby/object:Gem::Version
101
+ hash: -752018127558894247
102
+ segments:
103
+ - 0
57
104
  version: "0"
58
- version:
59
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
60
107
  requirements:
61
108
  - - ">="
62
109
  - !ruby/object:Gem::Version
63
110
  version: "0"
64
- version:
65
111
  requirements: []
66
112
 
67
- rubyforge_project: !binary |
68
- AA==
69
-
70
- rubygems_version: 1.2.0
113
+ rubyforge_project:
114
+ rubygems_version: 1.6.2
71
115
  signing_key:
72
- specification_version: 2
73
- summary: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
116
+ specification_version: 3
117
+ summary: Colour manipulation library supporting RGB and HSV representations
74
118
  test_files: []
75
119
 
data/History.txt DELETED
@@ -1,5 +0,0 @@
1
- == 0.3 / 2009-01-20
2
-
3
- * rSpec Testing
4
- * removed tests
5
- * now spec driven
data/Manifest.txt DELETED
@@ -1,11 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- colour.gemspec
6
- colour.rb
7
- lib/colour.rb
8
- lib/hsv.rb
9
- lib/rgb.rb
10
- lib/standard_colours.rb
11
-
data/colour.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'lib/colour'
2
- require 'lib/rgb'
3
- require 'lib/cmyk'
4
- require 'lib/hsv'
5
- require 'lib/standard_colours'