Module: Ruby2D::Window::ClassMethods

Included in:
Ruby2D::Window
Defined in:
lib/ruby2d/window/class_methods.rb

Overview

Class-level accessors that delegate to the DSL window instance

Instance Method Summary collapse

Instance Method Details

#add(object) ⇒ Object

Add an object to the window



155
156
157
# File 'lib/ruby2d/window/class_methods.rb', line 155

def add(object)
  DSL.window.add(object)
end

#backgroundObject

Get the background color



18
19
20
# File 'lib/ruby2d/window/class_methods.rb', line 18

def background
  DSL.window.background
end

#clearObject

Clear all objects from the window



175
176
177
# File 'lib/ruby2d/window/class_methods.rb', line 175

def clear
  DSL.window.clear
end

#closeObject

Close the window



205
206
207
# File 'lib/ruby2d/window/class_methods.rb', line 205

def close
  DSL.window.close
end

#currentObject

Get the current window instance



8
9
10
# File 'lib/ruby2d/window/class_methods.rb', line 8

def current
  DSL.window
end

#cursorObject

Get the current cursor state



195
196
197
# File 'lib/ruby2d/window/class_methods.rb', line 195

def cursor
  DSL.window.cursor
end

#cursor=(name) ⇒ Object

Set the cursor: :visible, :hidden, or a system cursor name



200
201
202
# File 'lib/ruby2d/window/class_methods.rb', line 200

def cursor=(name)
  DSL.window.cursor = name
end

#delta_timeObject

Get the most recent frame's delta time, in seconds (clamped to 0.1s). The same value passed to an update do |dt| block; the time source every animation advances on.



95
96
97
# File 'lib/ruby2d/window/class_methods.rb', line 95

def delta_time
  DSL.window.delta_time
end

#diagnosticsObject

Get whether diagnostics are enabled



120
121
122
# File 'lib/ruby2d/window/class_methods.rb', line 120

def diagnostics
  DSL.window.diagnostics
end

#display_heightObject

Get the display height



53
54
55
# File 'lib/ruby2d/window/class_methods.rb', line 53

def display_height
  DSL.window.display_height
end

#display_pixel_heightObject

Get the display height in physical pixels



63
64
65
# File 'lib/ruby2d/window/class_methods.rb', line 63

def display_pixel_height
  DSL.window.display_pixel_height
end

#display_pixel_widthObject

Get the display width in physical pixels



58
59
60
# File 'lib/ruby2d/window/class_methods.rb', line 58

def display_pixel_width
  DSL.window.display_pixel_width
end

#display_widthObject

Get the display width



48
49
50
# File 'lib/ruby2d/window/class_methods.rb', line 48

def display_width
  DSL.window.display_width
end

#fpsObject

Get the current frames per second



88
89
90
# File 'lib/ruby2d/window/class_methods.rb', line 88

def fps
  DSL.window.fps
end

#fps_capObject

Get the FPS cap



100
101
102
# File 'lib/ruby2d/window/class_methods.rb', line 100

def fps_cap
  DSL.window.fps_cap
end

#framesObject

Get the total number of rendered frames



83
84
85
# File 'lib/ruby2d/window/class_methods.rb', line 83

def frames
  DSL.window.frames
end

#get(sym) ⇒ Object

Get a window attribute by name



135
136
137
# File 'lib/ruby2d/window/class_methods.rb', line 135

def get(sym)
  DSL.window.get(sym)
end

#heightObject

Get the window height



28
29
30
# File 'lib/ruby2d/window/class_methods.rb', line 28

def height
  DSL.window.height
end

#highdpiObject

Get whether high DPI mode is enabled



73
74
75
# File 'lib/ruby2d/window/class_methods.rb', line 73

def highdpi
  DSL.window.highdpi
end

#mouse_positionObject

Get the mouse position as [x, y]



115
116
117
# File 'lib/ruby2d/window/class_methods.rb', line 115

def mouse_position
  DSL.window.mouse_position
end

#mouse_xObject

Get the mouse x position



105
106
107
# File 'lib/ruby2d/window/class_methods.rb', line 105

