Module: RbSDL2::Window::Position
- Included in:
- RbSDL2::Window
- Defined in:
- lib/rb_sdl2/window/position.rb
Instance Method Summary collapse
- #position ⇒ Object
- #position=(x_y) ⇒ Object
- #x ⇒ Object
- #x=(num) ⇒ Object
- #y ⇒ Object
- #y=(num) ⇒ Object
Instance Method Details
#position ⇒ Object
4 5 6 7 8 |
# File 'lib/rb_sdl2/window/position.rb', line 4 def position x_y = Array.new(2) { ::FFI::MemoryPointer.new(:int) } ::SDL2.SDL_GetWindowPosition(self, *x_y) x_y.map(&:read_int) end |
#position=(x_y) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rb_sdl2/window/position.rb', line 10 def position=(x_y) wx, wy = x_y wx ||= ::SDL2::SDL_WINDOWPOS_CENTERED_MASK wy ||= ::SDL2::SDL_WINDOWPOS_CENTERED_MASK ::SDL2.SDL_SetWindowPosition(self, wx, wy) end |
#x ⇒ Object
17 18 19 20 21 |
# File 'lib/rb_sdl2/window/position.rb', line 17 def x ptr = ::FFI::MemoryPointer.new(:int) ::SDL2.SDL_GetWindowPosition(self, ptr, nil) ptr.read_int end |
#x=(num) ⇒ Object
23 24 25 |
# File 'lib/rb_sdl2/window/position.rb', line 23 def x=(num) self.position = [num, y] end |
#y ⇒ Object
27 28 29 30 31 |
# File 'lib/rb_sdl2/window/position.rb', line 27 def y ptr = ::FFI::MemoryPointer.new(:int) ::SDL2.SDL_GetWindowPosition(self, nil, ptr) ptr.read_int end |
#y=(num) ⇒ Object
33 34 35 |
# File 'lib/rb_sdl2/window/position.rb', line 33 def y=(num) self.position = [x, num] end |