chroma-js 0.1.0 → 0.1.2

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: 2c0076bcd8f1e85c74208b5efcd1def0d159b6a1
4
- data.tar.gz: 2ea4087e646867f200ccd99412aba75a93b8a330
3
+ metadata.gz: aad0d7b80041df379b01d952e35860e31553928d
4
+ data.tar.gz: 3b8ab27b7dc40245a45301ee68663f51c47aed93
5
5
  SHA512:
6
- metadata.gz: e76bb76b7e6afbde0d7d7f0c13ecfbb6d820bf7ee2ffef979ce2f693092beab9dae2c10efb289f824dd428159d2dc8435bf62570511d7cd0e1a651110eb2723d
7
- data.tar.gz: af6a945a7643d091c66808d499c5337b95108d93ceca332d43a7f754ec3c60e1d9f41a49beb5515bd11863a8d18c1bf98bf1821cb220d14873c98736b8186f8b
6
+ metadata.gz: b420377686e2bb043b43f1b0eec809bbee1d7accd942f5e9ff0c6719c2a93188d08390427cc40f7d6e5e432bcbb2546d444468a27aa8c4c199bc59a1b0f77167
7
+ data.tar.gz: 76739f4f5b382a3e7ffafeafe8576e307427409c91b6111adb7f4e80c368c85922bc0e2697dbffe8987cceac65c8a8ae9747e1802e7acc278eed6dfa547f4106
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ bin/
@@ -0,0 +1,86 @@
1
+ # Contributing to bootstrap-sass
2
+
3
+ ## Asset Changes
4
+
5
+ Any changes to `bootstrap-sass` assets (scss, javascripts, fonts) should be checked against the `convert` rake task.
6
+ For usage instructions, see the [README](/README.md).
7
+
8
+ If something is broken in the converter, it's preferable to update the converter along with the asset itself.
9
+
10
+
11
+ ## Bugs
12
+
13
+ A bug is a _demonstrable problem_ that is caused by the code in the
14
+ repository. Good bug reports are extremely helpful - thank you!
15
+
16
+ Guidelines for bug reports:
17
+
18
+ 1. **Does it belong here?** — is this a problem with bootstrap-sass, or
19
+ it an issue with [twbs/bootstrap](https://github.com/twbs/bootstrap)?
20
+ We only distribute a direct port and will not modify files if they're not
21
+ changed upstream.
22
+
23
+ 2. **Use the GitHub issue search** — check if the issue has already been
24
+ reported.
25
+
26
+ 3. **Isolate the problem** — ideally create a [reduced test
27
+ case](http://css-tricks.com/6263-reduced-test-cases/) and a live example.
28
+
29
+ A good bug report shouldn't leave others needing to chase you up for more
30
+ information. Please try to be as detailed as possible in your report. What is
31
+ your environment? What steps will reproduce the issue? What browser(s) and OS
32
+ experience the problem? What would you expect to be the outcome? All these
33
+ details will help people to fix any potential bugs.
34
+
35
+ Example:
36
+
37
+ > Short and descriptive example bug report title
38
+ >
39
+ > A summary of the issue and the browser/OS environment in which it occurs. If
40
+ > suitable, include the steps required to reproduce the bug.
41
+ >
42
+ > 1. This is the first step
43
+ > 2. This is the second step
44
+ > 3. Further steps, etc.
45
+ >
46
+ > `<url>` (a link to the reduced test case)
47
+ >
48
+ > Any other information you want to share that is relevant to the issue being
49
+ > reported. This might include the lines of code that you have identified as
50
+ > causing the bug, and potential solutions (and your opinions on their
51
+ > merits).
52
+
53
+ **[File a bug report](https://github.com/twbs/bootstrap-sass/issues/)**
54
+
55
+
56
+ ## Pull requests
57
+
58
+ **We will not accept pull requests that modify the SCSS beyond fixing bugs caused by *our* code!**
59
+
60
+ We use a [converter script][converter-readme] to automatically convert upstream bootstrap, written in LESS, to Sass.
61
+
62
+ Issues related to styles or javascript but unrelated to the conversion process should go to [twbs/bootstrap][upstream].
63
+
64
+ Pull requests that fix bugs caused by our code should not modify the SCSS directly, but should patch the converter instead.
65
+
66
+ Good pull requests - patches, improvements, new features - are a fantastic
67
+ help. They should remain focused in scope and avoid containing unrelated
68
+ commits. If your contribution involves a significant amount of work or substantial
69
+ changes to any part of the project, please open an issue to discuss it first.
70
+
71
+ Make sure to adhere to the coding conventions used throughout a project
72
+ (indentation, accurate comments, etc.). Please update any documentation that is
73
+ relevant to the change you're making.
74
+
75
+ ## Do not…
76
+
77
+ Please **do not** use the issue tracker for personal support requests (use
78
+ [Stack Overflow](http://stackoverflow.com/)).
79
+
80
+ Please **do not** derail or troll issues. Keep the
81
+ discussion on topic and respect the opinions of others.
82
+
83
+ *props [html5-boilerplate](https://github.com/h5bp/html5-boilerplate/blob/master/CONTRIBUTING.md)*
84
+
85
+ [upstream]: https://github.com/twbs/bootstrap
86
+ [converter-readme]: https://github.com/twbs/bootstrap-sass/blob/master/README.md#upstream-converter
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org/'
2
2
 
3
3
  gemspec
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "chroma-js",
3
+ "version": "0.1.2",
4
+ "homepage": "https://github.com/schivei/chroma.js-rails",
5
+ "authors": [
6
+ "Elton Schivei Costa"
7
+ ],
8
+ "description": "This Gem is made to support the use of Chroma.js library with Rails Assets",
9
+ "main": [
10
+ "assets/javascripts/chroma.js"
11
+ ],
12
+ "keywords": [
13
+ "chroma-js",
14
+ "chroma.js",
15
+ "chroma",
16
+ "color",
17
+ "javascript"
18
+ ],
19
+ "license": "MIT",
20
+ "ignore": [
21
+ "**/.*",
22
+ "lib",
23
+ "templates",
24
+ "*.gemspec",
25
+ "Rakefile",
26
+ "Gemfile"
27
+ ]
28
+ }
@@ -1,25 +1,29 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'chroma.js/rails/version'
4
+ require 'chroma-js/version'
5
5
 
6
- Gem::Specification.new do |spec|
7
- spec.name = "chroma-js"
8
- spec.version = ChromaJS::Rails::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ["Elton Schivei Costa"]
11
- spec.email = ["costa@elton.schivei.nom.br"]
12
- spec.summary = "A Gem for Chroma.js library"
13
- spec.description = "This Gem is made to support the use of Chroma.js library with Rails Assets"
14
- spec.homepage = "https://github.com/schivei/chroma.js-rails"
15
- spec.license = "MIT"
6
+ Gem::Specification.new do |s|
7
+ s.name = "chroma-js"
8
+ s.version = Chroma::VERSION
9
+ s.authors = ["Elton Schivei Costa"]
10
+ s.email = ["costa@elton.schivei.nom.br"]
11
+ s.summary = "A Gem for Chroma.js library"
12
+ s.description = "This Gem is made to support the use of Chroma.js library with Rails Assets"
13
+ s.homepage = "https://github.com/schivei/chroma.js-rails"
14
+ s.license = "MIT"
16
15
 
17
- spec.required_rubygems_version = ">= 1.3.6"
18
- spec.rubyforge_project = "chroma-js"
16
+ s.add_runtime_dependency 'autoprefixer-rails', '~> 5.0'
17
+ s.add_development_dependency 'actionpack', '~> 4.1'
18
+ s.add_development_dependency 'activesupport', '~> 4.1'
19
+ s.add_development_dependency 'json', '~> 1.8'
20
+ s.add_development_dependency 'sprockets-rails', '~> 2.1'
21
+ s.add_development_dependency 'slim-rails', '~> 0'
22
+ s.add_development_dependency 'uglifier', '~> 0'
23
+ # Converter
24
+ s.add_development_dependency 'term-ansicolor', '~> 0'
19
25
 
20
- spec.add_dependency "railties", ">= 3.1"
21
- spec.add_development_dependency "rails", ">= 3.1"
26
+ s.rubyforge_project = "chroma-js"
22
27
 
23
- spec.files = `git ls-files`.split("\n")
24
- spec.require_path = "lib"
28
+ s.files = `git ls-files`.split("\n")
25
29
  end
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "schivei/chroma-js",
3
+ "version": "0.1.2",
4
+ "description": "This Gem is made to support the use of Chroma.js library with Rails Assets",
5
+ "keywords": [
6
+ "chroma-js",
7
+ "chroma.js",
8
+ "chroma",
9
+ "color",
10
+ "javascript"
11
+ ],
12
+ "homepage": "https://github.com/schivei/chroma.js-rails",
13
+ "authors": [
14
+ {
15
+ "name": "Elton Schivei Costa",
16
+ "email": "costa@elton.schivei.nom.br"
17
+ }
18
+ ],
19
+ "support": {
20
+ "issues": "https://github.com/schivei/chroma.js-rails/issues"
21
+ },
22
+ "license": "MIT",
23
+ "extra": {
24
+ "branch-alias": {
25
+ "dev-master": "0.1.x-dev"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,47 @@
1
+ require 'chroma-js/version'
2
+ module Chroma
3
+ class << self
4
+ # Based on bootstrap-sass
5
+ def load!
6
+ if rails?
7
+ register_rails_engine
8
+ elsif sprockets?
9
+ register_sprockets
10
+ end
11
+ end
12
+
13
+ # Paths
14
+ def gem_path
15
+ @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
16
+ end
17
+
18
+ def javascripts_path
19
+ File.join assets_path, 'javascripts'
20
+ end
21
+
22
+ def assets_path
23
+ @assets_path ||= File.join gem_path, 'assets'
24
+ end
25
+
26
+ # Environment detection helpers
27
+ def sprockets?
28
+ defined?(::Sprockets)
29
+ end
30
+
31
+ def rails?
32
+ defined?(::Rails)
33
+ end
34
+
35
+ private
36
+
37
+ def register_rails_engine
38
+ require 'chroma-js/engine'
39
+ end
40
+
41
+ def register_sprockets
42
+ Sprockets.append_path(javascripts_path)
43
+ end
44
+ end
45
+ end
46
+
47
+ Chroma.load!
@@ -0,0 +1,11 @@
1
+ module Chroma
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer 'chroma-js.assets.precompile' do |app|
5
+ %w(javascripts).each do |sub|
6
+ app.config.assets.paths << root.join('assets', sub).to_s
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module Chroma
2
+ VERSION = '0.1.2'
3
+ CHROMA_SHA = '65c0852b050b58147cff5de5157f061bdabf2bc4'
4
+ end
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "chroma-js",
3
+ "version": "0.1.2",
4
+ "homepage": "https://github.com/schivei/chroma.js-rails",
5
+ "main": "assets/javascripts/chroma.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git://github.com/schivei/chroma.js-rails"
9
+ },
10
+ "keywords": [
11
+ "chroma-js",
12
+ "chroma.js",
13
+ "chroma",
14
+ "color",
15
+ "javascript"
16
+ ],
17
+ "contributors": [
18
+ "Elton Schivei Costa"
19
+ ],
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/schivei/chroma.js-rails/issues"
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "chrome-js",
3
+ "description": "This Gem is made to support the use of Chroma.js library with Rails Assets",
4
+ "tags": [
5
+ "chroma-js",
6
+ "chroma.js",
7
+ "chroma",
8
+ "color",
9
+ "javascript"
10
+ ]
11
+ }
@@ -0,0 +1,28 @@
1
+ require 'find'
2
+ require 'json'
3
+ require 'pathname'
4
+
5
+ namespace :bower do
6
+
7
+ find_files = ->(path) {
8
+ Find.find(Pathname.new(path).relative_path_from(Pathname.new Dir.pwd).to_s).map do |path|
9
+ path if File.file?(path)
10
+ end.compact
11
+ }
12
+
13
+ desc 'update main and version in bower.json'
14
+ task :generate do
15
+ require 'bootstrap-sass'
16
+ Dir.chdir Bootstrap.gem_path do
17
+ spec = JSON.parse(File.read 'bower.json')
18
+
19
+ spec['main'] = %w(assets/javascripts/chroma.js)
20
+
21
+ spec['version'] = Chroma::VERSION
22
+
23
+ File.open('bower.json', 'w') do |f|
24
+ f.puts JSON.pretty_generate(spec)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,74 @@
1
+ # coding: utf-8
2
+ # Based on convert script from vwall/compass-twitter-bootstrap gem.
3
+ # https://github.com/vwall/compass-twitter-bootstrap/blob/master/build/convert.rb
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this work except in compliance with the License.
7
+ # You may obtain a copy of the License in the LICENSE file, or at:
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'open-uri'
18
+ require 'json'
19
+ require 'strscan'
20
+ require 'forwardable'
21
+ require 'term/ansicolor'
22
+ require 'fileutils'
23
+
24
+ require_relative 'converter/js_conversion'
25
+ require_relative 'converter/logger'
26
+ require_relative 'converter/network'
27
+
28
+ class Converter
29
+ extend Forwardable
30
+ include Network
31
+ include LessConversion
32
+ include JsConversion
33
+ include FontsConversion
34
+
35
+ def initialize(repo: 'gka/chroma.js', branch: 'master', save_to: {}, cache_path: 'tmp/converter-cache-chroma')
36
+ @logger = Logger.new
37
+ @repo = repo
38
+ @branch = branch || 'master'
39
+ @branch_sha = get_branch_sha
40
+ @cache_path = cache_path
41
+ @repo_url = "https://github.com/#@repo"
42
+ @save_to = {
43
+ js: 'assets/javascripts/chroma'}.merge(save_to)
44
+ end
45
+
46
+ def_delegators :@logger, :log, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
47
+
48
+ def process_chroma
49
+ log_status "Convert Chroma LESS to Sass"
50
+ puts " repo : #@repo_url"
51
+ puts " branch : #@branch_sha #@repo_url/tree/#@branch"
52
+ puts " save to: #{@save_to.to_json}"
53
+ puts " twbs cache: #{@cache_path}"
54
+ puts '-' * 60
55
+
56
+ @save_to.each { |_, v| FileUtils.mkdir_p(v) }
57
+
58
+ process_javascript_assets
59
+ store_version
60
+ end
61
+
62
+ def save_file(path, content, mode='w')
63
+ dir = File.dirname(path)
64
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
65
+ File.open(path, mode) { |file| file.write(content) }
66
+ end
67
+
68
+ # Update version.rb file with CHROMA_SHA
69
+ def store_version
70
+ path = 'lib/chroma-js/version.rb'
71
+ content = File.read(path).sub(/CHROMA_SHA\s*=\s*['"][\w]+['"]/, "CHROMA_SHA = '#@branch_sha'")
72
+ File.open(path, 'w') { |f| f.write(content) }
73
+ end
74
+ end
@@ -0,0 +1,38 @@
1
+ # regular string scanner works with bytes
2
+ # this one works with chars and provides #scan_next
3
+ class Converter
4
+ class CharStringScanner
5
+ extend Forwardable
6
+
7
+ def initialize(*args)
8
+ @s = StringScanner.new(*args)
9
+ end
10
+
11
+ def_delegators :@s, :scan_until, :skip_until, :string
12
+
13
+ # advance scanner to pos after the next match of pattern and return the match
14
+ def scan_next(pattern)
15
+ return unless @s.scan_until(pattern)
16
+ @s.matched
17
+ end
18
+
19
+ def pos
20
+ byte_to_str_pos @s.pos
21
+ end
22
+
23
+ def pos=(i)
24
+ @s.pos = str_to_byte_pos i
25
+ i
26
+ end
27
+
28
+ private
29
+
30
+ def byte_to_str_pos(pos)
31
+ @s.string.byteslice(0, pos).length
32
+ end
33
+
34
+ def str_to_byte_pos(pos)
35
+ @s.string.slice(0, pos).bytesize
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ class Converter
2
+ module JsConversion
3
+ def process_javascript_assets
4
+ log_status 'Processing javascripts...'
5
+ save_to = @save_to[:js]
6
+ contents = {}
7
+ read_files('js', chroma_js_files).each do |name, file|
8
+ contents[name] = file
9
+ save_file("#{save_to}/#{name}", file)
10
+ end
11
+ log_processed "#{chroma_js_files * ' '}"
12
+
13
+ log_status 'Updating javascript manifest'
14
+ manifest = ''
15
+ chroma_js_files.each do |name|
16
+ name = name.gsub(/\.js$/, '')
17
+ manifest << "//= require ./chroma/#{name}\n"
18
+ end
19
+ dist_js = read_files('dist/js', %w(chroma.js chroma.min.js))
20
+ {
21
+ 'assets/javascripts/chroma.js' => dist_js['chroma.js'],
22
+ 'assets/javascripts/chroma.min.js' => dist_js['chroma.min.js'],
23
+ }.each do |path, content|
24
+ save_file path, content
25
+ log_processed path
26
+ end
27
+ end
28
+
29
+ def chroma_js_files
30
+ @chroma_js_files ||= begin
31
+ files = get_paths_by_type('js', /\.js$/).reject { |path| path =~ %r(^tests/) }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,57 @@
1
+ class Converter
2
+ class Logger
3
+ include Term::ANSIColor
4
+
5
+ def log_status(status)
6
+ puts bold status
7
+ end
8
+
9
+ def log_file_info(s)
10
+ puts " #{magenta s}"
11
+ end
12
+
13
+ def log_transform(*args, from: caller[1][/`.*'/][1..-2].sub(/^block in /, ''))
14
+ puts " #{cyan from}#{cyan ": #{args * ', '}" unless args.empty?}"
15
+ end
16
+
17
+ def log_processing(name)
18
+ puts yellow " #{File.basename(name)}"
19
+ end
20
+
21
+ def log_processed(name)
22
+ puts green " #{name}"
23
+ end
24
+
25
+ def log_http_get_file(url, cached = false)
26
+ s = " #{'CACHED ' if cached}GET #{url}..."
27
+ if cached
28
+ puts dark green s
29
+ else
30
+ puts dark cyan s
31
+ end
32
+ end
33
+
34
+ def log_http_get_files(files, from, cached = false)
35
+ return if files.empty?
36
+ s = " #{'CACHED ' if cached}GET #{files.length} files from #{from} #{files * ' '}..."
37
+ if cached
38
+ puts dark green s
39
+ else
40
+ puts dark cyan s
41
+ end
42
+ end
43
+
44
+ def puts(*args)
45
+ STDERR.puts *args unless @silence
46
+ end
47
+
48
+ alias log puts
49
+
50
+ def silence_log
51
+ @silence = true
52
+ yield
53
+ ensure
54
+ @silence = false
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,97 @@
1
+ require 'shellwords'
2
+ class Converter
3
+ module Network
4
+ protected
5
+
6
+ def get_paths_by_type(dir, file_re, recursive = true)
7
+ get_file_paths(dir, recursive).select { |path| path =~ file_re }
8
+ end
9
+
10
+ def get_file_paths(dir, recursive = true)
11
+ get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
12
+ end
13
+
14
+ def read_files(path, files)
15
+ full_path = "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
16
+ contents = read_cached_files(path, files)
17
+ log_http_get_files contents.keys, full_path, true if contents.keys
18
+ files -= contents.keys
19
+ log_http_get_files files, full_path, false
20
+ files.map do |name|
21
+ Thread.start {
22
+ contents[name] = open("#{full_path}/#{name}").read
23
+ Thread.exclusive { write_cached_files path, name => contents[name] }
24
+ }
25
+ end.each(&:join)
26
+ contents
27
+ end
28
+
29
+ def read_cached_files(path, files)
30
+ full_path = "#@cache_path/#@branch_sha/#{path}"
31
+ contents = {}
32
+ if File.directory?(full_path)
33
+ files.each do |name|
34
+ path = "#{full_path}/#{name}"
35
+ contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
36
+ end
37
+ end
38
+ contents
39
+ end
40
+
41
+ def write_cached_files(path, files)
42
+ full_path = "./#@cache_path/#@branch_sha/#{path}"
43
+ files.each do |name, content|
44
+ FileUtils.mkdir_p File.dirname(File.join(full_path, name))
45
+ File.open("#{full_path}/#{name}", 'wb') { |f| f.write content }
46
+ end
47
+ end
48
+
49
+
50
+ def get_file(url)
51
+ uri = URI(url)
52
+ cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
53
+ FileUtils.mkdir_p File.dirname(cache_path)
54
+ if File.exists?(cache_path)
55
+ log_http_get_file url, true
56
+ File.read(cache_path, mode: 'rb')
57
+ else
58
+ log_http_get_file url, false
59
+ content = open(url).read
60
+ File.open(cache_path, 'wb') { |f| f.write content }
61
+ content
62
+ end
63
+ end
64
+
65
+ # get sha of the branch (= the latest commit)
66
+ def get_branch_sha
67
+ @branch_sha ||= begin
68
+ if @branch + "\n" == %x[git rev-parse #@branch]
69
+ @branch
70
+ else
71
+ cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"
72
+ log cmd
73
+ result = %x[#{cmd}]
74
+ raise 'Could not get branch sha!' unless $?.success? && !result.empty?
75
+ result.split(/\s+/).first
76
+ end
77
+ end
78
+ end
79
+
80
+ # Get the sha of a dir
81
+ def get_tree_sha(dir, tree = get_trees)
82
+ tree['tree'].find { |t| t['path'] == dir }['sha']
83
+ end
84
+
85
+ def get_trees
86
+ @trees ||= get_tree(@branch_sha)
87
+ end
88
+
89
+ def get_tree(sha, recursive = true)
90
+ get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
91
+ end
92
+
93
+ def get_json(url)
94
+ JSON.parse get_file(url)
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,12 @@
1
+ description 'Chroma JS'
2
+
3
+ # Copy JS
4
+ manifest = Pathname.new(File.dirname(__FILE__))
5
+ assets = File.expand_path('../../assets', manifest)
6
+ {:javascript => 'javascripts' }.each do |method, dir|
7
+ root = Pathname.new(assets).join(dir)
8
+ Dir.glob root.join('**', '*.*') do |path|
9
+ path = Pathname.new(path)
10
+ send method, path.relative_path_from(manifest).to_s, :to => path.relative_path_from(root).to_s
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chroma-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elton Schivei Costa
@@ -11,33 +11,117 @@ cert_chain: []
11
11
  date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: autoprefixer-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rails
28
+ name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: '4.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
40
+ version: '4.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sprockets-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: slim-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: uglifier
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: term-ansicolor
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
41
125
  description: This Gem is made to support the use of Chroma.js library with Rails Assets
42
126
  email:
43
127
  - costa@elton.schivei.nom.br
@@ -45,19 +129,28 @@ executables: []
45
129
  extensions: []
46
130
  extra_rdoc_files: []
47
131
  files:
48
- - .gitignore
132
+ - ".gitignore"
133
+ - CONTRIBUTING.md
49
134
  - Gemfile
50
135
  - LICENSE.txt
51
136
  - README.md
52
137
  - Rakefile
53
- - app/assets/javascripts/LICENSE
54
- - app/assets/javascripts/LICENSE-colors
55
- - app/assets/javascripts/chroma.js
56
- - app/assets/javascripts/chroma.min.js
57
- - app/assets/javascripts/readme.md
138
+ - assets/javascripts/chroma.js
139
+ - bower.json
58
140
  - chroma.js-rails.gemspec
59
- - lib/chroma.js/rails.rb
60
- - lib/chroma.js/rails/version.rb
141
+ - composer.json
142
+ - lib/chroma-js.rb
143
+ - lib/chroma-js/engine.rb
144
+ - lib/chroma-js/version.rb
145
+ - package.json
146
+ - sache.json
147
+ - tasks/bower.rake
148
+ - tasks/converter.rb
149
+ - tasks/converter/char_string_scanner.rb
150
+ - tasks/converter/js_conversion.rb
151
+ - tasks/converter/logger.rb
152
+ - tasks/converter/network.rb
153
+ - templates/project/manifest.rb
61
154
  homepage: https://github.com/schivei/chroma.js-rails
62
155
  licenses:
63
156
  - MIT
@@ -68,18 +161,19 @@ require_paths:
68
161
  - lib
69
162
  required_ruby_version: !ruby/object:Gem::Requirement
70
163
  requirements:
71
- - - '>='
164
+ - - ">="
72
165
  - !ruby/object:Gem::Version
73
166
  version: '0'
74
167
  required_rubygems_version: !ruby/object:Gem::Requirement
75
168
  requirements:
76
- - - '>='
169
+ - - ">="
77
170
  - !ruby/object:Gem::Version
78
- version: 1.3.6
171
+ version: '0'
79
172
  requirements: []
80
173
  rubyforge_project: chroma-js
81
- rubygems_version: 2.0.14
174
+ rubygems_version: 2.2.2
82
175
  signing_key:
83
176
  specification_version: 4
84
177
  summary: A Gem for Chroma.js library
85
178
  test_files: []
179
+ has_rdoc:
@@ -1,28 +0,0 @@
1
- chroma.js - JavaScript library for color conversions
2
-
3
- Copyright (c) 2011-2013, Gregor Aisch
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- 1. Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- 2. Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- 3. The name Gregor Aisch may not be used to endorse or promote products
17
- derived from this software without specific prior written permission.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,22 +0,0 @@
1
-
2
- chroma.js includes colors from colorbrewer2.org,
3
- which are released under the following license:
4
-
5
-
6
- Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
7
- and The Pennsylvania State University.
8
-
9
- Licensed under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License.
11
- You may obtain a copy of the License at
12
- http://www.apache.org/licenses/LICENSE-2.0
13
-
14
- Unless required by applicable law or agreed to in writing,
15
- software distributed under the License is distributed on an
16
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17
- either express or implied. See the License for the specific
18
- language governing permissions and limitations under the License.
19
-
20
-
21
- Named colors are taken from X11 Color Names.
22
- http://www.w3.org/TR/css3-color/#svg-color
@@ -1,21 +0,0 @@
1
- /** echo * @license echo * while read i do echo * done echo
2
- */
3
- !function(){var Color,K,PITHIRD,TWOPI,X,Y,Z,bezier,brewer,chroma,clip_rgb,colors,cos,css2rgb,hex2rgb,hsi2rgb,hsl2rgb,hsv2rgb,lab2lch,lab2rgb,lab_xyz,lch2lab,lch2rgb,limit,luminance,luminance_x,rgb2hex,rgb2hsi,rgb2hsl,rgb2hsv,rgb2lab,rgb2lch,rgb_xyz,root,type,unpack,xyz_lab,xyz_rgb,_ref;chroma=function(x,y,z,m){return new Color(x,y,z,m)};if(typeof module!=="undefined"&&module!==null&&module.exports!=null){module.exports=chroma}if(typeof define==="function"&&define.amd){define([],function(){return chroma})}else{root=typeof exports!=="undefined"&&exports!==null?exports:this;root.chroma=chroma}chroma.color=function(x,y,z,m){return new Color(x,y,z,m)};chroma.hsl=function(h,s,l,a){return new Color(h,s,l,a,"hsl")};chroma.hsv=function(h,s,v,a){return new Color(h,s,v,a,"hsv")};chroma.rgb=function(r,g,b,a){return new Color(r,g,b,a,"rgb")};chroma.hex=function(x){return new Color(x)};chroma.css=function(x){return new Color(x)};chroma.lab=function(l,a,b){return new Color(l,a,b,"lab")};chroma.lch=function(l,c,h){return new Color(l,c,h,"lch")};chroma.hsi=function(h,s,i){return new Color(h,s,i,"hsi")};chroma.gl=function(r,g,b,a){return new Color(r*255,g*255,b*255,a,"gl")};chroma.interpolate=function(a,b,f,m){if(a==null||b==null){return"#000"}if(type(a)==="string"){a=new Color(a)}if(type(b)==="string"){b=new Color(b)}return a.interpolate(f,b,m)};chroma.mix=chroma.interpolate;chroma.contrast=function(a,b){var l1,l2;if(type(a)==="string"){a=new Color(a)}if(type(b)==="string"){b=new Color(b)}l1=a.luminance();l2=b.luminance();if(l1>l2){return(l1+.05)/(l2+.05)}else{return(l2+.05)/(l1+.05)}};chroma.luminance=function(color){return chroma(color).luminance()};chroma._Color=Color;Color=function(){function Color(){var a,arg,args,m,me,me_rgb,x,y,z,_i,_len,_ref,_ref1,_ref2,_ref3,_ref4;me=this;args=[];for(_i=0,_len=arguments.length;_i<_len;_i++){arg=arguments[_i];if(arg!=null){args.push(arg)}}if(args.length===0){_ref=[255,0,255,1,"rgb"],x=_ref[0],y=_ref[1],z=_ref[2],a=_ref[3],m=_ref[4]}else if(type(args[0])==="array"){if(args[0].length===3){_ref1=args[0],x=_ref1[0],y=_ref1[1],z=_ref1[2];a=1}else if(args[0].length===4){_ref2=args[0],x=_ref2[0],y=_ref2[1],z=_ref2[2],a=_ref2[3]}else{throw"unknown input argument"}m=(_ref3=args[1])!=null?_ref3:"rgb"}else if(type(args[0])==="string"){x=args[0];m="hex"}else if(type(args[0])==="object"){_ref4=args[0]._rgb,x=_ref4[0],y=_ref4[1],z=_ref4[2],a=_ref4[3];m="rgb"}else if(args.length>=3){x=args[0];y=args[1];z=args[2]}if(args.length===3){m="rgb";a=1}else if(args.length===4){if(type(args[3])==="string"){m=args[3];a=1}else if(type(args[3])==="number"){m="rgb";a=args[3]}}else if(args.length===5){a=args[3];m=args[4]}if(a==null){a=1}if(m==="rgb"){me._rgb=[x,y,z,a]}else if(m==="gl"){me._rgb=[x*255,y*255,z*255,a]}else if(m==="hsl"){me._rgb=hsl2rgb(x,y,z);me._rgb[3]=a}else if(m==="hsv"){me._rgb=hsv2rgb(x,y,z);me._rgb[3]=a}else if(m==="hex"){me._rgb=hex2rgb(x)}else if(m==="lab"){me._rgb=lab2rgb(x,y,z);me._rgb[3]=a}else if(m==="lch"){me._rgb=lch2rgb(x,y,z);me._rgb[3]=a}else if(m==="hsi"){me._rgb=hsi2rgb(x,y,z);me._rgb[3]=a}me_rgb=clip_rgb(me._rgb)}Color.prototype.rgb=function(){return this._rgb.slice(0,3)};Color.prototype.rgba=function(){return this._rgb};Color.prototype.hex=function(){return rgb2hex(this._rgb)};Color.prototype.toString=function(){return this.name()};Color.prototype.hsl=function(){return rgb2hsl(this._rgb)};Color.prototype.hsv=function(){return rgb2hsv(this._rgb)};Color.prototype.lab=function(){return rgb2lab(this._rgb)};Color.prototype.lch=function(){return rgb2lch(this._rgb)};Color.prototype.hsi=function(){return rgb2hsi(this._rgb)};Color.prototype.gl=function(){return[this._rgb[0]/255,this._rgb[1]/255,this._rgb[2]/255,this._rgb[3]]};Color.prototype.luminance=function(){return luminance(this._rgb)};Color.prototype.name=function(){var h,k;h=this.hex();for(k in chroma.colors){if(h===chroma.colors[k]){return k}}return h};Color.prototype.alpha=function(alpha){if(arguments.length){this._rgb[3]=alpha;return this}return this._rgb[3]};Color.prototype.css=function(mode){var hsl,me,rgb,rnd;if(mode==null){mode="rgb"}me=this;rgb=me._rgb;if(mode.length===3&&rgb[3]<1){mode+="a"}if(mode==="rgb"){return mode+"("+rgb.slice(0,3).map(Math.round).join(",")+")"}else if(mode==="rgba"){return mode+"("+rgb.slice(0,3).map(Math.round).join(",")+","+rgb[3]+")"}else if(mode==="hsl"||mode==="hsla"){hsl=me.hsl();rnd=function(a){return Math.round(a*100)/100};hsl[0]=rnd(hsl[0]);hsl[1]=rnd(hsl[1]*100)+"%";hsl[2]=rnd(hsl[2]*100)+"%";if(mode.length===4){hsl[3]=rgb[3]}return mode+"("+hsl.join(",")+")"}};Color.prototype.interpolate=function(f,col,m){var dh,hue,hue0,hue1,lbv,lbv0,lbv1,me,res,sat,sat0,sat1,xyz0,xyz1;me=this;if(m==null){m="rgb"}if(type(col)==="string"){col=new Color(col)}if(m==="hsl"||m==="hsv"||m==="lch"||m==="hsi"){if(m==="hsl"){xyz0=me.hsl();xyz1=col.hsl()}else if(m==="hsv"){xyz0=me.hsv();xyz1=col.hsv()}else if(m==="hsi"){xyz0=me.hsi();xyz1=col.hsi()}else if(m==="lch"){xyz0=me.lch();xyz1=col.lch()}if(m.substr(0,1)==="h"){hue0=xyz0[0],sat0=xyz0[1],lbv0=xyz0[2];hue1=xyz1[0],sat1=xyz1[1],lbv1=xyz1[2]}else{lbv0=xyz0[0],sat0=xyz0[1],hue0=xyz0[2];lbv1=xyz1[0],sat1=xyz1[1],hue1=xyz1[2]}if(!isNaN(hue0)&&!isNaN(hue1)){if(hue1>hue0&&hue1-hue0>180){dh=hue1-(hue0+360)}else if(hue1<hue0&&hue0-hue1>180){dh=hue1+360-hue0}else{dh=hue1-hue0}hue=hue0+f*dh}else if(!isNaN(hue0)){hue=hue0;if((lbv1===1||lbv1===0)&&m!=="hsv"){sat=sat0}}else if(!isNaN(hue1)){hue=hue1;if((lbv0===1||lbv0===0)&&m!=="hsv"){sat=sat1}}else{hue=Number.NaN}if(sat==null){sat=sat0+f*(sat1-sat0)}lbv=lbv0+f*(lbv1-lbv0);if(m.substr(0,1)==="h"){res=new Color(hue,sat,lbv,m)}else{res=new Color(lbv,sat,hue,m)}}else if(m==="rgb"){xyz0=me._rgb;xyz1=col._rgb;res=new Color(xyz0[0]+f*(xyz1[0]-xyz0[0]),xyz0[1]+f*(xyz1[1]-xyz0[1]),xyz0[2]+f*(xyz1[2]-xyz0[2]),m)}else if(m==="lab"){xyz0=me.lab();xyz1=col.lab();res=new Color(xyz0[0]+f*(xyz1[0]-xyz0[0]),xyz0[1]+f*(xyz1[1]-xyz0[1]),xyz0[2]+f*(xyz1[2]-xyz0[2]),m)}else{throw"color mode "+m+" is not supported"}res.alpha(me.alpha()+f*(col.alpha()-me.alpha()));return res};Color.prototype.premultiply=function(){var a,rgb;rgb=this.rgb();a=this.alpha();return chroma(rgb[0]*a,rgb[1]*a,rgb[2]*a,a)};Color.prototype.darken=function(amount){var lch,me;if(amount==null){amount=20}me=this;lch=me.lch();lch[0]-=amount;return chroma.lch(lch).alpha(me.alpha())};Color.prototype.darker=function(amount){return this.darken(amount)};Color.prototype.brighten=function(amount){if(amount==null){amount=20}return this.darken(-amount)};Color.prototype.brighter=function(amount){return this.brighten(amount)};Color.prototype.saturate=function(amount){var lch,me;if(amount==null){amount=20}me=this;lch=me.lch();lch[1]+=amount;return chroma.lch(lch).alpha(me.alpha())};Color.prototype.desaturate=function(amount){if(amount==null){amount=20}return this.saturate(-amount)};return Color}();clip_rgb=function(rgb){var i;for(i in rgb){if(i<3){if(rgb[i]<0){rgb[i]=0}if(rgb[i]>255){rgb[i]=255}}else if(i===3){if(rgb[i]<0){rgb[i]=0}if(rgb[i]>1){rgb[i]=1}}}return rgb};css2rgb=function(css){var hsl,i,m,rgb,_i,_j,_k,_l;css=css.toLowerCase();if(chroma.colors!=null&&chroma.colors[css]){return hex2rgb(chroma.colors[css])}if(m=css.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){rgb=m.slice(1,4);for(i=_i=0;_i<=2;i=++_i){rgb[i]=+rgb[i]}rgb[3]=1}else if(m=css.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/)){rgb=m.slice(1,5);for(i=_j=0;_j<=3;i=++_j){rgb[i]=+rgb[i]}}else if(m=css.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){rgb=m.slice(1,4);for(i=_k=0;_k<=2;i=++_k){rgb[i]=Math.round(rgb[i]*2.55)}rgb[3]=1}else if(m=css.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){rgb=m.slice(1,5);for(i=_l=0;_l<=2;i=++_l){rgb[i]=Math.round(rgb[i]*2.55)}rgb[3]=+rgb[3]}else if(m=css.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){hsl=m.slice(1,4);hsl[1]*=.01;hsl[2]*=.01;rgb=hsl2rgb(hsl);rgb[3]=1}else if(m=css.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){hsl=m.slice(1,4);hsl[1]*=.01;hsl[2]*=.01;rgb=hsl2rgb(hsl);rgb[3]=+m[4]}return rgb};hex2rgb=function(hex){var a,b,g,r,rgb,u;if(hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)){if(hex.length===4||hex.length===7){hex=hex.substr(1)}if(hex.length===3){hex=hex.split("");hex=hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]}u=parseInt(hex,16);r=u>>16;g=u>>8&255;b=u&255;return[r,g,b,1]}if(hex.match(/^#?([A-Fa-f0-9]{8})$/)){if(hex.length===9){hex=hex.substr(1)}u=parseInt(hex,16);r=u>>24&255;g=u>>16&255;b=u>>8&255;a=u&255;return[r,g,b,a]}if(rgb=css2rgb(hex)){return rgb}throw"unknown color: "+hex};hsi2rgb=function(h,s,i){var b,g,r,_ref;_ref=unpack(arguments),h=_ref[0],s=_ref[1],i=_ref[2];h/=360;if(h<1/3){b=(1-s)/3;r=(1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3;g=1-(b+r)}else if(h<2/3){h-=1/3;r=(1-s)/3;g=(1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3;b=1-(r+g)}else{h-=2/3;g=(1-s)/3;b=(1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3;r=1-(g+b)}r=limit(i*r*3);g=limit(i*g*3);b=limit(i*b*3);return[r*255,g*255,b*255]};hsl2rgb=function(){var b,c,g,h,i,l,r,s,t1,t2,t3,_i,_ref,_ref1;_ref=unpack(arguments),h=_ref[0],s=_ref[1],l=_ref[2];if(s===0){r=g=b=l*255}else{t3=[0,0,0];c=[0,0,0];t2=l<.5?l*(1+s):l+s-l*s;t1=2*l-t2;h/=360;t3[0]=h+1/3;t3[1]=h;t3[2]=h-1/3;for(i=_i=0;_i<=2;i=++_i){if(t3[i]<0){t3[i]+=1}if(t3[i]>1){t3[i]-=1}if(6*t3[i]<1){c[i]=t1+(t2-t1)*6*t3[i]}else if(2*t3[i]<1){c[i]=t2}else if(3*t3[i]<2){c[i]=t1+(t2-t1)*(2/3-t3[i])*6}else{c[i]=t1}}_ref1=[Math.round(c[0]*255),Math.round(c[1]*255),Math.round(c[2]*255)],r=_ref1[0],g=_ref1[1],b=_ref1[2]}return[r,g,b]};hsv2rgb=function(){var b,f,g,h,i,p,q,r,s,t,v,_ref,_ref1,_ref2,_ref3,_ref4,_ref5,_ref6;_ref=unpack(arguments),h=_ref[0],s=_ref[1],v=_ref[2];v*=255;if(s===0){r=g=b=v}else{if(h===360){h=0}if(h>360){h-=360}if(h<0){h+=360}h/=60;i=Math.floor(h);f=h-i;p=v*(1-s);q=v*(1-s*f);t=v*(1-s*(1-f));switch(i){case 0:_ref1=[v,t,p],r=_ref1[0],g=_ref1[1],b=_ref1[2];break;case 1:_ref2=[q,v,p],r=_ref2[0],g=_ref2[1],b=_ref2[2];break;case 2:_ref3=[p,v,t],r=_ref3[0],g=_ref3[1],b=_ref3[2];break;case 3:_ref4=[p,q,v],r=_ref4[0],g=_ref4[1],b=_ref4[2];break;case 4:_ref5=[t,p,v],r=_ref5[0],g=_ref5[1],b=_ref5[2];break;case 5:_ref6=[v,p,q],r=_ref6[0],g=_ref6[1],b=_ref6[2]}}r=Math.round(r);g=Math.round(g);b=Math.round(b);return[r,g,b]};K=18;X=.95047;Y=1;Z=1.08883;lab2lch=function(){var a,b,c,h,l,_ref;_ref=unpack(arguments),l=_ref[0],a=_ref[1],b=_ref[2];c=Math.sqrt(a*a+b*b);h=Math.atan2(b,a)/Math.PI*180;return[l,c,h]};lab2rgb=function(l,a,b){var g,r,x,y,z,_ref,_ref1;if(l!==void 0&&l.length===3){_ref=l,l=_ref[0],a=_ref[1],b=_ref[2]}if(l!==void 0&&l.length===3){_ref1=l,l=_ref1[0],a=_ref1[1],b=_ref1[2]}y=(l+16)/116;x=y+a/500;z=y-b/200;x=lab_xyz(x)*X;y=lab_xyz(y)*Y;z=lab_xyz(z)*Z;r=xyz_rgb(3.2404542*x-1.5371385*y-.4985314*z);g=xyz_rgb(-.969266*x+1.8760108*y+.041556*z);b=xyz_rgb(.0556434*x-.2040259*y+1.0572252*z);return[limit(r,0,255),limit(g,0,255),limit(b,0,255),1]};lab_xyz=function(x){if(x>.206893034){return x*x*x}else{return(x-4/29)/7.787037}};xyz_rgb=function(r){return Math.round(255*(r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055))};lch2lab=function(){var c,h,l,_ref;_ref=unpack(arguments),l=_ref[0],c=_ref[1],h=_ref[2];h=h*Math.PI/180;return[l,Math.cos(h)*c,Math.sin(h)*c]};lch2rgb=function(l,c,h){var L,a,b,g,r,_ref,_ref1;_ref=lch2lab(l,c,h),L=_ref[0],a=_ref[1],b=_ref[2];_ref1=lab2rgb(L,a,b),r=_ref1[0],g=_ref1[1],b=_ref1[2];return[limit(r,0,255),limit(g,0,255),limit(b,0,255)]};luminance=function(r,g,b){var _ref;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];r=luminance_x(r);g=luminance_x(g);b=luminance_x(b);return.2126*r+.7152*g+.0722*b};luminance_x=function(x){x/=255;if(x<=.03928){return x/12.92}else{return Math.pow((x+.055)/1.055,2.4)}};rgb2hex=function(){var b,g,r,str,u,_ref;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];u=r<<16|g<<8|b;str="000000"+u.toString(16);return"#"+str.substr(str.length-6)};rgb2hsi=function(){var TWOPI,b,g,h,i,min,r,s,_ref;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];TWOPI=Math.PI*2;r/=255;g/=255;b/=255;min=Math.min(r,g,b);i=(r+g+b)/3;s=1-min/i;if(s===0){h=0}else{h=(r-g+(r-b))/2;h/=Math.sqrt((r-g)*(r-g)+(r-b)*(g-b));h=Math.acos(h);if(b>g){h=TWOPI-h}h/=TWOPI}return[h*360,s,i]};rgb2hsl=function(r,g,b){var h,l,max,min,s,_ref;if(r!==void 0&&r.length>=3){_ref=r,r=_ref[0],g=_ref[1],b=_ref[2]}r/=255;g/=255;b/=255;min=Math.min(r,g,b);max=Math.max(r,g,b);l=(max+min)/2;if(max===min){s=0;h=Number.NaN}else{s=l<.5?(max-min)/(max+min):(max-min)/(2-max-min)}if(r===max){h=(g-b)/(max-min)}else if(g===max){h=2+(b-r)/(max-min)}else if(b===max){h=4+(r-g)/(max-min)}h*=60;if(h<0){h+=360}return[h,s,l]};rgb2hsv=function(){var b,delta,g,h,max,min,r,s,v,_ref;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];min=Math.min(r,g,b);max=Math.max(r,g,b);delta=max-min;v=max/255;if(max===0){h=Number.NaN;s=0}else{s=delta/max;if(r===max){h=(g-b)/delta}if(g===max){h=2+(b-r)/delta}if(b===max){h=4+(r-g)/delta}h*=60;if(h<0){h+=360}}return[h,s,v]};rgb2lab=function(){var b,g,r,x,y,z,_ref;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];r=rgb_xyz(r);g=rgb_xyz(g);b=rgb_xyz(b);x=xyz_lab((.4124564*r+.3575761*g+.1804375*b)/X);y=xyz_lab((.2126729*r+.7151522*g+.072175*b)/Y);z=xyz_lab((.0193339*r+.119192*g+.9503041*b)/Z);return[116*y-16,500*(x-y),200*(y-z)]};rgb_xyz=function(r){if((r/=255)<=.04045){return r/12.92}else{return Math.pow((r+.055)/1.055,2.4)}};xyz_lab=function(x){if(x>.008856){return Math.pow(x,1/3)}else{return 7.787037*x+4/29}};rgb2lch=function(){var a,b,g,l,r,_ref,_ref1;_ref=unpack(arguments),r=_ref[0],g=_ref[1],b=_ref[2];_ref1=rgb2lab(r,g,b),l=_ref1[0],a=_ref1[1],b=_ref1[2];return lab2lch(l,a,b)};chroma.scale=function(colors,positions){var classifyValue,f,getClass,getColor,resetCache,setColors,setDomain,tmap,_colorCache,_colors,_correctLightness,_domain,_fixed,_max,_min,_mode,_nacol,_numClasses,_out,_pos,_spread;_mode="rgb";_nacol=chroma("#ccc");_spread=0;_fixed=false;_domain=[0,1];_colors=[];_out=false;_pos=[];_min=0;_max=1;_correctLightness=false;_numClasses=0;_colorCache={};setColors=function(colors,positions){var c,col,_i,_j,_ref,_ref1,_ref2;if(colors==null){colors=["#ddd","#222"]}if(colors!=null&&type(colors)==="string"&&((_ref=chroma.brewer)!=null?_ref[colors]:void 0)!=null){colors=chroma.brewer[colors]}if(type(colors)==="array"){colors=colors.slice(0);for(c=_i=0,_ref1=colors.length-1;0<=_ref1?_i<=_ref1:_i>=_ref1;c=0<=_ref1?++_i:--_i){col=colors[c];if(type(col)==="string"){colors[c]=chroma(col)}}if(positions!=null){_pos=positions}else{_pos=[];for(c=_j=0,_ref2=colors.length-1;0<=_ref2?_j<=_ref2:_j>=_ref2;c=0<=_ref2?++_j:--_j){_pos.push(c/(colors.length-1))}}}resetCache();return _colors=colors};setDomain=function(domain){if(domain==null){domain=[]}_domain=domain;_min=domain[0];_max=domain[domain.length-1];resetCache();if(domain.length===2){return _numClasses=0}else{return _numClasses=domain.length-1}};getClass=function(value){var i,n;if(_domain!=null){n=_domain.length-1;i=0;while(i<n&&value>=_domain[i]){i++}return i-1}return 0};tmap=function(t){return t};classifyValue=function(value){var i,maxc,minc,n,val;val=value;if(_domain.length>2){n=_domain.length-1;i=getClass(value);minc=_domain[0]+(_domain[1]-_domain[0])*(0+_spread*.5);maxc=_domain[n-1]+(_domain[n]-_domain[n-1])*(1-_spread*.5);val=_min+(_domain[i]+(_domain[i+1]-_domain[i])*.5-minc)/(maxc-minc)*(_max-_min)}return val};getColor=function(val,bypassMap){var c,col,f0,i,k,p,t,_i,_ref;if(bypassMap==null){bypassMap=false}if(isNaN(val)){return _nacol}if(!bypassMap){if(_domain.length>2){c=getClass(val);t=c/(_numClasses-1)}else{t=f0=(val-_min)/(_max-_min);t=Math.min(1,Math.max(0,t))}}else{t=val}if(!bypassMap){t=tmap(t)}k=Math.floor(t*1e4);if(_colorCache[k]){col=_colorCache[k]}else{if(type(_colors)==="array"){for(i=_i=0,_ref=_pos.length-1;0<=_ref?_i<=_ref:_i>=_ref;i=0<=_ref?++_i:--_i){p=_pos[i];if(t<=p){col=_colors[i];break}if(t>=p&&i===_pos.length-1){col=_colors[i];break}if(t>p&&t<_pos[i+1]){t=(t-p)/(_pos[i+1]-p);col=chroma.interpolate(_colors[i],_colors[i+1],t,_mode);break}}}else if(type(_colors)==="function"){col=_colors(t)}_colorCache[k]=col}return col};resetCache=function(){return _colorCache={}};setColors(colors,positions);f=function(v){var c;c=getColor(v);if(_out&&c[_out]){return c[_out]()}else{return c}};f.domain=function(domain,classes,mode,key){var d;if(mode==null){mode="e"}if(!arguments.length){return _domain}if(classes!=null){d=chroma.analyze(domain,key);if(classes===0){domain=[d.min,d.max]}else{domain=chroma.limits(d,mode,classes)}}setDomain(domain);return f};f.mode=function(_m){if(!arguments.length){return _mode}_mode=_m;resetCache();return f};f.range=function(colors,_pos){setColors(colors,_pos);return f};f.out=function(_o){_out=_o;return f};f.spread=function(val){if(!arguments.length){return _spread}_spread=val;return f};f.correctLightness=function(v){if(!arguments.length){return _correctLightness}_correctLightness=v;resetCache();if(_correctLightness){tmap=function(t){var L0,L1,L_actual,L_diff,L_ideal,max_iter,pol,t0,t1;L0=getColor(0,true).lab()[0];L1=getColor(1,true).lab()[0];pol=L0>L1;L_actual=getColor(t,true).lab()[0];L_ideal=L0+(L1-L0)*t;L_diff=L_actual-L_ideal;t0=0;t1=1;max_iter=20;while(Math.abs(L_diff)>.01&&max_iter-->0){!function(){if(pol){L_diff*=-1}if(L_diff<0){t0=t;t+=(t1-t)*.5}else{t1=t;t+=(t0-t)*.5}L_actual=getColor(t,true).lab()[0];return L_diff=L_actual-L_ideal}()}return t}}else{tmap=function(t){return t}}return f};f.colors=function(out){var i,samples,_i,_j,_len,_ref;if(out==null){out="hex"}colors=[];samples=[];if(_domain.length>2){for(i=_i=1,_ref=_domain.length;1<=_ref?_i<_ref:_i>_ref;i=1<=_ref?++_i:--_i){samples.push((_domain[i-1]+_domain[i])*.5)}}else{samples=_domain}for(_j=0,_len=samples.length;_j<_len;_j++){i=samples[_j];colors.push(f(i)[out]())}return colors};return f};if((_ref=chroma.scales)==null){chroma.scales={}}chroma.scales.cool=function(){return chroma.scale([chroma.hsl(180,1,.9),chroma.hsl(250,.7,.4)])};chroma.scales.hot=function(){return chroma.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")};chroma.analyze=function(data,key,filter){var add,k,r,val,visit,_i,_len;r={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};if(filter==null){filter=function(){return true}}add=function(val){if(val!=null&&!isNaN(val)){r.values.push(val);r.sum+=val;if(val<r.min){r.min=val}if(val>r.max){r.max=val}r.count+=1}};visit=function(val,k){if(filter(val,k)){if(key!=null&&type(key)==="function"){return add(key(val))}else if(key!=null&&type(key)==="string"||type(key)==="number"){return add(val[key])}else{return add(val)}}};if(type(data)==="array"){for(_i=0,_len=data.length;_i<_len;_i++){val=data[_i];visit(val)}}else{for(k in data){val=data[k];visit(val,k)}}r.domain=[r.min,r.max];r.limits=function(mode,num){return chroma.limits(r,mode,num)};return r};chroma.limits=function(data,mode,num){var assignments,best,centroids,cluster,clusterSizes,dist,i,j,kClusters,limits,max,max_log,min,min_log,mindist,n,nb_iters,newCentroids,p,pb,pr,repeat,sum,tmpKMeansBreaks,value,values,_i,_j,_k,_l,_m,_n,_o,_p,_q,_r,_ref1,_ref10,_ref11,_ref12,_ref13,_ref14,_ref15,_ref2,_ref3,_ref4,_ref5,_ref6,_ref7,_ref8,_ref9,_s,_t,_u,_v,_w;if(mode==null){mode="equal"}if(num==null){num=7}if(type(data)==="array"){data=chroma.analyze(data)}min=data.min;max=data.max;sum=data.sum;values=data.values.sort(function(a,b){return a-b});limits=[];if(mode.substr(0,1)==="c"){limits.push(min);limits.push(max)}if(mode.substr(0,1)==="e"){limits.push(min);for(i=_i=1,_ref1=num-1;1<=_ref1?_i<=_ref1:_i>=_ref1;i=1<=_ref1?++_i:--_i){limits.push(min+i/num*(max-min))}limits.push(max)}else if(mode.substr(0,1)==="l"){if(min<=0){throw"Logarithmic scales are only possible for values > 0"}min_log=Math.LOG10E*Math.log(min);max_log=Math.LOG10E*Math.log(max);limits.push(min);for(i=_j=1,_ref2=num-1;1<=_ref2?_j<=_ref2:_j>=_ref2;i=1<=_ref2?++_j:--_j){limits.push(Math.pow(10,min_log+i/num*(max_log-min_log)))}limits.push(max)}else if(mode.substr(0,1)==="q"){limits.push(min);for(i=_k=1,_ref3=num-1;1<=_ref3?_k<=_ref3:_k>=_ref3;i=1<=_ref3?++_k:--_k){p=values.length*i/num;pb=Math.floor(p);if(pb===p){limits.push(values[pb])}else{pr=p-pb;limits.push(values[pb]*pr+values[pb+1]*(1-pr))}}limits.push(max)}else if(mode.substr(0,1)==="k"){n=values.length;assignments=new Array(n);clusterSizes=new Array(num);repeat=true;nb_iters=0;centroids=null;centroids=[];centroids.push(min);for(i=_l=1,_ref4=num-1;1<=_ref4?_l<=_ref4:_l>=_ref4;i=1<=_ref4?++_l:--_l){centroids.push(min+i/num*(max-min))}centroids.push(max);while(repeat){for(j=_m=0,_ref5=num-1;0<=_ref5?_m<=_ref5:_m>=_ref5;j=0<=_ref5?++_m:--_m){clusterSizes[j]=0}for(i=_n=0,_ref6=n-1;0<=_ref6?_n<=_ref6:_n>=_ref6;i=0<=_ref6?++_n:--_n){value=values[i];mindist=Number.MAX_VALUE;for(j=_o=0,_ref7=num-1;0<=_ref7?_o<=_ref7:_o>=_ref7;j=0<=_ref7?++_o:--_o){dist=Math.abs(centroids[j]-value);if(dist<mindist){mindist=dist;best=j}}clusterSizes[best]++;assignments[i]=best}newCentroids=new Array(num);for(j=_p=0,_ref8=num-1;0<=_ref8?_p<=_ref8:_p>=_ref8;j=0<=_ref8?++_p:--_p){newCentroids[j]=null}for(i=_q=0,_ref9=n-1;0<=_ref9?_q<=_ref9:_q>=_ref9;i=0<=_ref9?++_q:--_q){cluster=assignments[i];if(newCentroids[cluster]===null){newCentroids[cluster]=values[i]}else{newCentroids[cluster]+=values[i]}}for(j=_r=0,_ref10=num-1;0<=_ref10?_r<=_ref10:_r>=_ref10;j=0<=_ref10?++_r:--_r){newCentroids[j]*=1/clusterSizes[j]}repeat=false;for(j=_s=0,_ref11=num-1;0<=_ref11?_s<=_ref11:_s>=_ref11;j=0<=_ref11?++_s:--_s){if(newCentroids[j]!==centroids[i]){repeat=true;break}}centroids=newCentroids;nb_iters++;if(nb_iters>200){repeat=false}}kClusters={};for(j=_t=0,_ref12=num-1;0<=_ref12?_t<=_ref12:_t>=_ref12;j=0<=_ref12?++_t:--_t){kClusters[j]=[]}for(i=_u=0,_ref13=n-1;0<=_ref13?_u<=_ref13:_u>=_ref13;i=0<=_ref13?++_u:--_u){cluster=assignments[i];kClusters[cluster].push(values[i])}tmpKMeansBreaks=[];for(j=_v=0,_ref14=num-1;0<=_ref14?_v<=_ref14:_v>=_ref14;j=0<=_ref14?++_v:--_v){tmpKMeansBreaks.push(kClusters[j][0]);tmpKMeansBreaks.push(kClusters[j][kClusters[j].length-1])}tmpKMeansBreaks=tmpKMeansBreaks.sort(function(a,b){return a-b});limits.push(tmpKMeansBreaks[0]);for(i=_w=1,_ref15=tmpKMeansBreaks.length-1;_w<=_ref15;i=_w+=2){if(!isNaN(tmpKMeansBreaks[i])){limits.push(tmpKMeansBreaks[i])}}}return limits};/**
4
- ColorBrewer colors for chroma.js
5
-
6
- Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The
7
- Pennsylvania State University.
8
-
9
- Licensed under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License.
11
- You may obtain a copy of the License at
12
- http://www.apache.org/licenses/LICENSE-2.0
13
-
14
- Unless required by applicable law or agreed to in writing, software distributed
15
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16
- CONDITIONS OF ANY KIND, either express or implied. See the License for the
17
- specific language governing permissions and limitations under the License.
18
-
19
- @preserve
20
- */
21
- chroma.brewer=brewer={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]};chroma.colors=colors={indigo:"#4b0082",gold:"#ffd700",hotpink:"#ff69b4",firebrick:"#b22222",indianred:"#cd5c5c",yellow:"#ffff00",mistyrose:"#ffe4e1",darkolivegreen:"#556b2f",olive:"#808000",darkseagreen:"#8fbc8f",pink:"#ffc0cb",tomato:"#ff6347",lightcoral:"#f08080",orangered:"#ff4500",navajowhite:"#ffdead",lime:"#00ff00",palegreen:"#98fb98",darkslategrey:"#2f4f4f",greenyellow:"#adff2f",burlywood:"#deb887",seashell:"#fff5ee",mediumspringgreen:"#00fa9a",fuchsia:"#ff00ff",papayawhip:"#ffefd5",blanchedalmond:"#ffebcd",chartreuse:"#7fff00",dimgray:"#696969",black:"#000000",peachpuff:"#ffdab9",springgreen:"#00ff7f",aquamarine:"#7fffd4",white:"#ffffff",orange:"#ffa500",lightsalmon:"#ffa07a",darkslategray:"#2f4f4f",brown:"#a52a2a",ivory:"#fffff0",dodgerblue:"#1e90ff",peru:"#cd853f",lawngreen:"#7cfc00",chocolate:"#d2691e",crimson:"#dc143c",forestgreen:"#228b22",darkgrey:"#a9a9a9",lightseagreen:"#20b2aa",cyan:"#00ffff",mintcream:"#f5fffa",silver:"#c0c0c0",antiquewhite:"#faebd7",mediumorchid:"#ba55d3",skyblue:"#87ceeb",gray:"#808080",darkturquoise:"#00ced1",goldenrod:"#daa520",darkgreen:"#006400",floralwhite:"#fffaf0",darkviolet:"#9400d3",darkgray:"#a9a9a9",moccasin:"#ffe4b5",saddlebrown:"#8b4513",grey:"#808080",darkslateblue:"#483d8b",lightskyblue:"#87cefa",lightpink:"#ffb6c1",mediumvioletred:"#c71585",slategrey:"#708090",red:"#ff0000",deeppink:"#ff1493",limegreen:"#32cd32",darkmagenta:"#8b008b",palegoldenrod:"#eee8aa",plum:"#dda0dd",turquoise:"#40e0d0",lightgrey:"#d3d3d3",lightgoldenrodyellow:"#fafad2",darkgoldenrod:"#b8860b",lavender:"#e6e6fa",maroon:"#800000",yellowgreen:"#9acd32",sandybrown:"#f4a460",thistle:"#d8bfd8",violet:"#ee82ee",navy:"#000080",magenta:"#ff00ff",dimgrey:"#696969",tan:"#d2b48c",rosybrown:"#bc8f8f",olivedrab:"#6b8e23",blue:"#0000ff",lightblue:"#add8e6",ghostwhite:"#f8f8ff",honeydew:"#f0fff0",cornflowerblue:"#6495ed",slateblue:"#6a5acd",linen:"#faf0e6",darkblue:"#00008b",powderblue:"#b0e0e6",seagreen:"#2e8b57",darkkhaki:"#bdb76b",snow:"#fffafa",sienna:"#a0522d",mediumblue:"#0000cd",royalblue:"#4169e1",lightcyan:"#e0ffff",green:"#008000",mediumpurple:"#9370db",midnightblue:"#191970",cornsilk:"#fff8dc",paleturquoise:"#afeeee",bisque:"#ffe4c4",slategray:"#708090",darkcyan:"#008b8b",khaki:"#f0e68c",wheat:"#f5deb3",teal:"#008080",darkorchid:"#9932cc",deepskyblue:"#00bfff",salmon:"#fa8072",darkred:"#8b0000",steelblue:"#4682b4",palevioletred:"#db7093",lightslategray:"#778899",aliceblue:"#f0f8ff",lightslategrey:"#778899",lightgreen:"#90ee90",orchid:"#da70d6",gainsboro:"#dcdcdc",mediumseagreen:"#3cb371",lightgray:"#d3d3d3",mediumturquoise:"#48d1cc",lemonchiffon:"#fffacd",cadetblue:"#5f9ea0",lightyellow:"#ffffe0",lavenderblush:"#fff0f5",coral:"#ff7f50",purple:"#800080",aqua:"#00ffff",whitesmoke:"#f5f5f5",mediumslateblue:"#7b68ee",darkorange:"#ff8c00",mediumaquamarine:"#66cdaa",darksalmon:"#e9967a",beige:"#f5f5dc",blueviolet:"#8a2be2",azure:"#f0ffff",lightsteelblue:"#b0c4de",oldlace:"#fdf5e6"};type=function(){var classToType,name,_i,_len,_ref1;classToType={};_ref1="Boolean Number String Function Array Date RegExp Undefined Null".split(" ");for(_i=0,_len=_ref1.length;_i<_len;_i++){name=_ref1[_i];classToType["[object "+name+"]"]=name.toLowerCase()}return function(obj){var strType;strType=Object.prototype.toString.call(obj);return classToType[strType]||"object"}}();limit=function(x,min,max){if(min==null){min=0}if(max==null){max=1}if(x<min){x=min}if(x>max){x=max}return x};unpack=function(args){if(args.length>=3){return args}else{return args[0]}};TWOPI=Math.PI*2;PITHIRD=Math.PI/3;cos=Math.cos;bezier=function(colors){var I,I0,I1,c,lab0,lab1,lab2,lab3,_ref1,_ref2,_ref3;colors=function(){var _i,_len,_results;_results=[];for(_i=0,_len=colors.length;_i<_len;_i++){c=colors[_i];_results.push(chroma(c))}return _results}();if(colors.length===2){_ref1=function(){var _i,_len,_results;_results=[];for(_i=0,_len=colors.length;_i<_len;_i++){c=colors[_i];_results.push(c.lab())}return _results}(),lab0=_ref1[0],lab1=_ref1[1];I=function(t){var i,lab;lab=function(){var _i,_results;_results=[];for(i=_i=0;_i<=2;i=++_i){_results.push(lab0[i]+t*(lab1[i]-lab0[i]))}return _results}();return chroma.lab.apply(chroma,lab)}}else if(colors.length===3){_ref2=function(){var _i,_len,_results;_results=[];for(_i=0,_len=colors.length;_i<_len;_i++){c=colors[_i];_results.push(c.lab())}return _results}(),lab0=_ref2[0],lab1=_ref2[1],lab2=_ref2[2];I=function(t){var i,lab;lab=function(){var _i,_results;_results=[];for(i=_i=0;_i<=2;i=++_i){_results.push((1-t)*(1-t)*lab0[i]+2*(1-t)*t*lab1[i]+t*t*lab2[i])}return _results}();return chroma.lab.apply(chroma,lab)}}else if(colors.length===4){_ref3=function(){var _i,_len,_results;_results=[];for(_i=0,_len=colors.length;_i<_len;_i++){c=colors[_i];_results.push(c.lab())}return _results}(),lab0=_ref3[0],lab1=_ref3[1],lab2=_ref3[2],lab3=_ref3[3];I=function(t){var i,lab;lab=function(){var _i,_results;_results=[];for(i=_i=0;_i<=2;i=++_i){_results.push((1-t)*(1-t)*(1-t)*lab0[i]+3*(1-t)*(1-t)*t*lab1[i]+3*(1-t)*t*t*lab2[i]+t*t*t*lab3[i])}return _results}();return chroma.lab.apply(chroma,lab)}}else if(colors.length===5){I0=bezier(colors.slice(0,3));I1=bezier(colors.slice(2,5));I=function(t){if(t<.5){return I0(t*2)}else{return I1((t-.5)*2)}}}return I};chroma.interpolate.bezier=bezier}.call(this);
@@ -1,81 +0,0 @@
1
- # Chroma.js
2
-
3
- Chroma.js is a tiny JavaScript library (8.5kB) for all kinds of color conversions and color scales.
4
-
5
- ### Usage
6
-
7
-
8
- Initiate and manipulate colors:
9
-
10
- ```javascript
11
- chroma('#D4F880').darken().hex(); // #9BC04B
12
- ```
13
-
14
- Working with color scales is easy, too:
15
-
16
- ```javascript
17
- scale = chroma.scale(['white', 'red']);
18
- scale(0.5).hex(); // #FF7F7F
19
- ```
20
-
21
- Lab/Lch interpolation looks better than than RGB
22
-
23
- ```javascript
24
- chroma.scale(['white', 'red']).mode('lab');
25
- ```
26
-
27
- Custom domains! Quantiles! Color Brewer!!
28
-
29
- ```javascript
30
- chroma.scale('RdYlBu').domain(myValues, 7, 'quantiles');
31
- ```
32
-
33
- And why not use logarithmic color scales once in your life?
34
-
35
- ```javascript
36
- chroma.scale(['lightyellow', 'navy']).domain([1, 100000], 7, 'log');
37
- ```
38
-
39
- ### Like it?
40
-
41
- Why not dive into the [API docs](https://github.com/gka/chroma.js/blob/master/doc/api.md) (quite short actually), and download [chroma.min.js](https://raw.github.com/gka/chroma.js/master/chroma.min.js) right away.
42
-
43
- You can use it in node.js, too!
44
-
45
- npm install chroma-js
46
-
47
-
48
- ### Build instructions
49
-
50
- To compile the coffee-script source files you have to run ``build.sh``.
51
-
52
- To run the tests simply run
53
-
54
- vows test/*.coffee
55
-
56
-
57
- ### Similar Libraries / Prior Art
58
-
59
- * [Chromatist](https://github.com/jrus/chromatist)
60
- * [GrapeFruit](https://github.com/xav/Grapefruit) (Python)
61
- * [colors.py](https://github.com/mattrobenolt/colors.py) (Python)
62
- * [d3.js](https://github.com/mbostock/d3)
63
-
64
-
65
- ### Author
66
-
67
- Chroma.js is written by [Gregor Aisch](http://driven-by-data.net).
68
-
69
- ### License
70
-
71
- Released under [BSD license](http://opensource.org/licenses/BSD-3-Clause).
72
- Versions prior to 0.4 were released under [GPL](http://www.gnu.org/licenses/gpl-3.0).
73
-
74
- ### Known issues
75
-
76
- * HSI color conversion is experimental and produces weird results sometimes
77
-
78
- ### Further reading
79
-
80
- * [How To Avoid Equidistant HSV Colors](https://vis4.net/blog/posts/avoid-equidistant-hsv-colors/)
81
- * [Mastering Multi-hued Color Scales with Chroma.js](https://vis4.net/blog/posts/mastering-multi-hued-color-scales/)
@@ -1,8 +0,0 @@
1
- require "chroma.js/rails/version"
2
-
3
- module Chroma.js
4
- module Rails
5
- class Engine < ::Rails::Engine
6
- end
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- module ChromaJS
2
- module Rails
3
- VERSION = "0.1.0"
4
- end
5
- end