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
-
#add(object) ⇒ Object
Add an object to the window.
-
#background ⇒ Object
Get the background color.
-
#clear ⇒ Object
Clear all objects from the window.
-
#close ⇒ Object
Close the window.
-
#current ⇒ Object
Get the current window instance.
-
#cursor ⇒ Object
Get the current cursor state.
-
#cursor=(name) ⇒ Object
Set the cursor:
:visible,:hidden, or a system cursor name. -
#delta_time ⇒ Object
Get the most recent frame's delta time, in seconds (clamped to 0.1s).
-
#diagnostics ⇒ Object
Get whether diagnostics are enabled.
-
#display_height ⇒ Object
Get the display height.
-
#display_pixel_height ⇒ Object
Get the display height in physical pixels.
-
#display_pixel_width ⇒ Object
Get the display width in physical pixels.
-
#display_width ⇒ Object
Get the display width.
-
#fps ⇒ Object
Get the current frames per second.
-
#fps_cap ⇒ Object
Get the FPS cap.
-
#frames ⇒ Object
Get the total number of rendered frames.
-
#get(sym) ⇒ Object
Get a window attribute by name.
-
#height ⇒ Object
Get the window height.
-
#highdpi ⇒ Object
Get whether high DPI mode is enabled.
-
#mouse_position ⇒ Object
Get the mouse position as [x, y].
-
#mouse_x ⇒ Object
Get the mouse x position.
-
#mouse_y ⇒ Object
Get the mouse y position.
-
#off(event_descriptor) ⇒ Object
Remove an event handler.
-
#on(event = nil, **filters, &proc) ⇒ Object
Register an event handler.
-
#pixel_scale ⇒ Object
Get the pixel scale.
-
#register_interactive(object) ⇒ Object
Register an interactive object.
-
#remove(object) ⇒ Object
Remove an object from the window.
-
#render(&proc) ⇒ Object
Set the render callback.
-
#render_ready_check ⇒ Object
Check if the window is ready for rendering.
-
#resizable ⇒ Object
Get whether the window is resizable.
-
#screenshot(path = nil) ⇒ Object
Take a screenshot, saving to
path(or a timestamped file if omitted). -
#set(opts) ⇒ Object
Set window attributes.
-
#show ⇒ Object
Show the window.
-
#show_fps ⇒ Object
Get whether FPS display is enabled.
-
#title ⇒ Object
Get the window title.
-
#unregister_interactive(object) ⇒ Object
Unregister an interactive object.
-
#update(&proc) ⇒ Object
Set the update callback.
-
#viewport_height ⇒ Object
Get the viewport height.
-
#viewport_mode ⇒ Object
Get the viewport scaling mode.
-
#viewport_width ⇒ Object
Get the viewport width.
-
#width ⇒ Object
Get the window width.
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 |
#background ⇒ Object
Get the background color
18 19 20 |
# File 'lib/ruby2d/window/class_methods.rb', line 18 def background DSL.window.background end |
#clear ⇒ Object
Clear all objects from the window
175 176 177 |
# File 'lib/ruby2d/window/class_methods.rb', line 175 def clear DSL.window.clear end |
#close ⇒ Object
Close the window
205 206 207 |
# File 'lib/ruby2d/window/class_methods.rb', line 205 def close DSL.window.close end |
#current ⇒ Object
Get the current window instance
8 9 10 |
# File 'lib/ruby2d/window/class_methods.rb', line 8 def current DSL.window end |
#cursor ⇒ Object
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_time ⇒ Object
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 |
#diagnostics ⇒ Object
Get whether diagnostics are enabled
120 121 122 |
# File 'lib/ruby2d/window/class_methods.rb', line 120 def diagnostics DSL.window.diagnostics end |
#display_height ⇒ Object
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_height ⇒ Object
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_width ⇒ Object
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_width ⇒ Object
Get the display width
48 49 50 |
# File 'lib/ruby2d/window/class_methods.rb', line 48 def display_width DSL.window.display_width end |
#fps ⇒ Object
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_cap ⇒ Object
Get the FPS cap
100 101 102 |
# File 'lib/ruby2d/window/class_methods.rb', line 100 def fps_cap DSL.window.fps_cap end |
#frames ⇒ Object
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 |
#height ⇒ Object
Get the window height
28 29 30 |
# File 'lib/ruby2d/window/class_methods.rb', line 28 def height DSL.window.height end |
#highdpi ⇒ Object
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_position ⇒ Object
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_x ⇒ Object
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_y ⇒ Object
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_scale ⇒ Object
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_check ⇒ Object
Check if the window is ready for rendering
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 |
#resizable ⇒ Object
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 |
#show ⇒ Object
Show the window
190 191 192 |
# File 'lib/ruby2d/window/class_methods.rb', line 190 def show DSL.window.show end |
#show_fps ⇒ Object
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 |
#title ⇒ Object
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_height ⇒ Object
Get the viewport height
38 39 40 |
# File 'lib/ruby2d/window/class_methods.rb', line 38 def DSL.window. end |
#viewport_mode ⇒ Object
Get the viewport scaling mode
43 44 45 |
# File 'lib/ruby2d/window/class_methods.rb', line 43 def DSL.window. end |