rmthemegen 0.0.23 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/README +9 -5
- data/lib/rmthemegen/color/color/cmyk.rb +279 -0
- data/lib/rmthemegen/color/color/css.rb +28 -0
- data/lib/rmthemegen/color/color/grayscale.rb +212 -0
- data/lib/rmthemegen/color/color/hsl.rb +221 -0
- data/lib/rmthemegen/color/color/palette/adobecolor.rb +272 -0
- data/lib/rmthemegen/color/color/palette/gimp.rb +116 -0
- data/lib/rmthemegen/color/color/palette/monocontrast.rb +180 -0
- data/lib/rmthemegen/color/color/palette.rb +16 -0
- data/lib/rmthemegen/color/color/rgb/metallic.rb +43 -0
- data/lib/rmthemegen/color/color/rgb-colors.rb +355 -0
- data/lib/rmthemegen/color/color/rgb.rb +511 -0
- data/lib/rmthemegen/color/color/yiq.rb +84 -0
- data/lib/rmthemegen/color/color.rb +145 -0
- data/lib/rmthemegen/geany_fix.rb +22 -5
- data/lib/rmthemegen/rgb_contrast_methods.rb +5 -4
- data/lib/rmthemegen/version.rb +1 -1
- data/lib/rmthemegen/xmlsimple.rb +1030 -0
- data/license.txt +9 -0
- data/rmthemegen.gemspec +1 -1
- metadata +18 -3
@@ -0,0 +1,145 @@
|
|
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.1
|
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 - 2010 Austin Ziegler and Matt Lyon
|
14
|
+
#++
|
15
|
+
|
16
|
+
# = Colour Management with Ruby
|
17
|
+
module Color
|
18
|
+
COLOR_VERSION = '1.4.1'
|
19
|
+
|
20
|
+
class RGB; end
|
21
|
+
class CMYK; end
|
22
|
+
class GrayScale; end
|
23
|
+
class YIQ; end
|
24
|
+
|
25
|
+
# The maximum "resolution" for colour math; if any value is less than or
|
26
|
+
# equal to this value, it is treated as zero.
|
27
|
+
COLOR_EPSILON = 1e-5
|
28
|
+
# The tolerance for comparing the components of two colours. In general,
|
29
|
+
# colours are considered equal if all of their components are within this
|
30
|
+
# tolerance value of each other.
|
31
|
+
COLOR_TOLERANCE = 1e-4
|
32
|
+
|
33
|
+
class << self
|
34
|
+
# Returns +true+ if the value is less than COLOR_EPSILON.
|
35
|
+
def near_zero?(value)
|
36
|
+
(value.abs <= COLOR_EPSILON)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns +true+ if the value is within COLOR_EPSILON of zero or less than
|
40
|
+
# zero.
|
41
|
+
def near_zero_or_less?(value)
|
42
|
+
(value < 0.0 or near_zero?(value))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns +true+ if the value is within COLOR_EPSILON of one.
|
46
|
+
def near_one?(value)
|
47
|
+
near_zero?(value - 1.0)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns +true+ if the value is within COLOR_EPSILON of one or more than
|
51
|
+
# one.
|
52
|
+
def near_one_or_more?(value)
|
53
|
+
(value > 1.0 or near_one?(value))
|
54
|
+
end
|
55
|
+
|
56
|
+
# Normalizes the value to the range (0.0) .. (1.0).
|
57
|
+
def normalize(value)
|
58
|
+
if near_zero_or_less? value
|
59
|
+
0.0
|
60
|
+
elsif near_one_or_more? value
|
61
|
+
1.0
|
62
|
+
else
|
63
|
+
value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
alias normalize_fractional normalize
|
67
|
+
|
68
|
+
def normalize_to_range(value, range)
|
69
|
+
range = (range.end..range.begin) if (range.end < range.begin)
|
70
|
+
|
71
|
+
if value <= range.begin
|
72
|
+
range.begin
|
73
|
+
elsif value >= range.end
|
74
|
+
range.end
|
75
|
+
else
|
76
|
+
value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Normalize the value to the range (0) .. (255).
|
81
|
+
def normalize_byte(value)
|
82
|
+
normalize_to_range(value, 0..255).to_i
|
83
|
+
end
|
84
|
+
alias normalize_8bit normalize_byte
|
85
|
+
|
86
|
+
# Normalize the value to the range (0) .. (65535).
|
87
|
+
def normalize_word(value)
|
88
|
+
normalize_to_range(value, 0..65535).to_i
|
89
|
+
end
|
90
|
+
alias normalize_16bit normalize_word
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
require File.dirname(__FILE__)+'/color/rgb'
|
95
|
+
require File.dirname(__FILE__)+'/color/cmyk'
|
96
|
+
require File.dirname(__FILE__)+'/color/grayscale'
|
97
|
+
require File.dirname(__FILE__)+'/color/hsl'
|
98
|
+
require File.dirname(__FILE__)+'/color/yiq'
|
99
|
+
require File.dirname(__FILE__)+'/color/rgb/metallic'
|
100
|
+
|
101
|
+
module Color
|
102
|
+
def self.const_missing(name) #:nodoc:
|
103
|
+
case name
|
104
|
+
when "VERSION", :VERSION, "COLOR_TOOLS_VERSION", :COLOR_TOOLS_VERSION
|
105
|
+
warn "Color::#{name} has been deprecated. Use Color::COLOR_VERSION instead."
|
106
|
+
Color::COLOR_VERSION
|
107
|
+
else
|
108
|
+
if Color::RGB.const_defined?(name)
|
109
|
+
warn "Color::#{name} has been deprecated. Use Color::RGB::#{name} instead."
|
110
|
+
Color::RGB.const_get(name)
|
111
|
+
else
|
112
|
+
super
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Provides a thin veneer over the Color module to make it seem like this
|
118
|
+
# is Color 0.1.0 (a class) and not Color 1.4.1 (a module). This
|
119
|
+
# "constructor" will be removed in the future.
|
120
|
+
#
|
121
|
+
# mode = :hsl:: +values+ must be an array of [ hue deg, sat %, lum % ].
|
122
|
+
# A Color::HSL object will be created.
|
123
|
+
# mode = :rgb:: +values+ will either be an HTML-style colour string or
|
124
|
+
# an array of [ red, green, blue ] (range 0 .. 255). A
|
125
|
+
# Color::RGB object will be created.
|
126
|
+
# mode = :cmyk:: +values+ must be an array of [ cyan %, magenta %, yellow
|
127
|
+
# %, black % ]. A Color::CMYK object will be created.
|
128
|
+
def self.new(values, mode = :rgb)
|
129
|
+
warn "Color.new has been deprecated. Use Color::#{mode.to_s.upcase}.new instead."
|
130
|
+
color = case mode
|
131
|
+
when :hsl
|
132
|
+
Color::HSL.new(*values)
|
133
|
+
when :rgb
|
134
|
+
values = [ values ].flatten
|
135
|
+
if values.size == 1
|
136
|
+
Color::RGB.from_html(*values)
|
137
|
+
else
|
138
|
+
Color::RGB.new(*values)
|
139
|
+
end
|
140
|
+
when :cmyk
|
141
|
+
Color::CMYK.new(*values)
|
142
|
+
end
|
143
|
+
color.to_hsl
|
144
|
+
end
|
145
|
+
end
|
data/lib/rmthemegen/geany_fix.rb
CHANGED
@@ -1,8 +1,25 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'xmlsimple'
|
3
|
-
require 'color'
|
1
|
+
#require 'rubygems'
|
2
|
+
#require 'xmlsimple'
|
3
|
+
#require 'color'
|
4
|
+
|
5
|
+
#doing it with local files since these are stable gems and I want geany_fix.rb to function without gem dependencies.
|
6
|
+
|
7
|
+
#***********************************************************************
|
8
|
+
# geany_fix.rb - a utility to create a new, random color theme for the
|
9
|
+
# geany editor. http://www.geany.org/
|
10
|
+
#
|
11
|
+
# Released under an MIT-style license, see license.txt for details
|
12
|
+
#
|
13
|
+
# copyright (c) David Heitzman 2011
|
14
|
+
#
|
15
|
+
#***********************************************************************
|
16
|
+
|
17
|
+
# geany_fix.rb uses a local copy of gems color and xml-simple, in order
|
18
|
+
# ease use as a stand-alone utility.
|
19
|
+
|
4
20
|
require File.dirname(__FILE__)+"/token_list"
|
5
|
-
require File.dirname(__FILE__)+'/
|
21
|
+
require File.dirname(__FILE__)+'/color/color'
|
22
|
+
require File.dirname(__FILE__)+'/xmlsimple.rb'
|
6
23
|
|
7
24
|
module RMThemeGen
|
8
25
|
class GeanyFixer < RMThemeParent
|
@@ -15,7 +32,7 @@ module RMThemeGen
|
|
15
32
|
@iterations = ARGV[0].to_s.to_i
|
16
33
|
|
17
34
|
puts "geany_fix - puts a new (random) color theme into your geany directory"
|
18
|
-
puts " David Heitzman 2011 "
|
35
|
+
puts " copyright (c) David Heitzman 2011 "
|
19
36
|
puts " Note: if you want to put back your old Geany colors, go to ~/.config/geany/filedefs/ and"
|
20
37
|
puts " copy the corresponding _old_xxx file back onto filetypes.xyz, eg. filetypes.html, etc. "
|
21
38
|
puts " Restart geany to see new colors "
|
@@ -1,6 +1,7 @@
|
|
1
|
-
require 'color'
|
1
|
+
#require 'color'
|
2
2
|
|
3
|
-
|
3
|
+
module Color
|
4
|
+
class RGB
|
4
5
|
|
5
6
|
# Outputs how much contrast this color has with another rgb color. Computes the same
|
6
7
|
# regardless of which one is considered foreground.
|
@@ -93,5 +94,5 @@ class Color::RGB
|
|
93
94
|
return y
|
94
95
|
end
|
95
96
|
|
96
|
-
end
|
97
|
-
|
97
|
+
end #class RGB
|
98
|
+
end #module Color
|
data/lib/rmthemegen/version.rb
CHANGED