gdk4 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/COPYING.LIB +502 -0
- data/README.md +58 -0
- data/Rakefile +26 -0
- data/dependency-check/Rakefile +44 -0
- data/gdk4.gemspec +47 -0
- data/lib/gdk4.rb +43 -0
- data/lib/gdk4/cairo.rb +71 -0
- data/lib/gdk4/loader.rb +80 -0
- data/lib/gdk4/rectangle.rb +56 -0
- data/lib/gdk4/rgba.rb +53 -0
- data/lib/gdk4/version.rb +27 -0
- data/lib/gdk4/x11-loader.rb +28 -0
- data/test/fixture/ruby-gnome2-logo.png +0 -0
- data/test/gdk-test-utils.rb +28 -0
- data/test/run-test.rb +42 -0
- data/test/test-gdk-cairo.rb +62 -0
- data/test/test-gdk-cursor.rb +44 -0
- data/test/test-gdk-event-mask.rb +21 -0
- data/test/test-gdk-event-type.rb +25 -0
- data/test/test-gdk-event.rb +698 -0
- data/test/test-gdk-geometry.rb +24 -0
- data/test/test-gdk-keyval.rb +80 -0
- data/test/test-gdk-pixbuf.rb +43 -0
- data/test/test-gdk-rectangle.rb +74 -0
- data/test/test-gdk-rgba.rb +94 -0
- data/test/test-gdk-selection.rb +29 -0
- data/test/test-gdk-window-attr.rb +32 -0
- metadata +113 -0
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Ruby/GDK4
|
2
|
+
|
3
|
+
Ruby/GDK4 is a Ruby binding of GDK 4.
|
4
|
+
https://developer.gnome.org/gdk4/3.90/
|
5
|
+
|
6
|
+
## Requirements
|
7
|
+
|
8
|
+
* Ruby/GLib2, Ruby/ATK, Ruby/Pango and Ruby/GdkPixbuf2 in
|
9
|
+
[Ruby-GNOME2](https://ruby-gnome2.osdn.jp/)
|
10
|
+
* [rcairo](https://github.com/rcairo/rcairo)
|
11
|
+
* [GTK+](https://www.gtk.org/) 3.93 or later
|
12
|
+
|
13
|
+
## Test
|
14
|
+
|
15
|
+
With jhbuild environment:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
#!/bin/bash
|
19
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
20
|
+
|
21
|
+
export GI_TYPELIB_PATH="/home/$USER/jhbuild/install/lib/girepository-1.0"
|
22
|
+
export LD_LIBRARY_PATH="/home/$USER/jhbuild/install/lib"
|
23
|
+
|
24
|
+
if [ $# -eq 0 ]
|
25
|
+
then
|
26
|
+
$DIR/gdk4/test/run-test.rb
|
27
|
+
else
|
28
|
+
$DIR/gdk4/test/run-test.rb -t $1
|
29
|
+
fi
|
30
|
+
```
|
31
|
+
|
32
|
+
Run with:
|
33
|
+
|
34
|
+
```
|
35
|
+
runtest.sh
|
36
|
+
# or
|
37
|
+
runtest.sh TestGdkRectangle
|
38
|
+
```
|
39
|
+
|
40
|
+
## Gtk/Gdk Roadmap
|
41
|
+
|
42
|
+
* https://wiki.gnome.org/Projects/GTK+/Roadmap/GTK4
|
43
|
+
* https://wiki.gnome.org/Projects/GTK+/gdk4
|
44
|
+
|
45
|
+
## Install
|
46
|
+
|
47
|
+
gem install gdk4
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
Copyright (c) 2002-2018 Ruby-GNOME2 Project Team
|
52
|
+
|
53
|
+
This program is free software. You can distribute/modify this program
|
54
|
+
under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
|
55
|
+
|
56
|
+
## Project Website
|
57
|
+
|
58
|
+
https://ruby-gnome2.osdn.jp/
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift("./../glib2/lib")
|
20
|
+
require "gnome2/rake/package-task"
|
21
|
+
|
22
|
+
package_name = File.basename(__dir__)
|
23
|
+
spec = Gem::Specification.load("#{package_name}.gemspec")
|
24
|
+
|
25
|
+
GNOME2::Rake::PackageTask.define(spec, __dir__) do |package|
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (C) 2017-2019 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "pkg-config"
|
18
|
+
require "native-package-installer"
|
19
|
+
|
20
|
+
if File.exist?(File.join(__dir__, "..", "vendor"))
|
21
|
+
task :default => "nothing"
|
22
|
+
else
|
23
|
+
task :default => "dependency:check"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :nothing do
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :dependency do
|
30
|
+
desc "Check dependency"
|
31
|
+
task :check do
|
32
|
+
package_id = "gdk-4.0"
|
33
|
+
unless PKGConfig.check_version?(package_id)
|
34
|
+
unless NativePackageInstaller.install(:altlinux => "libgtk+4-devel",
|
35
|
+
:debian => "libgtk-4-dev",
|
36
|
+
:redhat => "pkgconfig(#{package_id})",
|
37
|
+
:homebrew => "gtk+4",
|
38
|
+
:macports => "gtk4",
|
39
|
+
:msys2 => "gtk4")
|
40
|
+
exit(false)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/gdk4.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2018 Ruby-GNOME Project Team
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
require_relative "../glib2/version"
|
20
|
+
|
21
|
+
Gem::Specification.new do |s|
|
22
|
+
s.name = "gdk4"
|
23
|
+
s.summary = "Ruby/GDK4 is a Ruby binding of GDK-4.x."
|
24
|
+
s.description = "Ruby/GDK4 is a Ruby binding of GDK-4.x."
|
25
|
+
s.author = "The Ruby-GNOME Project Team"
|
26
|
+
s.email = "ruby-gnome2-devel-en@lists.sourceforge.net"
|
27
|
+
s.homepage = "https://ruby-gnome2.osdn.jp/"
|
28
|
+
s.licenses = ["LGPL-2.1+"]
|
29
|
+
s.version = ruby_glib2_version
|
30
|
+
s.extensions = ["dependency-check/Rakefile"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.files = [
|
33
|
+
"COPYING.LIB",
|
34
|
+
"README.md",
|
35
|
+
"Rakefile",
|
36
|
+
"#{s.name}.gemspec",
|
37
|
+
"dependency-check/Rakefile",
|
38
|
+
]
|
39
|
+
s.files += Dir.glob("lib/**/*.rb")
|
40
|
+
s.files += Dir.glob("test/**/*")
|
41
|
+
|
42
|
+
s.add_runtime_dependency("pango", "= #{s.version}")
|
43
|
+
s.add_runtime_dependency("gdk_pixbuf2", "= #{s.version}")
|
44
|
+
s.add_runtime_dependency("cairo-gobject", "= #{s.version}")
|
45
|
+
|
46
|
+
s.metadata["msys2_mingw_dependencies"] = "gtk4"
|
47
|
+
end
|
data/lib/gdk4.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (C) 2013-2018 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "gobject-introspection"
|
18
|
+
require "cairo-gobject"
|
19
|
+
require "atk"
|
20
|
+
require "pango"
|
21
|
+
require "gdk_pixbuf2"
|
22
|
+
|
23
|
+
require "gdk4/loader"
|
24
|
+
require "gdk4/x11-loader"
|
25
|
+
|
26
|
+
module Gdk
|
27
|
+
LOG_DOMAIN = "Gdk"
|
28
|
+
GLib::Log.set_log_domain(LOG_DOMAIN)
|
29
|
+
|
30
|
+
class Error < StandardError
|
31
|
+
end
|
32
|
+
|
33
|
+
loader = Loader.new(self)
|
34
|
+
loader.load
|
35
|
+
x11_loader = X11Loader.new(self)
|
36
|
+
x11_loader.load
|
37
|
+
|
38
|
+
class << self
|
39
|
+
def cairo_available?
|
40
|
+
true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/gdk4/cairo.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (C) 2014-2018 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Cairo
|
18
|
+
class Context
|
19
|
+
alias_method :set_source_rgba_raw, :set_source_rgba
|
20
|
+
def set_source_rgba(rgba, g=nil, b=nil, a=nil)
|
21
|
+
case rgba
|
22
|
+
when Gdk::RGBA
|
23
|
+
set_source_gdk_rgba(rgba)
|
24
|
+
when Array
|
25
|
+
set_source_rgba_raw(rgba)
|
26
|
+
else
|
27
|
+
r = rgba
|
28
|
+
set_source_rgba_raw([r, g, b, a || 1.0])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def source_rgba=(rgba)
|
33
|
+
set_source_rgba(rgba)
|
34
|
+
rgba
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :set_source_pixbuf_raw, :set_source_pixbuf
|
38
|
+
def set_source_pixbuf(pixbuf, pixbuf_x=0, pixbuf_y=0)
|
39
|
+
set_source_pixbuf_raw(pixbuf, pixbuf_x, pixbuf_y)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class Surface
|
44
|
+
alias_method :to_pixbuf_raw, :to_pixbuf
|
45
|
+
def to_pixbuf(options={})
|
46
|
+
src_x = options[:src_x] || 0
|
47
|
+
src_y = options[:src_y] || 0
|
48
|
+
w = options[:width]
|
49
|
+
h = options[:height]
|
50
|
+
if w.nil? and respond_to?(:width)
|
51
|
+
w = width
|
52
|
+
end
|
53
|
+
if h.nil? and respond_to?(:height)
|
54
|
+
h = height
|
55
|
+
end
|
56
|
+
to_pixbuf_raw(src_x, src_y, w, h)
|
57
|
+
end
|
58
|
+
|
59
|
+
extend GLib::Deprecatable
|
60
|
+
|
61
|
+
define_deprecated_method_by_hash_args(:to_pixbuf,
|
62
|
+
"src_x, src_y, width, height",
|
63
|
+
":src_x => 0, " +
|
64
|
+
":src_y => 0, " +
|
65
|
+
":width => width, " +
|
66
|
+
":height => height",
|
67
|
+
0) do |surface, src_x, src_y, w, h|
|
68
|
+
[{:src_x => src_x, :src_y => src_y, :width => w, :height => h}]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/gdk4/loader.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Copyright (C) 2013-2018 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gdk
|
18
|
+
class Loader < GObjectIntrospection::Loader
|
19
|
+
def load
|
20
|
+
self.version = "4.0"
|
21
|
+
super("Gdk")
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def pre_load(repository, namespace)
|
26
|
+
define_version(repository, namespace)
|
27
|
+
end
|
28
|
+
|
29
|
+
def define_version(repository, namespace)
|
30
|
+
major, minor, micro = repository.get_version(namespace).split(".")
|
31
|
+
version_module = Module.new do
|
32
|
+
const_set("MAJOR", Integer(major))
|
33
|
+
const_set("MINOR", Integer(minor))
|
34
|
+
micro = Integer(micro) unless micro.nil?
|
35
|
+
const_set("MICRO", micro)
|
36
|
+
end
|
37
|
+
@base_module.const_set("Version", version_module)
|
38
|
+
end
|
39
|
+
|
40
|
+
def post_load(repository, namespace)
|
41
|
+
require_libraries
|
42
|
+
end
|
43
|
+
|
44
|
+
def require_libraries
|
45
|
+
require "gdk4/cairo"
|
46
|
+
require "gdk4/rectangle"
|
47
|
+
require "gdk4/rgba"
|
48
|
+
require "gdk4/version"
|
49
|
+
end
|
50
|
+
|
51
|
+
def load_function_info(info)
|
52
|
+
name = info.name
|
53
|
+
case name
|
54
|
+
when /\Apixbuf_/
|
55
|
+
target_class = nil
|
56
|
+
case $POSTMATCH
|
57
|
+
when "get_from_surface"
|
58
|
+
target_class = Cairo::Surface
|
59
|
+
end
|
60
|
+
if target_class
|
61
|
+
define_method(info, target_class, "to_pixbuf")
|
62
|
+
else
|
63
|
+
super
|
64
|
+
end
|
65
|
+
when /\Acairo_/
|
66
|
+
name = $POSTMATCH
|
67
|
+
case name
|
68
|
+
when "set_source_rgba"
|
69
|
+
define_method(info, Cairo::Context, "set_source_gdk_rgba")
|
70
|
+
when "rectangle"
|
71
|
+
define_method(info, Cairo::Context, "gdk_rectangle")
|
72
|
+
else
|
73
|
+
define_method(info, Cairo::Context, name)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (C) 2014-2015 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gdk
|
18
|
+
class Rectangle
|
19
|
+
alias_method :initialize_raw, :initialize
|
20
|
+
def initialize(x, y, width, height)
|
21
|
+
initialize_raw
|
22
|
+
self.x = x
|
23
|
+
self.y = y
|
24
|
+
self.width = width
|
25
|
+
self.height = height
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :intersect_raw, :intersect
|
29
|
+
def intersect(other)
|
30
|
+
intersected, dest = intersect_raw(other)
|
31
|
+
if intersected
|
32
|
+
dest
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def inspect
|
39
|
+
super.gsub(/>\z/) do
|
40
|
+
" x=#{x.inspect} y=#{y.inspect} " +
|
41
|
+
"width=#{width.inspect} height=#{height.inspect}>"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_a
|
46
|
+
[x, y, width, height]
|
47
|
+
end
|
48
|
+
|
49
|
+
unless instance_method(:==).owner == self
|
50
|
+
def ==(other)
|
51
|
+
other.is_a?(self.class) and
|
52
|
+
self.to_a == other.to_a
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/gdk4/rgba.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gdk
|
18
|
+
class RGBA
|
19
|
+
class << self
|
20
|
+
def parse(spec)
|
21
|
+
rgba = new
|
22
|
+
unless rgba.parse(spec)
|
23
|
+
available_formats = [
|
24
|
+
"COLOR_NAME",
|
25
|
+
"\#RGB",
|
26
|
+
"\#RRGGBB",
|
27
|
+
"\#RRRGGGBBB",
|
28
|
+
"\#RRRRGGGGBBBB",
|
29
|
+
"rgb(R, G, B)",
|
30
|
+
"rgba(R, G, B, A)",
|
31
|
+
]
|
32
|
+
message = "invalid RGBA format: #{spec.inspect} "
|
33
|
+
message << "(available formats: #{available_formats.join(', ')})"
|
34
|
+
raise ArgumentError, message
|
35
|
+
end
|
36
|
+
rgba
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
alias_method :initialize_raw, :initialize
|
41
|
+
def initialize(red=nil, green=nil, blue=nil, alpha=nil)
|
42
|
+
initialize_raw
|
43
|
+
self.red = red if red
|
44
|
+
self.green = green if green
|
45
|
+
self.blue = blue if blue
|
46
|
+
self.alpha = alpha || 1.0
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_a
|
50
|
+
[red, green, blue, alpha]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|