def mouse_x
  DSL.window.mouse_x
end

#mouse_yObject

Get the mouse y position



110
111
112
# File 'lib/ruby2d/window/class_methods.rb', line 110

def mouse_y
  DSL.window.mouse_y
end

#off(event_descriptor) ⇒ Object

Remove an event handler



150
151
152
# File 'lib/ruby2d/window/class_methods.rb', line 150

def off(event_descriptor)
  DSL.window.off(event_descriptor)
end

#on(event = nil, **filters, &proc) ⇒ Object

Register an event handler



145
146
147
# File 'lib/ruby2d/window/class_methods.rb', line 145

def on(event = nil, **filters, &proc)
  DSL.window.on(event, **filters, &proc)
end

#pixel_scaleObject

Get the pixel scale



78
79
80
# File 'lib/ruby2d/window/class_methods.rb', line 78

def pixel_scale
  DSL.window.pixel_scale
end

#register_interactive(object) ⇒ Object

Register an interactive object



165
166
167
# File 'lib/ruby2d/window/class_methods.rb', line 165

def register_interactive(object)
  DSL.window.register_interactive(object)
end

#remove(object) ⇒ Object

Remove an object from the window



160
161
162
# File 'lib/ruby2d/window/class_methods.rb', line 160

def remove(object)
  DSL.window.remove(object)
end

#render(&proc) ⇒ Object

Set the render callback



185
186
187
# File 'lib/ruby2d/window/class_methods.rb', line 185

def render(&proc)
  DSL.window.render(&proc)
end

#render_ready_checkObject

Check if the window is ready for rendering

Raises:



210
211
212
213
214
215
# File 'lib/ruby2d/window/class_methods.rb', line 210

def render_ready_check
  return if shown?

  raise Error,
        'Attempting to draw before the window is ready. Please put calls to render() inside of a render block.'
end

#resizableObject

Get whether the window is resizable



68
69
70
# File 'lib/ruby2d/window/class_methods.rb', line 68

def resizable
  DSL.window.resizable
end

#screenshot(path = nil) ⇒ Object

Take a screenshot, saving to path (or a timestamped file if omitted)



130
131
132
# File 'lib/ruby2d/window/class_methods.rb', line 130

def screenshot(path = nil)
  DSL.window.screenshot(path)
end

#set(opts) ⇒ Object

Set window attributes



140
141
142
# File 'lib/ruby2d/window/class_methods.rb', line 140

def set(opts)
  DSL.window.set(opts)
end

#showObject

Show the window



190
191
192
# File 'lib/ruby2d/window/class_methods.rb', line 190

def show
  DSL.window.show
end

#show_fpsObject

Get whether FPS display is enabled



125
126
127
# File 'lib/ruby2d/window/class_methods.rb', line 125

def show_fps
  DSL.window.show_fps
end

#titleObject

Get the window title



13
14
15
# File 'lib/ruby2d/window/class_methods.rb', line 13

def title
  DSL.window.title
end

#unregister_interactive(object) ⇒ Object

Unregister an interactive object



170
171
172
# File 'lib/ruby2d/window/class_methods.rb', line 170

def unregister_interactive(object)
  DSL.window.unregister_interactive(object)
end

#update(&proc) ⇒ Object

Set the update callback



180
181
182
# File 'lib/ruby2d/window/class_methods.rb', line 180

def update(&proc)
  DSL.window.update(&proc)
end

#viewport_heightObject

Get the viewport height



38
39
40
# File 'lib/ruby2d/window/class_methods.rb', line 38

def viewport_height
  DSL.window.viewport_height
end

#viewport_modeObject

Get the viewport scaling mode



43
44
45
# File 'lib/ruby2d/window/class_methods.rb', line 43

def viewport_mode
  DSL.window.viewport_mode
end

#viewport_widthObject

Get the viewport width



33
34
35
# File 'lib/ruby2d/window/class_methods.rb', line 33

def viewport_width
  DSL.window.viewport_width
end

#widthObject

Get the window width



23
24
25
# File 'lib/ruby2d/window/class_methods.rb', line 23

def width
  DSL.window.width
end