summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-02-07 00:31:04 -0500
committerrealtradam <[email protected]>2022-02-07 00:31:04 -0500
commita80abe732ceca5691831b0e2c3c1b8c46bf0e759 (patch)
treebf851fbabc86057c2261fcf68a8432a3e1ae2a56 /mrblib
parent5e9d51fee79dcad2c6f0c08c84053fc76f09f8f6 (diff)
downloadmruby-raylib-a80abe732ceca5691831b0e2c3c1b8c46bf0e759.tar.gz
mruby-raylib-a80abe732ceca5691831b0e2c3c1b8c46bf0e759.zip
ColorList now can have an optional alpha value
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/color.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/mrblib/color.rb b/mrblib/color.rb
index 8757abe..346c015 100644
--- a/mrblib/color.rb
+++ b/mrblib/color.rb
@@ -2,7 +2,7 @@ module Raylib
# In addition to creating custom colors, you can call
# any of the default 140 HTML colors(in addition to
- # RayWhite) seen here:
+ # RayWhite and Clear) seen here:
# https://www.w3schools.com/colors/colors_names.asp
#
# When a default color is called it is created once and
@@ -16,19 +16,12 @@ module Raylib
# You can also add custom default colors by adding it to the ColorList hash so that they can be called the same way.
class Color
class << self
- # A fully transparent color.
- # +rgba(0, 0, 0, 0)+
- # The color is cached when this method creates it.
- # @return [Color]
- def clear
- @clear ||= Color.new(0, 0, 0, 0)
- end
# @!visibility private
def color_cache(color)
@color_cache ||= {}
if ColorList[color]
- @color_cache[color] ||= Raylib::Color.new(ColorList[color][:r],ColorList[color][:g],ColorList[color][:b],255)
+ @color_cache[color] ||= Raylib::Color.new(ColorList[color][:r],ColorList[color][:g],ColorList[color][:b],ColorList[color][:a]||255)
else
raise 'Bad Colorname'
end
@@ -59,6 +52,7 @@ module Raylib
# Hash of all web colors
ColorList = {
+ :clear=>{:r=>0, :g=>0, :b=>0, :a=>0},
:ray_white=>{:r=>245, :g=>245, :b=>245},
:alice_blue=>{:r=>0, :g=>15, :b=>143},
:antique_white=>{:r=>0, :g=>174, :b=>189},