rcade_colors 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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/lib/rcade_colors.rb +32 -0
- data/rcade_colors.gemspec +23 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5515fab6c047adebf5d34e7d0a1df76a1a23b02f
|
4
|
+
data.tar.gz: e53d78c45cd9e8b127ebaf10684b19dbd211cce6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42eae60bcc4f2f3be767e2033c8d7e4a33a53062cdaff05eb511ce440c5838b6cbea4a437a4d024e00a0dab4eedb7e7abe8294e445cc1ba7e8f722948a3b09b9
|
7
|
+
data.tar.gz: b01022fb1f1ea3ed44c812e4a1f5a40b8df69d6db028d5e9c07c3d374d9d813a70ec070d98b35450e338472fc2ca2a35d1af9fc6432cfdf81147c0dfd4ddc1f2
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p195
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andrew Havens
|
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,49 @@
|
|
1
|
+
# Rcade Colors
|
2
|
+
|
3
|
+
Provides additional CSS Hex value and opacity support for Gosu.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rcade_colors'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rcade_colors
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### CSS Hex values
|
22
|
+
|
23
|
+
Using this gem, you can create a Gosu::Color object using CSS hex values:
|
24
|
+
|
25
|
+
Rcade::Color.from_css('#ff0')
|
26
|
+
|
27
|
+
### CSS color names
|
28
|
+
|
29
|
+
If you would like to create a Gosu::Color from a CSS color name, you can!
|
30
|
+
|
31
|
+
Rcade::Color.named('DarkSlateBlue')
|
32
|
+
|
33
|
+
See [full list of supported color names](https://github.com/halostatue/color/blob/master/lib/color/rgb-colors.rb).
|
34
|
+
|
35
|
+
### Opacity
|
36
|
+
|
37
|
+
You can also modify the opacity of a color before using it:
|
38
|
+
|
39
|
+
color = Rcade::Color::RED.opacity(0.5)
|
40
|
+
|
41
|
+
And that's it. If you want any other features, submit an issue, or send a pull request.
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rcade_colors.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
require 'color'
|
3
|
+
|
4
|
+
module Rcade
|
5
|
+
class Color < Gosu::Color
|
6
|
+
|
7
|
+
# hex argument should be a string and can be the full 6 digit hex
|
8
|
+
# or 3 digit shorthand and may include a # prefix.
|
9
|
+
# Examples:
|
10
|
+
# "fed"
|
11
|
+
# "#fed"
|
12
|
+
# "cabbed"
|
13
|
+
# "#cabbed"
|
14
|
+
def self.from_hex(hex)
|
15
|
+
color = Color::RGB.from_html(hex).to_hsl
|
16
|
+
Gosu::Color.from_hsv(color.hue.to_i, color.s, color.l) # 255, 1.0, 1.0
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.named(color_name)
|
20
|
+
color = Color::CSS[color_name]
|
21
|
+
raise 'Invalid color name' unless color
|
22
|
+
self.from_hex(color.html)
|
23
|
+
end
|
24
|
+
|
25
|
+
# opacity should be a float 0.0..1.0
|
26
|
+
def opacity(opacity)
|
27
|
+
a = alpha * opacity
|
28
|
+
Gosu::Color.from_ahsv(a, hue, saturation, value)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "rcade_colors"
|
5
|
+
spec.version = "0.0.1"
|
6
|
+
spec.authors = ["Andrew Havens"]
|
7
|
+
spec.email = ["email@andrewhavens.com"]
|
8
|
+
spec.description = %q{Provides additional CSS Hex value and opacity support for Gosu.}
|
9
|
+
spec.summary = %q{Provides additional CSS Hex value and opacity support for Gosu.}
|
10
|
+
spec.homepage = "https://github.com/ruby-rcade/rcade_colors"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_dependency "gosu"
|
19
|
+
spec.add_dependency "color"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcade_colors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Havens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gosu
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: color
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Provides additional CSS Hex value and opacity support for Gosu.
|
70
|
+
email:
|
71
|
+
- email@andrewhavens.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .ruby-version
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/rcade_colors.rb
|
83
|
+
- rcade_colors.gemspec
|
84
|
+
homepage: https://github.com/ruby-rcade/rcade_colors
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.0.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Provides additional CSS Hex value and opacity support for Gosu.
|
108
|
+
test_files: []
|