solargraph-dragonruby 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +56 -0
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/LICENSE.txt +21 -0
  5. data/NOTICE +8 -0
  6. data/README.md +185 -0
  7. data/Rakefile +13 -0
  8. data/lib/solargraph/dragonruby/convention.rb +43 -0
  9. data/lib/solargraph/dragonruby/macro_node.rb +44 -0
  10. data/lib/solargraph/dragonruby/version.rb +7 -0
  11. data/lib/solargraph/dragonruby.rb +15 -0
  12. data/lib/solargraph-dragonruby.rb +5 -0
  13. data/sig/solargraph/dragonruby.rbs +19 -0
  14. data/stubs/extensions/README.md +20 -0
  15. data/stubs/extensions/args.rb +91 -0
  16. data/stubs/extensions/array.rb +25 -0
  17. data/stubs/extensions/attr.rb +249 -0
  18. data/stubs/extensions/easing.rb +90 -0
  19. data/stubs/extensions/entity.rb +63 -0
  20. data/stubs/extensions/geometry.rb +528 -0
  21. data/stubs/extensions/grid.rb +247 -0
  22. data/stubs/extensions/inputs.rb +678 -0
  23. data/stubs/extensions/layout.rb +175 -0
  24. data/stubs/extensions/log.rb +158 -0
  25. data/stubs/extensions/main.rb +63 -0
  26. data/stubs/extensions/numeric.rb +395 -0
  27. data/stubs/extensions/outputs.rb +132 -0
  28. data/stubs/extensions/runtime.rb +436 -0
  29. data/stubs/extensions/string.rb +85 -0
  30. data/stubs/extensions/typing.rb +193 -0
  31. data/stubs/extensions/zlib.rb +24 -0
  32. data/stubs/upstream/LICENSE.txt +21 -0
  33. data/stubs/upstream/UPSTREAM +2 -0
  34. data/stubs/upstream/args.rb +61 -0
  35. data/stubs/upstream/constants.rb +8 -0
  36. data/stubs/upstream/controller.rb +90 -0
  37. data/stubs/upstream/easing.rb +119 -0
  38. data/stubs/upstream/geometry.rb +430 -0
  39. data/stubs/upstream/globals.rb +17 -0
  40. data/stubs/upstream/gtk.rb +476 -0
  41. data/stubs/upstream/inputs.rb +286 -0
  42. data/stubs/upstream/kernel.rb +7 -0
  43. data/stubs/upstream/keyboard.rb +38 -0
  44. data/stubs/upstream/layout.rb +32 -0
  45. data/stubs/upstream/numeric.rb +82 -0
  46. data/stubs/upstream/outputs.rb +55 -0
  47. data/stubs/upstream/outputs_array.rb +4 -0
  48. data/stubs/upstream/phantom_types.rb +25 -0
  49. data/stubs/upstream/toplevel.rb +13 -0
  50. metadata +107 -0
