colorscheme 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in colorscheme.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Claus Witt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Colorscheme
2
+
3
+ Colorscheme is a gem for creating a colorscheme from a known source - either a website, an image or a (set) of color(s). The gem can be used to generate a set of colors to be used in a websites stylesheet.
4
+
5
+ It will give your options of getting the following types of colorschemes:
6
+
7
+ - Monochromatic
8
+ - Complementary
9
+ - Analogous
10
+ - Triadic
11
+ - Split-Complementary
12
+ - Tetradic
13
+ - Square
14
+
15
+ ### Currently working version:
16
+
17
+ You can only get colors as Color objects (from the Color gem) and you can only get colorschemes from a known color (again, a Color object from the Color gem).
18
+
19
+ The only implemented schemes are: Complementary, Analogous, Triadic, Split-Complementary and Square.
20
+
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'colorscheme'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install colorscheme
35
+
36
+ ## Usage
37
+
38
+ ```
39
+ scheme = Colorscheme::Colorscheme.new(Color.RGB.new(255,0,0))
40
+ scheme.triadic!
41
+ scheme.colors # is an array of three colors
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'colorscheme/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "colorscheme"
8
+ gem.version = Colorscheme::VERSION
9
+ gem.authors = ["Claus Witt"]
10
+ gem.email = ["claus@wittnezz.dk"]
11
+ gem.description = %q{Create colorschemes from known values}
12
+ gem.summary = %q{Given a source - a website, and image or a color - the gem returns a colorscheme}
13
+ gem.homepage = "http://clauswitt.com/gems/colorscheme"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_dependency('color', '~> 1.4.1')
20
+ gem.add_dependency('rmagick', '~> 2.13.1')
21
+ gem.add_development_dependency('rspec')
22
+ end
@@ -0,0 +1,59 @@
1
+ require 'color'
2
+ module Colorscheme
3
+ class Colorscheme
4
+ attr_accessor :colors, :source_color
5
+ def initialize(options={})
6
+ @colors = []
7
+ @source_color = options[:source] if options.has_key?(:source)
8
+ end
9
+
10
+ def complementary!
11
+ @colors = []
12
+ @colors.push(@source_color)
13
+ @colors.push(complementary(@source_color))
14
+ end
15
+
16
+ def rotate_color(source, degrees)
17
+ hsl = source.to_hsl
18
+ h = 360.0 * hsl.h + degrees
19
+ Color::HSL.new(h, hsl.s * 100, hsl.l * 100).to_rgb
20
+ end
21
+
22
+ def complementary(source)
23
+ rotate_color(source, 180)
24
+ end
25
+
26
+ def analogous!(degrees)
27
+ @colors = []
28
+ @colors.push(@source_color)
29
+ @colors.concat analogous(@source_color, degrees)
30
+ end
31
+
32
+ def analogous(source, degrees)
33
+ [rotate_color(source, degrees), rotate_color(source, -degrees)]
34
+ end
35
+
36
+ def split_complementary!(degrees)
37
+ @colors = []
38
+ @colors.push @source_color
39
+ complementary = complementary(@source_color)
40
+ analogous_to_complementary = analogous(complementary, degrees)
41
+ @colors.push complementary
42
+ @colors.concat analogous_to_complementary
43
+ end
44
+
45
+ def triadic!
46
+ @colors = []
47
+ @colors.push @source_color
48
+ @colors.concat analogous(@source_color, 120)
49
+ end
50
+
51
+ def squared!
52
+ @colors = []
53
+ @colors.push @source_color
54
+ @colors.push rotate_color(@source_color, 90)
55
+ @colors.push rotate_color(@source_color, 180)
56
+ @colors.push rotate_color(@source_color, 270)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Colorscheme
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "colorscheme/version"
2
+ require "colorscheme/colorscheme"
3
+ module Colorscheme
4
+ end
@@ -0,0 +1,99 @@
1
+ require 'colorscheme/colorscheme'
2
+
3
+ describe Colorscheme::Colorscheme do
4
+ describe ".new" do
5
+ it "can be instantiated by calling new" do
6
+ Colorscheme::Colorscheme.new
7
+ end
8
+ end
9
+
10
+ describe ".colors" do
11
+ it "has an array of colors" do
12
+ scheme = Colorscheme::Colorscheme.new
13
+ scheme.colors.should be_a_kind_of(Array)
14
+ end
15
+ end
16
+
17
+ describe ".source_color" do
18
+ it "sets the source_color on the object" do
19
+ color = Color::RGB.new(1,2,3)
20
+ scheme = Colorscheme::Colorscheme.new({:source => color})
21
+ scheme.source_color.should equal(color)
22
+ end
23
+ end
24
+
25
+ describe ".complementary" do
26
+ it "gets the complementary color as well as the original" do
27
+ color = Color::RGB.new(255,0,0)
28
+ scheme = Colorscheme::Colorscheme.new({:source => color})
29
+ scheme.complementary!
30
+ scheme.colors.first.should equal(color)
31
+ scheme.colors.last.html.should eq(Color::RGB.new(0,255,255).html)
32
+ end
33
+ end
34
+
35
+ describe ".analogous" do
36
+ it "gets adjacent colors" do
37
+ color = Color::RGB.new(255,0,0)
38
+ adj1 = Color::HSL.new(30,100,50)
39
+ adj2 = Color::HSL.new(-30,100,50)
40
+ scheme = Colorscheme::Colorscheme.new({:source => color})
41
+
42
+ scheme.analogous!(30)
43
+
44
+ scheme.colors.first.should equal(color)
45
+ scheme.colors[1].html.should eq(adj1.html)
46
+ scheme.colors.last.html.should eq(adj2.html)
47
+ end
48
+ end
49
+
50
+ describe ".split_complementary" do
51
+ it "gets the complementary color, and its analogous colors" do
52
+ color = Color::RGB.new(0,255,255)
53
+ complementary = Color::RGB.new(255,0,0)
54
+ adj1 = Color::HSL.new(30,100,50)
55
+ adj2 = Color::HSL.new(-30,100,50)
56
+ scheme = Colorscheme::Colorscheme.new({:source => color})
57
+
58
+ scheme.split_complementary!(30)
59
+
60
+ scheme.colors.first.should equal(color)
61
+ scheme.colors[1].html.should eq(complementary.html)
62
+ scheme.colors[2].html.should eq(adj1.html)
63
+ scheme.colors[3].html.should eq(adj2.html)
64
+
65
+ end
66
+ end
67
+
68
+ describe ".triadic" do
69
+ it "gets triadic colors for source" do
70
+ color = Color::RGB.new(255,0,0)
71
+ triadic1 = Color::RGB.new(0,255,0)
72
+ triadic2 = Color::RGB.new(0,0,255)
73
+ scheme = Colorscheme::Colorscheme.new({:source => color})
74
+
75
+ scheme.triadic!
76
+
77
+ scheme.colors.first.should equal(color)
78
+ scheme.colors[1].html.should eq(triadic1.html)
79
+ scheme.colors[2].html.should eq(triadic2.html)
80
+ end
81
+ end
82
+
83
+ describe ".squared" do
84
+ it "gets equally spaced colors for source" do
85
+ color = Color::RGB.new(255,0,0)
86
+ quad1 = Color::HSL.new(90, 100, 50)
87
+ quad2 = Color::HSL.new(180, 100, 50)
88
+ quad3 = Color::HSL.new(270, 100, 50)
89
+ scheme = Colorscheme::Colorscheme.new({:source => color})
90
+
91
+ scheme.squared!
92
+
93
+ scheme.colors.first.should equal(color)
94
+ scheme.colors[1].html.should eq(quad1.html)
95
+ scheme.colors[2].html.should eq(quad2.html)
96
+ scheme.colors[3].html.should eq(quad3.html)
97
+ end
98
+ end
99
+ end
File without changes
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorscheme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Claus Witt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: color
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: rmagick
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.13.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.13.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Create colorschemes from known values
63
+ email:
64
+ - claus@wittnezz.dk
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - colorscheme.gemspec
76
+ - lib/colorscheme.rb
77
+ - lib/colorscheme/colorscheme.rb
78
+ - lib/colorscheme/version.rb
79
+ - spec/lib/colorscheme/colorscheme_spec.rb
80
+ - spec/spec_helper.rb
81
+ homepage: http://clauswitt.com/gems/colorscheme
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.24
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Given a source - a website, and image or a color - the gem returns a colorscheme
105
+ test_files:
106
+ - spec/lib/colorscheme/colorscheme_spec.rb
107
+ - spec/spec_helper.rb