From 951ddc08632cf35f246d19248b863ee1c0d1033c Mon Sep 17 00:00:00 2001 From: kawasakikou Date: Wed, 29 Jul 2015 17:54:50 +0900 Subject: [PATCH 1/2] fix set_color_key as error does not occurrence --- lib/dxruby_sdl/image.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/dxruby_sdl/image.rb b/lib/dxruby_sdl/image.rb index 8f65bff..af67b27 100644 --- a/lib/dxruby_sdl/image.rb +++ b/lib/dxruby_sdl/image.rb @@ -39,6 +39,10 @@ def initialize(width, height, color = [0, 0, 0, 0]) @_surface = SDL::Surface.new(SDL::SWSURFACE, width, height, Window.send(:screen)) @_surface.fill_rect(0, 0, width, height, @color) + + if color[3] == 0 + set_color_key(@color[0..2]) + end end def width @@ -51,7 +55,7 @@ def height def set_color_key(color) @_surface.set_color_key(SDL::SRCCOLORKEY | SDL::RLEACCEL, color) - @_surface = @_surface.display_format_alpha + # @_surface = @_surface.display_format_alpha end def compare(x, y, color) From 75928c0dc7932bb06b4ffa45c63467d01277ff89 Mon Sep 17 00:00:00 2001 From: kawasakikou Date: Thu, 30 Jul 2015 13:18:59 +0900 Subject: [PATCH 2/2] Delete display_format_alpha and Add TODO --- lib/dxruby_sdl/image.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dxruby_sdl/image.rb b/lib/dxruby_sdl/image.rb index af67b27..cc9f1b4 100644 --- a/lib/dxruby_sdl/image.rb +++ b/lib/dxruby_sdl/image.rb @@ -40,6 +40,8 @@ def initialize(width, height, color = [0, 0, 0, 0]) SDL::Surface.new(SDL::SWSURFACE, width, height, Window.send(:screen)) @_surface.fill_rect(0, 0, width, height, @color) + # TODO: a値が0の時にしか対応していない。 + # 1から254の値に対応すること if color[3] == 0 set_color_key(@color[0..2]) end @@ -55,7 +57,6 @@ def height def set_color_key(color) @_surface.set_color_key(SDL::SRCCOLORKEY | SDL::RLEACCEL, color) - # @_surface = @_surface.display_format_alpha end def compare(x, y, color)