redgreenblue 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redgreenblue/24bit.rb +29 -12
- data/lib/redgreenblue/48bit.rb +19 -2
- data/lib/redgreenblue/base.rb +15 -1
- data/lib/redgreenblue/bgr24bit.rb +19 -2
- data/lib/redgreenblue/cie_1931.rb +4 -4
- data/lib/redgreenblue/cie_1976.rb +7 -7
- data/lib/redgreenblue/cie_1994.rb +1 -1
- data/lib/redgreenblue/gamma.rb +1 -1
- data/lib/redgreenblue/gif.rb +1 -1
- data/lib/redgreenblue/gpl.rb +48 -31
- data/lib/redgreenblue/hex.rb +39 -24
- data/lib/redgreenblue/hsb.rb +18 -3
- data/lib/redgreenblue/hsl.rb +21 -4
- data/lib/redgreenblue/hsv.rb +21 -4
- data/lib/redgreenblue/hsx_shared.rb +1 -1
- data/lib/redgreenblue/hwb.rb +1 -1
- data/lib/redgreenblue/inspect.rb +36 -24
- data/lib/redgreenblue/int.rb +19 -2
- data/lib/redgreenblue/lazy.rb +84 -10
- data/lib/redgreenblue/mac.rb +1 -1
- data/lib/redgreenblue/match.rb +1 -1
- data/lib/redgreenblue/math.rb +1 -1
- data/lib/redgreenblue/misc.rb +25 -8
- data/lib/redgreenblue/mix.rb +6 -6
- data/lib/redgreenblue/name.rb +1 -1
- data/lib/redgreenblue/opt/philipshue.rb +3 -3
- data/lib/redgreenblue/os/mac.rb +23 -6
- data/lib/redgreenblue/ostwald.rb +3 -3
- data/lib/redgreenblue/random.rb +21 -4
- data/lib/redgreenblue/rgb565.rb +19 -2
- data/lib/redgreenblue/terminal.rb +1 -1
- data/lib/redgreenblue/version.rb +2 -2
- data/lib/redgreenblue/view.rb +2 -2
- data/lib/redgreenblue/web.rb +56 -52
- data/lib/redgreenblue.rb +20 -1
- metadata +3 -3
data/lib/redgreenblue/web.rb
CHANGED
@@ -1,55 +1,4 @@
|
|
1
|
-
class RGB
|
2
|
-
|
3
|
-
#----------------------------------------------------------------------#
|
4
|
-
# Class Methods #
|
5
|
-
#----------------------------------------------------------------------#
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
# Returns CSS named colors, as per CSS Color Module Level 4.
|
10
|
-
#
|
11
|
-
# Optional selector argument can be:
|
12
|
-
# - String or Regexp (to select by name)
|
13
|
-
# - RGB color (to select by color)
|
14
|
-
# - Integer (to select by index).
|
15
|
-
# Selection by name (string or regular expression) is case-insensitive by default.
|
16
|
-
#
|
17
|
-
# @example No Selector
|
18
|
-
# # All colors
|
19
|
-
# RGB.css
|
20
|
-
#
|
21
|
-
# # Pastels
|
22
|
-
# RGB.css.select { |c| c.ostwald_cwk[1] > 0.6 }
|
23
|
-
# @example Select by Name
|
24
|
-
# # Exact name
|
25
|
-
# RGB.css 'pink'
|
26
|
-
#
|
27
|
-
# # Regular expression
|
28
|
-
# RGB.css /pink|rose/
|
29
|
-
#
|
30
|
-
# @example Select by RGB color
|
31
|
-
# RGB.css RGB.hex('0ff')
|
32
|
-
def css(selector=nil)
|
33
|
-
@@css ||= load_gpl file: ( File.join File.dirname(__FILE__), 'palettes', 'css.gpl' ), freeze: true
|
34
|
-
case selector
|
35
|
-
when NilClass
|
36
|
-
@@css
|
37
|
-
when String
|
38
|
-
n = selector.downcase
|
39
|
-
@@css.select { |c| c.name == n }.first
|
40
|
-
when Regexp
|
41
|
-
r = Regexp.new selector.source, Regexp::IGNORECASE
|
42
|
-
@@css.select { |c| c.name =~ r }
|
43
|
-
when Integer
|
44
|
-
@@css[selector]
|
45
|
-
when self
|
46
|
-
@@css.select { |c| c == selector }
|
47
|
-
else
|
48
|
-
raise ArgumentError, 'Unsupported selector'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
1
|
+
class RGB::Color
|
53
2
|
|
54
3
|
#----------------------------------------------------------------------#
|
55
4
|
# Instance Methods #
|
@@ -112,3 +61,58 @@ class RGB
|
|
112
61
|
end
|
113
62
|
|
114
63
|
end
|
64
|
+
|
65
|
+
#----------------------------------------------------------------------#
|
66
|
+
# Module Methods #
|
67
|
+
#----------------------------------------------------------------------#
|
68
|
+
|
69
|
+
module RGB
|
70
|
+
|
71
|
+
class << self
|
72
|
+
|
73
|
+
# Returns CSS named colors, as per CSS Color Module Level 4.
|
74
|
+
#
|
75
|
+
# Optional selector argument can be:
|
76
|
+
# - String or Regexp (to select by name)
|
77
|
+
# - RGB color (to select by color)
|
78
|
+
# - Integer (to select by index).
|
79
|
+
# Selection by name (string or regular expression) is case-insensitive by default.
|
80
|
+
#
|
81
|
+
# @example No Selector
|
82
|
+
# # All colors
|
83
|
+
# RGB.css
|
84
|
+
#
|
85
|
+
# # Pastels
|
86
|
+
# RGB.css.select { |c| c.ostwald_cwk[1] > 0.6 }
|
87
|
+
# @example Select by Name
|
88
|
+
# # Exact name
|
89
|
+
# RGB.css 'pink'
|
90
|
+
#
|
91
|
+
# # Regular expression
|
92
|
+
# RGB.css /pink|rose/
|
93
|
+
#
|
94
|
+
# @example Select by RGB color
|
95
|
+
# RGB.css RGB.hex('0ff')
|
96
|
+
def css(selector=nil)
|
97
|
+
@@css ||= load_gpl file: ( File.join File.dirname(__FILE__), 'palettes', 'css.gpl' ), freeze: true
|
98
|
+
case selector
|
99
|
+
when NilClass
|
100
|
+
@@css
|
101
|
+
when String
|
102
|
+
n = selector.downcase
|
103
|
+
@@css.select { |c| c.name == n }.first
|
104
|
+
when Regexp
|
105
|
+
r = Regexp.new selector.source, Regexp::IGNORECASE
|
106
|
+
@@css.select { |c| c.name =~ r }
|
107
|
+
when Integer
|
108
|
+
@@css[selector]
|
109
|
+
when RGB::Color
|
110
|
+
@@css.select { |c| c == selector }
|
111
|
+
else
|
112
|
+
raise ArgumentError, 'Unsupported selector'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
data/lib/redgreenblue.rb
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
|
1
|
+
# The RGB module is the main namespace for redgreenblue.
|
2
|
+
#
|
3
|
+
# This module has many helper methods for creating RGB::Color objects.
|
4
|
+
# The example below shows seven ways to create an RGB::Color object for the exact same color.
|
5
|
+
# @example
|
6
|
+
# require 'redgreenblue'
|
7
|
+
#
|
8
|
+
# pink = RGB.new(1, 0.6, 0.8)
|
9
|
+
# pink = RGB.rgb(255, 153, 204)
|
10
|
+
# pink = RGB.rrggbb(65535, 39321, 52428)
|
11
|
+
# pink = RGB.hex('f9c')
|
12
|
+
# pink = RGB.hsl(330, 1, 0.8)
|
13
|
+
# pink = RGB.hsv(330, 0.4, 1)
|
14
|
+
# pink = RGB.at(16751052)
|
15
|
+
module RGB
|
16
|
+
|
17
|
+
# This class represents an RGB color.
|
18
|
+
class Color
|
19
|
+
end
|
20
|
+
|
2
21
|
end
|
3
22
|
|
4
23
|
%w(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redgreenblue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lllist.eu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.3.11
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: A simple Ruby library for handling RGB colors.
|