@@ -0,0 +1,395 @@
1
+ class Numeric
2
+ # Treating self as the tick an animation started, returns a Hash describing
3
+ # the current frame: `frame_index`, `frame_count`, `frames_left`, `started`,
4
+ # `completed`, `elapsed_time`, `frame_elapsed_time`, `duration`.
5
+ # Takes the same arguments as #frame_index.
6
+ #
7
+ # @return [Typing::FrameHash]
8
+ def frame *args, **kwargs; end
9
+
10
+ # Treating self as the tick an animation started, returns the index of the
11
+ # sprite to show, or `nil` when the animation is out of bounds.
12
+ #
13
+ # @example positional
14
+ # 0.frame_index 6, 4, true
15
+ # @example named (also `Numeric.frame_index start_at: 0, ...`)
16
+ # 0.frame_index count: 6, hold_for: 4, repeat: true, repeat_index: 0
17
+ #
18
+ # @return [Integer, nil]
19
+ def frame_index *args, **kwargs; end
20
+
21
+ # @param tick_count_override [Integer, nil] used instead of `Kernel.tick_count`
22
+ # @return [Integer] frames elapsed since self
23
+ def elapsed_time tick_count_override = nil; end
24
+
25
+ # @param offset [Integer] added to self before comparing
26
+ # @return [Boolean] true if #elapsed_time is greater than self (+ offset)
27
+ def elapsed? offset = 0; end
28
+
29
+ # @return [String] "string float" with two decimal places (`5.8778` => `"5.88"`)
30
+ # @param decimal_places [Integer]
31
+ # @param include_sign [Boolean] prefix positive numbers with `+`
32
+ def to_sf decimal_places: 2, include_sign: false; end
33
+
34
+ # @return [String] "string int" with `_` thousands separators (`50000.8778` => `"50_000"`)
35
+ def to_si; end
36
+
37
+ # @return [Float] x component of the vector for self as an angle in degrees
38
+ # @param max_value [Numeric] length of the vector
39
+ def vector_x max_value = 1; end
40
+
41
+ # @return [Float] y component of the vector for self as an angle in degrees
42
+ # @param max_value [Numeric] length of the vector
43
+ def vector_y max_value = 1; end
44
+
45
+ # @return [Float] x component of the vector for self as an angle in radians
46
+ # @param max_value [Numeric] length of the vector
47
+ def vector_x_r max_value = 1; end
48
+
49
+ # @return [Float] y component of the vector for self as an angle in radians
50
+ # @param max_value [Numeric] length of the vector
51
+ def vector_y_r max_value = 1; end
52
+
53
+ # @param other [Numeric]
54
+ # @return [Integer] integer division (`5.0.idiv(3)` => `1`)
55
+ def idiv other; end
56
+
57
+ # @param other [Numeric]
58
+ # @return [Boolean] true if `self % other == 0`
59
+ def zmod? other; end
60
+
61
+ # @return [Float] self (degrees) converted to radians
62
+ def to_radians; end
63
+
64
+ # @return [Float] self (radians) converted to degrees
65
+ def to_degrees; end
66
+
67
+ # Returns self, `l`, or `r`, whichever keeps the value within `l..r`
68
+ # (in either order). Either bound may be omitted or `nil`.
69
+ #
70
+ # @example
71
+ # 10.mid(0, 5) # => 5
72
+ # 10.mid(l: 0, r: 5) # => 5
73
+ # 10.mid(r: 5) # => 5
74
+ #
75
+ # @return [Numeric]
76
+ def mid *lr, l: nil, r: nil; end
77
+
78
+ # Takes the same arguments as #mid.
79
+ #
80
+ # @return [Boolean] true if self is within `l..r` (in either order)
81
+ def mid? *lr, l: nil, r: nil; end
82
+
83
+ # Same as #mid?: unlike Comparable#between?, the bounds may be in either
84
+ # order, omitted, or named.
85
+ #
86
+ # @return [Boolean]
87
+ def between? *lr, l: nil, r: nil; end
88
+
89
+ # @example
90
+ # 10.min(5) # => 5
91
+ #
92
+ # @param n [Numeric, nil]
93
+ # @return [Numeric] the smaller of self and `n` (self if `n` is `nil`)
94
+ def min n = nil; end
95
+
96
+ # @example
97
+ # 0.max(5) # => 5
98
+ #
99
+ # @param n [Numeric, nil]
100
+ # @return [Numeric] the larger of self and `n` (self if `n` is `nil`)
101
+ def max n = nil; end
102
+
103
+ # @param max_value [Numeric] length of the vector
104
+ # @return [Typing::PointHash] `{ x:, y: }` vector for self as an angle in degrees
105
+ def to_vector max_value = 1; end
106
+
107
+ # @param max_value [Numeric] length of the vector
108
+ # @return [Typing::PointHash] `{ x:, y: }` vector for self as an angle in radians
109
+ def to_vector_r max_value = 1; end
110
+
111
+ # @return [Float] self / 2.0
112
+ def half; end
113
+
114
+ # @return [Float] self / 3.0
115
+ def third; end
116
+
117
+ # @return [Float] self / 4.0
118
+ def quarter; end
119
+
120
+ # Randomizes self. Options: `:ratio` (or `:float`) for a random float in
121
+ # `0...self`, `:int` for a random integer in `0...self`, and `:sign` to
122
+ # randomly negate. `:sign` combines with either of the others.
123
+ #
124
+ # @example
125
+ # 10.randomize(:ratio, :sign) # => a float between -10 and 10
126
+ #
127
+ # @param definitions [Array<Symbol>]
128
+ # @return [Numeric]
129
+ def randomize *definitions; end
130
+
131
+ # @return [Integer] `-1` or `1`, at random
132
+ def rand_sign; end
133
+
134
+ # @return [Float] self multiplied by a random float in `0...1`
135
+ def rand_ratio; end
136
+
137
+ # @return [Integer] `-1`, `0`, or `1`
138
+ def sign; end
139
+
140
+ # @param int [Integer]
141
+ # @return [Integer] self floored to a multiple of `int` (`17.ifloor(5)` => `15`)
142
+ def ifloor int; end
143
+
144
+ # @return [Float] sine of self in degrees
145
+ def sin; end
146
+
147
+ # @return [Float] sine of self in degrees
148
+ def sin_d; end
149
+
150
+ # @return [Float] sine of self in radians
151
+ def sin_r; end
152
+
153
+ # @return [Float] cosine of self in degrees
154
+ def cos; end
155
+
156
+ # @return [Float] cosine of self in degrees
157
+ def cos_d; end
158
+
159
+ # @return [Float] cosine of self in radians
160
+ def cos_r; end
161
+
162
+ # @return [Float] tangent of self in degrees
163
+ def tan; end
164
+
165
+ # @return [Float] tangent of self in degrees
166
+ def tan_d; end
167
+
168
+ # @return [Float] tangent of self in radians
169
+ def tan_r; end
170
+
171
+ # Moves self toward `target` by `magnitude`, without overshooting.
172
+ #
173
+ # @param target [Numeric]
174
+ # @param magnitude [Numeric]
175
+ # @return [Numeric]
176
+ def towards target, magnitude; end
177
+
178
+ # @param n [Numeric]
179
+ # @return [Float] self / n, clamped to `0..1`
180
+ def percentage_of n; end
181
+
182
+ # @param i [Numeric]
183
+ # @return [Numeric] self, but no greater than `i`
184
+ def cap i; end
185
+
186
+ # @param min [Numeric]
187
+ # @param max [Numeric]
188
+ # @return [Numeric] self clamped to `min..max`
189
+ def cap_min_max min, max; end
190
+
191
+ # @param n [Numeric]
192
+ # @return [Numeric] self % n
193
+ def mod n; end
194
+
195
+ # @param ns [Array<Numeric>]
196
+ # @return [Boolean] true if self is a multiple of any of `ns`
197
+ def mod_zero? *ns; end
198
+
199
+ # Same as #max.
200
+ # @param n [Numeric, nil]
201
+ # @return [Numeric]
202
+ def greater n = nil; end
203
+
204
+ # Same as #min.
205
+ # @param n [Numeric, nil]
206
+ # @return [Numeric]
207
+ def lesser n = nil; end
208
+
209
+ # @return [Numeric] `Grid.top - self`
210
+ def from_top; end
211
+
212
+ # @return [Numeric] `Grid.bottom + self`
213
+ def from_bottom; end
214
+
215
+ # @return [Numeric] `Grid.left + self`
216
+ def from_left; end
217
+
218
+ # @return [Numeric] `Grid.right - self`
219
+ def from_right; end
220
+
221
+ # Treating self as a start tick, #elapsed_time as a percentage of `duration`.
222
+ #
223
+ # @param duration [Integer]
224
+ # @return [Float] `0.0` to `1.0`
225
+ def elapsed_time_percent duration; end
226
+
227
+ # @param tick_count_override [Integer, nil]
228
+ # @return [Boolean] true if self is the current tick
229
+ def new? tick_count_override; end
230
+
231
+ # Treating self as a start tick, Easing.ease progress for `duration`.
232
+ #
233
+ # @example
234
+ # percentage = state.started_at.ease(120, :smooth_stop_quad)
235
+ #
236
+ # @param duration [Integer]
237
+ # @param definitions [Array<Symbol, Proc>] easing definitions (`:identity`, `:flip`, `:quad`, ...)
238
+ # @return [Float]
239
+ def ease duration, *definitions; end
240
+
241
+ # Like #ease, but measured against `Kernel.global_tick_count`.
242
+ #
243
+ # @param duration [Integer]
244
+ # @param definitions [Array<Symbol, Proc>]
245
+ # @return [Float]
246
+ def global_ease duration, *definitions; end
247
+
248
+ # Treating self as a start tick, Easing.spline progress for `duration`.
249
+ #
250
+ # @param duration [Integer]
251
+ # @param spline [Array<Array<Numeric>>] bezier definitions, four values each
252
+ # @return [Float]
253
+ def ease_spline duration, spline; end
254
+
255
+ # Like #ease_spline, but measured against `Kernel.global_tick_count`.
256
+ #
257
+ # @param duration [Integer]
258
+ # @param spline [Array<Array<Numeric>>]
259
+ # @return [Float]
260
+ def global_ease_spline duration, spline; end
261
+
262
+ # @return [Array<Integer>] `0` to self, inclusive
263
+ def numbers; end
264
+
265
+ # @param other_int [Integer]
266
+ # @return [Array<Array(Integer, Integer)>] every pair of #numbers of self and `other_int`
267
+ def combinations other_int; end
268
+
269
+ # Yields every `x`, `y` with `x` in `0...self` and `y` in `0...ys`.
270
+ #
271
+ # @param ys [Integer]
272
+ # @yieldparam x [Integer]
273
+ # @yieldparam y [Integer]
274
+ # @return [Array]
275
+ def map_with_ys ys, &block; end
276
+
277
+ # Like #times, but also yields the index.
278
+ #
279
+ # @return [Numeric]
280
+ def times_with_index &blk; end
281
+
282
+ # @param col [Numeric]
283
+ # @param w [Numeric]
284
+ # @param h [Numeric]
285
+ # @return [Numeric] y of Layout row self
286
+ def to_layout_row col: 0, w: 0, h: 0; end
287
+
288
+ # @param w [Numeric]
289
+ # @param h [Numeric]
290
+ # @return [Numeric] x of Layout column self
291
+ def to_layout_col w: 0, h: 0; end
292
+
293
+ # @param col [Numeric]
294
+ # @param w [Numeric]
295
+ # @param h [Numeric]
296
+ # @return [Numeric] y of Layout row self, counting from the bottom
297
+ def to_layout_row_from_bottom col: 0, w: 0, h: 0; end
298
+
299
+ # @param w [Numeric]
300
+ # @param h [Numeric]
301
+ # @return [Numeric] x of Layout column self, counting from the right
302
+ def to_layout_col_from_right w: 0, h: 0; end
303
+
304
+ # @return [Numeric] width of self Layout columns
305
+ def to_layout_w; end
306
+
307
+ # @return [Numeric] height of self Layout rows
308
+ def to_layout_h; end
309
+
310
+ class << self
311
+ # @param n [Numeric]
312
+ # @return [Numeric] `Grid.top - n`
313
+ def from_top n; end
314
+
315
+ # @param n [Numeric]
316
+ # @return [Numeric] `Grid.bottom + n`
317
+ def from_bottom n; end
318
+
319
+ # @param n [Numeric]
320
+ # @return [Numeric] `Grid.left + n`
321
+ def from_left n; end
322
+
323
+ # @param n [Numeric]
324
+ # @return [Numeric] `Grid.right - n`
325
+ def from_right n; end
326
+
327
+ # Expanded `rand` that also accepts a Range (`Numeric.rand(-10..10)`).
328
+ #
329
+ # @param max [Numeric, Range, nil]
330
+ # @return [Numeric]
331
+ def rand max = nil; end
332
+
333
+ # Named-argument variant of Numeric#frame_index.
334
+ #
335
+ # @return [Integer, nil]
336
+ def frame_index start_at:, count: nil, frame_count: nil, hold_for: 1, repeat: false, repeat_index: 0, tick_count_override: nil; end
337
+
338
+ # Returns `m`, `l`, or `r`, whichever keeps the value within `l..r`
339
+ # (in either order).
340
+ #
341
+ # @example
342
+ # Numeric.mid(l: 0, m: 10, r: 5) # => 5
343
+ #
344
+ # @param l [Numeric, nil]
345
+ # @param m [Numeric]
346
+ # @param r [Numeric, nil]
347
+ # @return [Numeric, nil] `nil` if `m` is `nil`
348
+ def mid l: nil, m: nil, r: nil; end
349
+
350
+ # Packs a custom blend mode for a primitive's `blendmode:`, mostly
351
+ # used when rendering to a render target. Factors are the
352
+ # `BLENDFACTOR_*` constants and operations the `BLENDOPERATION_*` ones:
353
+ #
354
+ # dstRGB = color_operation(srcRGB * src_color_factor, dstRGB * dst_color_factor)
355
+ # dstA = alpha_operation(srcA * src_alpha_factor, dstA * dst_alpha_factor)
356
+ #
357
+ # @example hole punch
358
+ # Numeric.compose_blendmode(BLENDFACTOR_ZERO, BLENDFACTOR_ONE_MINUS_SRC_ALPHA, BLENDOPERATION_ADD,
359
+ # BLENDFACTOR_ZERO, BLENDFACTOR_ONE_MINUS_SRC_ALPHA, BLENDOPERATION_ADD)
360
+ #
361
+ # @param src_color_factor [Integer]
362
+ # @param dst_color_factor [Integer]
363
+ # @param color_operation [Integer]
364
+ # @param src_alpha_factor [Integer]
365
+ # @param dst_alpha_factor [Integer]
366
+ # @param alpha_operation [Integer]
367
+ # @return [Integer]
368
+ def compose_blendmode src_color_factor, dst_color_factor, color_operation, src_alpha_factor, dst_alpha_factor, alpha_operation; end
369
+ end
370
+ end
371
+
372
+ class Integer
373
+ # @return [Boolean] true if self is greater than zero
374
+ def pos?; end
375
+
376
+ # @return [Boolean] true if self is less than zero
377
+ def neg?; end
378
+ end
379
+
380
+ # Blend operations and factors for Numeric.compose_blendmode.
381
+ BLENDOPERATION_ADD = 0x1
382
+ BLENDOPERATION_SUBTRACT = 0x2
383
+ BLENDOPERATION_REV_SUBTRACT = 0x3
384
+ BLENDOPERATION_MINIMUM = 0x4
385
+ BLENDOPERATION_MAXIMUM = 0x5
386
+ BLENDFACTOR_ZERO = 0x1
387
+ BLENDFACTOR_ONE = 0x2
388
+ BLENDFACTOR_SRC_COLOR = 0x3
389
+ BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4
390
+ BLENDFACTOR_SRC_ALPHA = 0x5
391
+ BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6
392
+ BLENDFACTOR_DST_COLOR = 0x7
393
+ BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8
394
+ BLENDFACTOR_DST_ALPHA = 0x9
395
+ BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA
@@ -0,0 +1,132 @@
1
+ module GTK
2
+ class Outputs
3
+ # Sounds to play once; push a file path (`args.outputs.sounds << "sounds/coin.wav"`).
4
+ # Prefer `args.audio` for control over playback.
5
+ #
6
+ # @return [Array<String>]
7
+ attr_reader :sounds
8
+
9
+ # Shows a value on screen for debugging.
10
+ #
11
+ # @param obj [Object] converted to a string
12
+ # @param label_style [Hash, nil] overrides the default label style
13
+ # @param background_style [Hash, nil] overrides the default background style
14
+ # @return [void]
15
+ def watch obj, label_style: nil, background_style: nil; end
16
+
17
+ # Watches every instance variable of `target` (dev builds only).
18
+ #
19
+ # @param target [Object]
20
+ # @param label_style [Hash, nil]
21
+ # @param background_style [Hash, nil]
22
+ # @return [void]
23
+ def watch_ivars target, label_style: nil, background_style: nil; end
24
+
25
+ # Watches every attribute of `target` whose class has `attributes`
26
+ # (dev builds only).
27
+ #
28
+ # @param target [Object]
29
+ # @param label_style [Hash, nil]
30
+ # @param background_style [Hash, nil]
31
+ # @return [void]
32
+ def watch_attrs target, label_style: nil, background_style: nil; end
33
+
34
+ # Watches the current framerate (dev builds only).
35
+ #
36
+ # @return [void]
37
+ def watch_fps; end
38
+
39
+ # Render targets by name, to check whether one has been created yet.
40
+ #
41
+ # @example
42
+ # return if args.outputs.render_target_state.queued?(:minimap)
43
+ #
44
+ # @return [GTK::RenderTargetState]
45
+ def render_target_state; end
46
+
47
+ # Same as #render_target_state.
48
+ #
49
+ # @return [GTK::RenderTargetState]
50
+ def rt_state; end
51
+
52
+ # Accessibility nodes by id. Each value is a rect with `a11y_text:` and
53
+ # `a11y_trait:` (e.g. `:button`), or `{ a11y_text:, a11y_trait: :notification }`.
54
+ #
55
+ # @example
56
+ # args.outputs.a11y[:play] = { a11y_text: "play", a11y_trait: :button, x: 100, y: 100, w: 200, h: 50 }
57
+ #
58
+ # @return [Hash]
59
+ attr_reader :a11y
60
+
61
+ # @return [Typing::ColorHash] #background_color as `{ r:, g:, b:, a: }`
62
+ def background_color_h; end
63
+
64
+ # Fragment shader applied to these outputs (the screen, or a render
65
+ # target via `args.outputs[:name].shader = ...`). Shader files must be
66
+ # `require`d before use, e.g. `require "shaders/effect.frag.hlsl"` at the
67
+ # top of `main.rb`. See `samples/14_shaders`.
68
+ #
69
+ # Keys:
70
+ # - `path:` [String] the required shader file
71
+ # - `uniforms:` [Array<Hash>] values bound in order, each `{ type: :int | :float, value: }`
72
+ # - `textures:` [Array<Symbol>] render targets bound as additional textures
73
+ #
74
+ # Indie or Pro license. Shaders are experimental and the API may change.
75
+ #
76
+ # @example
77
+ # args.outputs.shader = {
78
+ # path: "shaders/effect.frag.hlsl",
79
+ # uniforms: [{ type: :int, value: Kernel.tick_count }]
80
+ # }
81
+ #
82
+ # @return [Typing::ShaderHash, Hash, nil]
83
+ attr_accessor :shader
84
+ end
85
+
86
+ class OutputsArray
87
+ # Shows a value on screen for debugging (`args.outputs.debug.watch`).
88
+ #
89
+ # @param obj [Object] converted to a string
90
+ # @param label_style [Hash, nil] overrides the default label style
91
+ # @param background_style [Hash, nil] overrides the default background style
92
+ # @return [void]
93
+ def watch obj, label_style: nil, background_style: nil; end
94
+
95
+ # Watches every instance variable of `target` (dev builds only).
96
+ #
97
+ # @param target [Object]
98
+ # @param label_style [Hash, nil]
99
+ # @param background_style [Hash, nil]
100
+ # @return [void]
101
+ def watch_ivars target, label_style: nil, background_style: nil; end
102
+
103
+ # Watches every attribute of `target` whose class has `attributes`
104
+ # (dev builds only).
105
+ #
106
+ # @param target [Object]
107
+ # @param label_style [Hash, nil]
108
+ # @param background_style [Hash, nil]
109
+ # @return [void]
110
+ def watch_attrs target, label_style: nil, background_style: nil; end
111
+
112
+ # Watches the current framerate (dev builds only).
113
+ #
114
+ # @return [void]
115
+ def watch_fps; end
116
+ end
117
+
118
+ # Render targets created via `args.outputs[name]`, by name.
119
+ class RenderTargetState
120
+ # @param name [Symbol, String]
121
+ # @return [Typing::RenderTargetEntryHash, nil] the render target's entry (`path`, `ready`, ...)
122
+ def [] name; end
123
+
124
+ # @param name [Symbol, String]
125
+ # @return [Boolean] true once a render target with this name has been requested
126
+ def queued? name; end
127
+
128
+ # @param name [Symbol, String]
129
+ # @return [Boolean] true once the render target's texture is ready to use
130
+ def ready? name; end
131
+ end
132
+ end