timocratic-color 1.4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ == Color 1.4.0 / 2007.02.11
2
+ * Merged Austin Ziegler's color-tools library (previously part of the Ruby
3
+ PDF Tools project) with Matt Lyon's color library.
4
+ - The HSL implementation from the Color class has been merged into
5
+ Color::HSL. Color is a module the way it was for color-tools.
6
+ - A thin veneer has been written to allow Color::new to return a Color::HSL
7
+ instance; Color::HSL supports as many methods as possible that were
8
+ previously supported by the Color class.
9
+ - Values that were previously rounded by Color are no longer rounded;
10
+ fractional values matter.
11
+ * Converted to hoe for project management.
12
+ * Moved to the next step of deprecating Color::Name values; printing a
13
+ warning for each use (see the history for color-tools 1.3.0).
14
+ * Print a warning on the access of either VERSION or COLOR_TOOLS_VERSION; the
15
+ version constant is now COLOR_VERSION.
16
+ * Added humanized versions of accessors (e.g., CMYK colours now have both #cyan
17
+ and #c to access the cyan component of the colour; #cyan provides the value
18
+ as a percentage).
19
+ * Added CSS3 formatters for RGB, RGBA, HSL, and HSLA outputs. Note that the
20
+ Color library does not yet have a way of setting alpha opacity, so the
21
+ output for RGBA and HSLA are at full alpha opacity (1.0). The values are
22
+ output with two decimal places.
23
+ * Applied a patch to provide simple arithmetic colour addition and subtraction
24
+ to Color::GrayScale and Color::RGB. The patch was contributed by Jeremy
25
+ Hinegardner <jeremy@hinegardner.org>. This patch also provides the ability to
26
+ return the maximum RGB value as a grayscale colour.
27
+ * Fixed two problems reported by Jean Krohn <jb.krohn@free.fr> against
28
+ color-tools relating to RGB-to-HSL and HSL-to-RGB conversion. (Color and
29
+ color-tools use the same formulas, but the ordering of the calculations is
30
+ slightly different with Color and did not suffer from this problem;
31
+ color-tools was more sensitive to floating-point values and precision
32
+ errors.)
33
+ * Fixed an issue with HSL/RGB conversions reported by Adam Johnson
34
+ <adam.sven.johnson@gmail.com>.
35
+ * Added an Adobe Color swatch (Photoshop) palette reader,
36
+ Color::Palette::AdobeColor (for .aco files only).
37
+
38
+ == Color 0.1.0 / 2006.08.05
39
+ * Added HSL (degree, percent, percent) interface.
40
+ * Removed RGB instance variable; color is managed internally as HSL floating
41
+ point.
42
+ * Tests!
43
+
44
+ == color-tools 1.3.0
45
+ * Added new metallic colours suggested by Jim Freeze <jfn@freeze.org>. These
46
+ are in the namespace Color::Metallic.
47
+ * Colours that were defined in the Color namespace (e.g., Color::Red,
48
+ Color::AliceBlue) are now defined in Color::RGB (e.g., Color::RGB::Red,
49
+ Color::RGB::AliceBlue). They are added back to the Color namespace on the
50
+ first use of the old colours and a warning is printed. In version 1.4, this
51
+ warning will be printed on every use of the old colours. In version 1.5,
52
+ the backwards compatible support for colours like Color::Red will be
53
+ removed completely.
54
+ * Added the Color::CSS module, color/css or Color::CSS that provides a name
55
+ lookup of Color::RGB-namespaced constants with Color::CSS[name]. Most of
56
+ these colours (which are mirrored from the Color::RGB default colours) are
57
+ only "officially" recognised under the CSS3 colour module or SVG.
58
+ * Added the Color::HSL colour space and some helper utilities to Color::RGB
59
+ for colour manipulation using the HSL value.
60
+ * Controlled internal value replacement to be between 0 and 1 for all
61
+ colours.
62
+ * Updated Color::Palette::Gimp to more meaningfully deal with duplicate named
63
+ colours. Named colours now return an array of colours.
64
+ * Indicated the plans for some methods and constants out to color-tools 2.0.
65
+ * Added unit tests and fixed a number of hidden bugs because of them.
66
+
67
+ == color-tools 1.2.0
68
+ * Changed installer from a custom-written install.rb to setup.rb
69
+ 3.3.1-modified.
70
+ * Added Color::GreyScale (or Color::GrayScale).
71
+ * Added Color::YIQ. This colour definition is incomplete; it does not have
72
+ conversions from YIQ to other colour spaces.
73
+
74
+ == color-tools 1.1.0
75
+ * Added color/palette/gimp to support the reading and use of GIMP color
76
+ palettes.
77
+
78
+ == color-tools 1.0.0
79
+ * Initial release.
80
+
81
+ == Copyright
82
+ Color
83
+ Colour Management with Ruby
84
+ http://rubyforge.org/projects/color
85
+
86
+ Licensed under a MIT-style licence. See Licence.txt in the main
87
+ distribution for full licensing information.
88
+
89
+ Copyright (c) 2005 - 2007 Austin Ziegler and Matt Lyon
90
+
91
+ $Id: History.txt 50 2007-02-03 20:26:19Z austin $
@@ -0,0 +1,20 @@
1
+ == Installing Color
2
+
3
+ Color may be installed with:
4
+
5
+ % ruby setup.rb
6
+
7
+ Alternatively, the RubyGems version of Color may be installed from the usual
8
+ sources.
9
+
10
+ == Copyright
11
+ Color
12
+ Colour Management with Ruby
13
+ http://rubyforge.org/projects/color
14
+
15
+ Licensed under a MIT-style licence. See Licence.txt in the main
16
+ distribution for full licensing information.
17
+
18
+ Copyright (c) 2005 - 2007 Austin Ziegler and Matt Lyon
19
+
20
+ $Id: History.txt 50 2007-02-03 20:26:19Z austin $
@@ -0,0 +1,29 @@
1
+ Color
2
+ Colour management in Ruby
3
+ http://rubyforge.org/projects/color/
4
+
5
+ Copyright (c) 2005 - 2007 Austin Ziegler, Matt Lyon, and other contributors
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ $Id: History.txt 50 2007-02-03 20:26:19Z austin $
@@ -0,0 +1,31 @@
1
+ History.txt
2
+ Install.txt
3
+ Licence.txt
4
+ Manifest.txt
5
+ Rakefile
6
+ Readme.txt
7
+ lib/color.rb
8
+ lib/color/cmyk.rb
9
+ lib/color/css.rb
10
+ lib/color/grayscale.rb
11
+ lib/color/hsl.rb
12
+ lib/color/palette.rb
13
+ lib/color/palette/adobecolor.rb
14
+ lib/color/palette/gimp.rb
15
+ lib/color/palette/monocontrast.rb
16
+ lib/color/rgb-colors.rb
17
+ lib/color/rgb.rb
18
+ lib/color/rgb/metallic.rb
19
+ lib/color/yiq.rb
20
+ setup.rb
21
+ test/test_adobecolor.rb
22
+ test/test_all.rb
23
+ test/test_cmyk.rb
24
+ test/test_color.rb
25
+ test/test_css.rb
26
+ test/test_gimp.rb
27
+ test/test_grayscale.rb
28
+ test/test_hsl.rb
29
+ test/test_monocontrast.rb
30
+ test/test_rgb.rb
31
+ test/test_yiq.rb
@@ -0,0 +1,116 @@
1
+ #! /usr/bin/env rake
2
+ #--
3
+ # Color
4
+ # Colour Management with Ruby
5
+ # http://rubyforge.org/projects/color
6
+ #
7
+ # Licensed under a MIT-style licence. See Licence.txt in the main
8
+ # distribution for full licensing information.
9
+ #
10
+ # Copyright (c) 2005 - 2007 Austin Ziegler and Matt Lyon
11
+ #
12
+ # $Id: History.txt 50 2007-02-03 20:26:19Z austin $
13
+ #++
14
+
15
+ require 'rubygems'
16
+ require 'hoe'
17
+
18
+ $LOAD_PATH.unshift('lib')
19
+
20
+ require 'color'
21
+
22
+ PKG_NAME = 'color'
23
+ PKG_VERSION = Color::COLOR_VERSION
24
+ PKG_DIST = "#{PKG_NAME}-#{PKG_VERSION}"
25
+ PKG_TAR = "pkg/#{PKG_DIST}.tar.gz"
26
+ MANIFEST = File.read("Manifest.txt").split
27
+
28
+ Hoe.new PKG_NAME, PKG_VERSION do |p|
29
+ p.rubyforge_name = PKG_NAME
30
+ # This is a lie becasue I will continue to use Archive::Tar::Minitar.
31
+ p.need_tar = false
32
+ # need_zip - Should package create a zipfile? [default: false]
33
+
34
+ p.author = [ "Austin Ziegler", "Matt Lyon" ]
35
+ p.email = %W(austin@rubyforge.org matt@postsomnia.com)
36
+ p.url = "http://color.rubyforge.org/"
37
+ p.summary = "Colour management with Ruby"
38
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
39
+ p.description = p.paragraphs_of("Readme.txt", 1..1).join("\n\n")
40
+
41
+ p.extra_dev_deps << [ "archive-tar-minitar", "~>0.5.1" ]
42
+
43
+ p.clean_globs << "coverage"
44
+
45
+ p.spec_extras[:extra_rdoc_files] = MANIFEST.grep(/txt$/) -
46
+ ["Manifest.txt"]
47
+ end
48
+
49
+ desc "Build a Color .tar.gz distribution."
50
+ task :tar => [ PKG_TAR ]
51
+ file PKG_TAR => [ :test ] do |t|
52
+ require 'archive/tar/minitar'
53
+ require 'zlib'
54
+ files = MANIFEST.map { |f|
55
+ fn = File.join(PKG_DIST, f)
56
+ tm = File.stat(f).mtime
57
+
58
+ if File.directory?(f)
59
+ { :name => fn, :mode => 0755, :dir => true, :mtime => tm }
60
+ else
61
+ mode = if f =~ %r{^bin}
62
+ 0755
63
+ else
64
+ 0644
65
+ end
66
+ data = File.read(f)
67
+ { :name => fn, :mode => mode, :data => data, :size => data.size,
68
+ :mtime => tm }
69
+ end
70
+ }
71
+
72
+ begin
73
+ unless File.directory?(File.dirname(t.name))
74
+ require 'fileutils'
75
+ File.mkdir_p File.dirname(t.name)
76
+ end
77
+ tf = File.open(t.name, 'wb')
78
+ gz = Zlib::GzipWriter.new(tf)
79
+ tw = Archive::Tar::Minitar::Writer.new(gz)
80
+
81
+ files.each do |entry|
82
+ if entry[:dir]
83
+ tw.mkdir(entry[:name], entry)
84
+ else
85
+ tw.add_file_simple(entry[:name], entry) { |os|
86
+ os.write(entry[:data])
87
+ }
88
+ end
89
+ end
90
+ ensure
91
+ tw.close if tw
92
+ gz.close if gz
93
+ end
94
+ end
95
+ task :package => [ PKG_TAR ]
96
+
97
+ desc "Build the manifest file from the current set of files."
98
+ task :build_manifest do |t|
99
+ require 'find'
100
+
101
+ paths = []
102
+ Find.find(".") do |path|
103
+ next if File.directory?(path)
104
+ next if path =~ /\.svn/
105
+ next if path =~ /\.swp$/
106
+ next if path =~ %r{coverage/}
107
+ next if path =~ /~$/
108
+ paths << path.sub(%r{^\./}, '')
109
+ end
110
+
111
+ File.open("Manifest.txt", "w") do |f|
112
+ f.puts paths.sort.join("\n")
113
+ end
114
+
115
+ puts paths.sort.join("\n")
116
+ end
@@ -0,0 +1,33 @@
1
+ = Color
2
+ Color is a Ruby library to provide basic RGB, CMYK, HSL, and other colourspace
3
+ manipulation support to applications that require it. It also provides 152
4
+ named RGB colours (184 with spelling variations) that are commonly supported
5
+ in HTML, SVG, and X11 applications. A technique for generating monochromatic
6
+ contrasting palettes is also included.
7
+
8
+ The capabilities of the Color library are limited to pure mathematical
9
+ manipulation of the colours based on colour theory without reference to colour
10
+ profiles (such as sRGB or Adobe RGB). For most purposes, when working with the
11
+ RGB and HSL colours, this won't matter. However, some colour models (like CIE
12
+ L*a*b*) are not supported because Color does not yet support colour profiles,
13
+ giving no meaningful way to convert colours in absolute colour spaces (like
14
+ L*a*b*, XYZ) to non-absolute colour spaces (like RGB).
15
+
16
+ Color version 1.4 is the result of a project merge between color.rb 0.1.0 by
17
+ Matt Lyon and color-tools 1.3 by Austin Ziegler. Please see History.txt for
18
+ details on the changes this merge brings.
19
+
20
+ Copyright:: Copyright (c) 2005 - 2007 by Austin Ziegler and Matt Lyon
21
+ Version:: 1.4.0
22
+ Homepage:: http://rubyforge.org/projects/color/
23
+ Licence:: MIT-Style; see Licence.txt
24
+
25
+ Color::Palette was developed based on techniques described by Andy "Malarkey"
26
+ Clarke[1], implemented in JavaScript by Steve G. Chipman at SlayerOffice[2] and
27
+ by Patrick Fitzgerald of BarelyFitz[3] in PHP.
28
+
29
+ [1] http://www.stuffandnonsense.co.uk/archives/creating_colour_palettes.html
30
+ [2] http://slayeroffice.com/tools/color_palette/
31
+ [3] http://www.barelyfitz.com/projects/csscolor/
32
+
33
+ $Id: Readme.txt 50 2007-02-03 20:26:19Z austin $
@@ -0,0 +1,147 @@
1
+ # :title: Color -- Colour Management with Ruby
2
+ # :main: Readme.txt
3
+
4
+ #--
5
+ # Color
6
+ # Colour management with Ruby
7
+ # http://rubyforge.org/projects/color
8
+ # Version 1.4.0
9
+ #
10
+ # Licensed under a MIT-style licence. See Licence.txt in the main
11
+ # distribution for full licensing information.
12
+ #
13
+ # Copyright (c) 2005 - 2007 Austin Ziegler and Matt Lyon
14
+ #
15
+ # $Id: test_all.rb 55 2007-02-03 23:29:34Z austin $
16
+ #++
17
+
18
+ # = Colour Management with Ruby
19
+ module Color
20
+ COLOR_VERSION = '1.4.1.0'
21
+
22
+ class RGB; end
23
+ class CMYK; end
24
+ class GrayScale; end
25
+ class YIQ; end
26
+
27
+ # The maximum "resolution" for colour math; if any value is less than or
28
+ # equal to this value, it is treated as zero.
29
+ COLOR_EPSILON = 1e-5
30
+ # The tolerance for comparing the components of two colours. In general,
31
+ # colours are considered equal if all of their components are within this
32
+ # tolerance value of each other.
33
+ COLOR_TOLERANCE = 1e-4
34
+
35
+ class << self
36
+ # Returns +true+ if the value is less than COLOR_EPSILON.
37
+ def near_zero?(value)
38
+ (value.abs <= COLOR_EPSILON)
39
+ end
40
+
41
+ # Returns +true+ if the value is within COLOR_EPSILON of zero or less than
42
+ # zero.
43
+ def near_zero_or_less?(value)
44
+ (value < 0.0 or near_zero?(value))
45
+ end
46
+
47
+ # Returns +true+ if the value is within COLOR_EPSILON of one.
48
+ def near_one?(value)
49
+ near_zero?(value - 1.0)
50
+ end
51
+
52
+ # Returns +true+ if the value is within COLOR_EPSILON of one or more than
53
+ # one.
54
+ def near_one_or_more?(value)
55
+ (value > 1.0 or near_one?(value))
56
+ end
57
+
58
+ # Normalizes the value to the range (0.0) .. (1.0).
59
+ def normalize(value)
60
+ if near_zero_or_less? value
61
+ 0.0
62
+ elsif near_one_or_more? value
63
+ 1.0
64
+ else
65
+ value
66
+ end
67
+ end
68
+ alias normalize_fractional normalize
69
+
70
+ def normalize_to_range(value, range)
71
+ range = (range.end..range.begin) if (range.end < range.begin)
72
+
73
+ if value <= range.begin
74
+ range.begin
75
+ elsif value >= range.end
76
+ range.end
77
+ else
78
+ value
79
+ end
80
+ end
81
+
82
+ # Normalize the value to the range (0) .. (255).
83
+ def normalize_byte(value)
84
+ normalize_to_range(value, 0..255).to_i
85
+ end
86
+ alias normalize_8bit normalize_byte
87
+
88
+ # Normalize the value to the range (0) .. (65535).
89
+ def normalize_word(value)
90
+ normalize_to_range(value, 0..65535).to_i
91
+ end
92
+ alias normalize_16bit normalize_word
93
+ end
94
+ end
95
+
96
+ require 'color/rgb'
97
+ require 'color/cmyk'
98
+ require 'color/grayscale'
99
+ require 'color/hsl'
100
+ require 'color/yiq'
101
+ require 'color/rgb/metallic'
102
+
103
+ module Color
104
+ def self.const_missing(name) #:nodoc:
105
+ case name
106
+ when "VERSION", :VERSION, "COLOR_TOOLS_VERSION", :COLOR_TOOLS_VERSION
107
+ warn "Color::#{name} has been deprecated. Use Color::COLOR_VERSION instead."
108
+ Color::COLOR_VERSION
109
+ else
110
+ if Color::RGB.const_defined?(name)
111
+ warn "Color::#{name} has been deprecated. Use Color::RGB::#{name} instead."
112
+ Color::RGB.const_get(name)
113
+ else
114
+ super
115
+ end
116
+ end
117
+ end
118
+
119
+ # Provides a thin veneer over the Color module to make it seem like this
120
+ # is Color 0.1.0 (a class) and not Color 1.4.0 (a module). This
121
+ # "constructor" will be removed in the future.
122
+ #
123
+ # mode = :hsl:: +values+ must be an array of [ hue deg, sat %, lum % ].
124
+ # A Color::HSL object will be created.
125
+ # mode = :rgb:: +values+ will either be an HTML-style colour string or
126
+ # an array of [ red, green, blue ] (range 0 .. 255). A
127
+ # Color::RGB object will be created.
128
+ # mode = :cmyk:: +values+ must be an array of [ cyan %, magenta %, yellow
129
+ # %, black % ]. A Color::CMYK object will be created.
130
+ def self.new(values, mode = :rgb)
131
+ warn "Color.new has been deprecated. Use Color::#{mode.to_s.upcase}.new instead."
132
+ color = case mode
133
+ when :hsl
134
+ Color::HSL.new(*values)
135
+ when :rgb
136
+ values = [ values ].flatten
137
+ if values.size == 1
138
+ Color::RGB.from_html(*values)
139
+ else
140
+ Color::RGB.new(*values)
141
+ end
142
+ when :cmyk
143
+ Color::CMYK.new(*values)
144
+ end
145
+ color.to_hsl
146
+ end
147
+ end