Module: RbSDL2::Surface::BlendMode

Included in:
RbSDL2::Surface
Defined in:
lib/rb_sdl2/surface/blend_mode.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_name(num) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 17

def to_name(num)
  case num
  when ::SDL::BLENDMODE_ADD then "additive"
  when ::SDL::BLENDMODE_BLEND then "alpha"
  when ::SDL::BLENDMODE_MOD then "modulate"
  when ::SDL::BLENDMODE_MUL then "multiply"
  when ::SDL::BLENDMODE_NONE then "normal"
  else
    ""
  end
end

.to_num(obj) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 5

def to_num(obj)
  case obj
  when /\Aadd/ then ::SDL::BLENDMODE_ADD
  when /\Aalpha/, /\Ablend/ then ::SDL::BLENDMODE_BLEND
  when /\Amod/ then ::SDL::BLENDMODE_MOD
  when /\Amul/ then ::SDL::BLENDMODE_MUL
  when /\Anone/, /\Anormal/ then ::SDL::BLENDMODE_NONE
  else
    obj.to_i
  end
end

Instance Method Details

#additive_blend_mode?Boolean

Returns:

  • (Boolean)


30
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 30

def additive_blend_mode? = ::SDL::BLENDMODE_ADD == blend_mode

#alpha_blend_mode?Boolean

Returns:

  • (Boolean)


32
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 32

def alpha_blend_mode? = ::SDL::BLENDMODE_BLEND == blend_mode

#modulate_blend_mode?Boolean

Returns:

  • (Boolean)


34
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 34

def modulate_blend_mode? = ::SDL::BLENDMODE_MOD == blend_mode

#multiply_blend_mode?Boolean

Returns:

  • (Boolean)


36
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 36

def multiply_blend_mode? = ::SDL::BLENDMODE_MUL == blend_mode

#normal_blend_mode?Boolean

Returns:

  • (Boolean)


38
# File 'lib/rb_sdl2/surface/blend_mode.rb', line 38

def normal_blend_mode? = ::SDL::BLENDMODE_NONE == blend_mode