color-hacker 1.0.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,59 @@
1
+ # What is this?
2
+
3
+ Color Hacker is a handy little utility for helping you crack your color schemes using Sass color functions.
4
+ Simply pass the `hack-colors` function a list of colors and it will return a set of color functions that show
5
+ how all of the colors in the color scheme can be derived from the first color.
6
+
7
+ ## Example
8
+
9
+ ``` scss
10
+ @debug(hack-colors(#cff09e #a8dba8 #79bd9a #3b8686 #0b486b));
11
+ ```
12
+
13
+ Output:
14
+
15
+ ``` scss
16
+ $key: #cff09e;
17
+ $color-2: scale-color(adjust-hue($key, 36deg), $saturation: -43.367%, $lightness: -2.764%);
18
+ $color-3: scale-color(adjust-hue($key, 65deg), $saturation: -53.561%, $lightness: -22.111%);
19
+ $color-4: scale-color(adjust-hue($key, 96deg), $saturation: -46.923%, $lightness: -51.508%);
20
+ $color-5: scale-color(adjust-hue($key, 118deg), $saturation: 30.395%, $lightness: -70.352%);
21
+ ```
22
+
23
+
24
+ ## Setup
25
+
26
+ Install the plugin:
27
+
28
+ ``` sh
29
+ gem install color-hacker
30
+ ```
31
+
32
+ Add Color Hacker to your compass configuration file:
33
+
34
+ ``` rb
35
+ require 'color-hacker'
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ `hack-colors` accepts two variables.
41
+
42
+ 1. A space separated list of colors, e.g. (#fab #00face)
43
+ 2. Optional: A function type, scale or adjust. Defaults to scale.
44
+
45
+ ``` scss
46
+ // Debug passes output to the terminal
47
+ @debug(hack-colors(#beaf0c #deac0b));
48
+
49
+ // Return adjust-color functions
50
+ @debug(hack-colors(#beaf0c #deac0b, scale));
51
+
52
+ ```
53
+
54
+ ## License
55
+ Copyright (c) 2008-2009 Brandon Mathis<br>
56
+ All Rights Reserved.<br>
57
+ Released under a [slightly modified MIT License][license].
58
+
59
+ [license]: http://github.com/imathis/color-hacker/tree/master/LICENSE.markdown
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 0
4
+ :patch: 0
@@ -0,0 +1,7 @@
1
+ #require 'compass'
2
+
3
+ base_directory = File.join(File.dirname(__FILE__), '..')
4
+ stylesheets_dir = File.join(base_directory, 'stylesheets')
5
+ templates_dir = File.join(base_directory, 'templates')
6
+
7
+ Compass::Frameworks.register('color-hacker', :stylesheets_directory => stylesheets_dir, :templates_directory => templates_dir)
@@ -0,0 +1,59 @@
1
+ module ColorHacker
2
+ module Version
3
+ # Returns a hash representing the version.
4
+ # The :major, :minor, and :teeny keys have their respective numbers.
5
+ # The :string key contains a human-readable string representation of the version.
6
+ # The :rev key will have the current revision hash.
7
+ #
8
+ # This method swiped from Compass by Chris Eppstein who swiped it from Haml and then modified it, so some credit goes to Nathan Weizenbaum too.
9
+ def version
10
+ if defined?(@version)
11
+ @version
12
+ else
13
+ read_version
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ def scope(file) # :nodoc:
20
+ File.join(File.dirname(__FILE__), '..', file)
21
+ end
22
+
23
+ def read_version
24
+ require 'yaml'
25
+ @version = YAML::load(File.read(scope('VERSION.yml')))
26
+ @version[:teeny] = @version[:patch]
27
+ @version[:string] = "#{@version[:major]}.#{@version[:minor]}"
28
+ @version[:string] << ".#{@version[:patch]}" if @version[:patch]
29
+ @version[:string] << ".#{@version[:state]}" if @version[:state]
30
+ @version[:string] << ".#{@version[:build]}" if @version[:build]
31
+ #if !ENV['OFFICIAL'] && r = revision
32
+ # @version[:string] << ".#{r[0..6]}"
33
+ #end
34
+ @version
35
+ end
36
+
37
+ def revision
38
+ revision_from_git
39
+ end
40
+
41
+ def revision_from_git
42
+ if File.exists?(scope('.git/HEAD'))
43
+ rev = File.read(scope('.git/HEAD')).strip
44
+ if rev =~ /^ref: (.*)$/
45
+ rev = File.read(scope(".git/#{$1}")).strip
46
+ end
47
+ end
48
+ end
49
+ end
50
+ extend ColorHacker::Version
51
+ def self.const_missing(const)
52
+ # This avoid reading from disk unless the VERSION is requested.
53
+ if const == :VERSION
54
+ version[:string]
55
+ else
56
+ super
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,35 @@
1
+ @function scale-to-adjust($start, $change) {
2
+ @if($change > 0) {
3
+ $end: $start + $change;
4
+ @return percentage(($end - $start)/(100 - $start));
5
+ } @else {
6
+ @return percentage($change / $start);
7
+ }
8
+ }
9
+
10
+ @function scale-key($key, $color) {
11
+ $h: hue($color) - hue($key);
12
+ $s: saturation($color) - saturation($key);
13
+ $l: lightness($color) - lightness($key);
14
+ @return "scale-color(adjust-hue($key, #{$h}), $saturation: #{scale-to-adjust(saturation($key), $s)}, $lightness: #{scale-to-adjust(lightness($key), $l)}); ";
15
+ }
16
+
17
+ @function adjust-key($key, $color) {
18
+ $h: hue($color) - hue($key);
19
+ $s: saturation($color) - saturation($key);
20
+ $l: lightness($color) - lightness($key);
21
+ @return "adjust-color($key, $hue: #{$h}, $saturation: #{$s}, $lightness: #{$l}); ";
22
+ }
23
+
24
+ @function hack-colors($colors, $method: scale){
25
+ $key: nth($colors, 1);
26
+ $hack: "$key: #{$key}; ";
27
+ @for $i from 2 through length($colors) {
28
+ @if $method == scale {
29
+ $hack: $hack + "$color-#{$i}: #{scale-key($key, nth($colors, $i))}";
30
+ } @else {
31
+ $hack: $hack + "$color-#{$i}: #{adjust-key($key, nth($colors, $i))}";
32
+ }
33
+ }
34
+ @return $hack;
35
+ }
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: color-hacker
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Brandon Mathis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-05 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: compass
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0.11"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: Color Hacker is a Compass plugin which uses Sass color functions to find find the relationships between colors
28
+ email: brandon@imathis.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - README.markdown
37
+ - VERSION.yml
38
+ - lib/color-hacker.rb
39
+ - lib/version.rb
40
+ - stylesheets/_color-hacker.scss
41
+ has_rdoc: true
42
+ homepage: http://github.com/imathis/color-hacker
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.6.2
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Converts a list of colors into a set of dependant color functions
69
+ test_files: []
70
+