color-tools 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +4 -0
- data/Install +1 -1
- data/README +6 -7
- data/Rakefile +8 -11
- data/lib/color.rb +1 -1
- data/lib/color/palette/gimp.rb +72 -0
- metadata +6 -4
data/Changelog
CHANGED
data/Install
CHANGED
data/README
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
color-tools README
|
2
|
-
==================
|
1
|
+
= color-tools README
|
3
2
|
color-tools is a Ruby library to provide RGB and CMYK colour support to
|
4
3
|
applications that require it. It provides 148 named RGB colours that are
|
5
4
|
commonly supported and used in HTML, colour manipulation operations, and
|
6
|
-
a monochromatic contrasting palette generator.
|
5
|
+
a monochromatic contrasting palette generator. With version 1.1, the
|
6
|
+
ability to read and use GIMP colour palette definition files has been
|
7
|
+
added.
|
7
8
|
|
8
|
-
Copyright
|
9
|
-
=========
|
9
|
+
== Copyright
|
10
10
|
Copyright 2005 by Austin Ziegler
|
11
11
|
|
12
12
|
Color::RGB and Color::CMYK were originally developed for the Ruby PDF
|
@@ -16,8 +16,7 @@ Color::Palette was developed based on techniques described by Andy
|
|
16
16
|
"Malarkey" Clarke[1], implemented in JavaScript by Steve G. Chipman at
|
17
17
|
SlayerOffice[2] and by Patrick Fitzgerald of BarelyFitz[3] in PHP.
|
18
18
|
|
19
|
-
Licence
|
20
|
-
=======
|
19
|
+
== Licence
|
21
20
|
Permission is hereby granted, free of charge, to any person obtaining a
|
22
21
|
copy of this software and associated documentation files (the "Soft-
|
23
22
|
ware"), to deal in the Software without restriction, including without
|
data/Rakefile
CHANGED
@@ -100,17 +100,14 @@ file TARDIST => [ :test ] do |t|
|
|
100
100
|
end
|
101
101
|
task TARDIST => [ :test ]
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
task :signgem => [ :gem ] do
|
112
|
-
sign "../#{DISTDIR}.gem"
|
103
|
+
desc "Build the rdoc documentation for color-tools"
|
104
|
+
task :docs do
|
105
|
+
require 'rdoc/rdoc'
|
106
|
+
rdoc_options = %w(--title color-tools --main README --line-numbers)
|
107
|
+
files = FileList[*%w(README Changelog bin/**/*.rb lib/**/*.rb)]
|
108
|
+
rdoc_options += files.to_a
|
109
|
+
RDoc::RDoc.new.document(rdoc_options)
|
113
110
|
end
|
114
111
|
|
115
112
|
desc "Build everything."
|
116
|
-
task :default => [ :
|
113
|
+
task :default => [ :tar, :gem ]
|
data/lib/color.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
#--
|
2
|
+
# Colour management with Ruby.
|
3
|
+
#
|
4
|
+
# Copyright 2005 Austin Ziegler
|
5
|
+
# http://rubyforge.org/ruby-pdf/
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'color/palette'
|
9
|
+
|
10
|
+
class Color::Palette::Gimp
|
11
|
+
include Enumerable
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def from_file(filename)
|
15
|
+
File.open(filename, "rb") { |io| Color::Palette::Gimp.from_io(io) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def from_io(io)
|
19
|
+
Color::Palette::Gimp.new(io.read)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(palette)
|
24
|
+
@colors = {}
|
25
|
+
@valid = false
|
26
|
+
@name = "(unnamed)"
|
27
|
+
|
28
|
+
index = 0
|
29
|
+
collision = {}
|
30
|
+
|
31
|
+
palette.split($/).each do |line|
|
32
|
+
line.chomp!
|
33
|
+
line.gsub!(/\s*#.*\Z/, '')
|
34
|
+
|
35
|
+
next if line.empty?
|
36
|
+
|
37
|
+
if line =~ /\AGIMP Palette\Z/
|
38
|
+
@valid = true
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
info = /(\w+):\s(.*$)/.match(line)
|
43
|
+
if info
|
44
|
+
@name = info.captures[1] if info.captures[0] =~ /name/i
|
45
|
+
next
|
46
|
+
end
|
47
|
+
|
48
|
+
line.gsub!(/^\s+/, '')
|
49
|
+
data = line.split(/\s+/, 4)
|
50
|
+
name = data.pop
|
51
|
+
data.map! { |el| el.to_i }
|
52
|
+
|
53
|
+
@colors[index] = Color::RGB.new(*data)
|
54
|
+
|
55
|
+
if @colors.has_key?(name)
|
56
|
+
collision[name] = true
|
57
|
+
else
|
58
|
+
@colors[name] = @colors[index]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
collision.each_key { |key| @colors.delete_at(key) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def [](key)
|
66
|
+
@colors[key]
|
67
|
+
end
|
68
|
+
|
69
|
+
def each
|
70
|
+
@colors.each { |el| yield el }
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: color-tools
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2005-05-04
|
8
8
|
summary: color-tools provides RGB and CMYK colour definitions and manpiulations.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -14,7 +14,8 @@ rubyforge_project: ruby-pdf
|
|
14
14
|
description: "color-tools is a Ruby library to provide RGB and CMYK colour support to
|
15
15
|
applications that require it. It provides 148 named RGB colours that are
|
16
16
|
commonly supported and used in HTML, colour manipulation operations, and a
|
17
|
-
monochromatic contrasting palette generator.
|
17
|
+
monochromatic contrasting palette generator. With version 1.1, the ability to
|
18
|
+
read and use GIMP colour palette definition files has been added."
|
18
19
|
autorequire: color
|
19
20
|
default_executable:
|
20
21
|
bindir: bin
|
@@ -41,6 +42,7 @@ files:
|
|
41
42
|
- lib/color/palette
|
42
43
|
- lib/color/palette.rb
|
43
44
|
- lib/color/rgb.rb
|
45
|
+
- lib/color/palette/gimp.rb
|
44
46
|
- lib/color/palette/monocontrast.rb
|
45
47
|
test_files: []
|
46
48
|
rdoc_options:
|