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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +56 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/NOTICE +8 -0
- data/README.md +185 -0
- data/Rakefile +13 -0
- data/lib/solargraph/dragonruby/convention.rb +43 -0
- data/lib/solargraph/dragonruby/macro_node.rb +44 -0
- data/lib/solargraph/dragonruby/version.rb +7 -0
- data/lib/solargraph/dragonruby.rb +15 -0
- data/lib/solargraph-dragonruby.rb +5 -0
- data/sig/solargraph/dragonruby.rbs +19 -0
- data/stubs/extensions/README.md +20 -0
- data/stubs/extensions/args.rb +91 -0
- data/stubs/extensions/array.rb +25 -0
- data/stubs/extensions/attr.rb +249 -0
- data/stubs/extensions/easing.rb +90 -0
- data/stubs/extensions/entity.rb +63 -0
- data/stubs/extensions/geometry.rb +528 -0
- data/stubs/extensions/grid.rb +247 -0
- data/stubs/extensions/inputs.rb +678 -0
- data/stubs/extensions/layout.rb +175 -0
- data/stubs/extensions/log.rb +158 -0
- data/stubs/extensions/main.rb +63 -0
- data/stubs/extensions/numeric.rb +395 -0
- data/stubs/extensions/outputs.rb +132 -0
- data/stubs/extensions/runtime.rb +436 -0
- data/stubs/extensions/string.rb +85 -0
- data/stubs/extensions/typing.rb +193 -0
- data/stubs/extensions/zlib.rb +24 -0
- data/stubs/upstream/LICENSE.txt +21 -0
- data/stubs/upstream/UPSTREAM +2 -0
- data/stubs/upstream/args.rb +61 -0
- data/stubs/upstream/constants.rb +8 -0
- data/stubs/upstream/controller.rb +90 -0
- data/stubs/upstream/easing.rb +119 -0
- data/stubs/upstream/geometry.rb +430 -0
- data/stubs/upstream/globals.rb +17 -0
- data/stubs/upstream/gtk.rb +476 -0
- data/stubs/upstream/inputs.rb +286 -0
- data/stubs/upstream/kernel.rb +7 -0
- data/stubs/upstream/keyboard.rb +38 -0
- data/stubs/upstream/layout.rb +32 -0
- data/stubs/upstream/numeric.rb +82 -0
- data/stubs/upstream/outputs.rb +55 -0
- data/stubs/upstream/outputs_array.rb +4 -0
- data/stubs/upstream/phantom_types.rb +25 -0
- data/stubs/upstream/toplevel.rb +13 -0
- metadata +107 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
module GTK
|
|
2
|
+
module Geometry
|
|
3
|
+
class << self
|
|
4
|
+
# @param v1 [Typing::Point, Object] a vector (a Hash with x and y keys, or an Object that responds to x and y)
|
|
5
|
+
# @param v2 [Typing::Point, Object] a vector
|
|
6
|
+
# @return [Typing::PointHash] `x`, `y` sum of the two vectors
|
|
7
|
+
def vec2_add v1, v2; end
|
|
8
|
+
|
|
9
|
+
# @param v1 [Typing::Point, Object] a vector
|
|
10
|
+
# @param v2 [Typing::Point, Object] a vector
|
|
11
|
+
# @return [Typing::PointHash] `x`, `y` difference of the two vectors
|
|
12
|
+
def vec2_subtract v1, v2; end
|
|
13
|
+
|
|
14
|
+
# Alias of #vec2_subtract.
|
|
15
|
+
# @param v1 [Typing::Point, Object] a vector
|
|
16
|
+
# @param v2 [Typing::Point, Object] a vector
|
|
17
|
+
# @return [Typing::PointHash]
|
|
18
|
+
def vec2_sub v1, v2; end
|
|
19
|
+
|
|
20
|
+
# @param v [Typing::Point, Object] a vector
|
|
21
|
+
# @param scalar [Numeric]
|
|
22
|
+
# @return [Typing::PointHash] `x`, `y` with each component multiplied by `scalar`
|
|
23
|
+
def vec2_scale v, scalar; end
|
|
24
|
+
|
|
25
|
+
# @param v1 [Typing::Point, Object] a vector
|
|
26
|
+
# @param v2 [Typing::Point, Object] a vector
|
|
27
|
+
# @return [Float] dot product of the two vectors
|
|
28
|
+
def vec2_dot_product v1, v2; end
|
|
29
|
+
|
|
30
|
+
# @param v [Typing::Point, Object] a vector
|
|
31
|
+
# @return [Float] magnitude of the vector
|
|
32
|
+
def vec2_magnitude v; end
|
|
33
|
+
|
|
34
|
+
# @param v [Typing::Point, Object] a vector
|
|
35
|
+
# @return [Typing::PointHash] `x`, `y` normal of the vector
|
|
36
|
+
def vec2_normal v; end
|
|
37
|
+
|
|
38
|
+
# @param v [Typing::Point, Object] a vector
|
|
39
|
+
# @return [Typing::PointHash] `x`, `y` normalized vector
|
|
40
|
+
def vec2_normalize v; end
|
|
41
|
+
|
|
42
|
+
# @param v [Typing::Point, Object] a vector
|
|
43
|
+
# @return [Float] angle of the vector in degrees (`0` to `359.9`)
|
|
44
|
+
def vec2_angle v; end
|
|
45
|
+
|
|
46
|
+
# @param angle [Numeric] degrees
|
|
47
|
+
# @return [Typing::PointHash] `x`, `y` vector components of the angle
|
|
48
|
+
def angle_vec2 angle; end
|
|
49
|
+
|
|
50
|
+
# @param angle [Numeric] radians
|
|
51
|
+
# @return [Typing::PointHash] `x`, `y` vector components of the angle
|
|
52
|
+
def angle_vec2_r angle; end
|
|
53
|
+
|
|
54
|
+
# @param angle [Numeric] degrees
|
|
55
|
+
# @return [Typing::PointHash] `x`, `y` vector components snapped to 45 degree angles (like a dpad)
|
|
56
|
+
def angle_cardinal_vec2 angle; end
|
|
57
|
+
|
|
58
|
+
# @param angle [Numeric] radians
|
|
59
|
+
# @return [Typing::PointHash] `x`, `y` vector components snapped to 45 degree angles (like a dpad)
|
|
60
|
+
def angle_cardinal_vec2_r angle; end
|
|
61
|
+
|
|
62
|
+
# @param rect [Typing::Rect, Object] a rect (`x`, `y`, `w`, `h`, optional `anchor_x`, `anchor_y`)
|
|
63
|
+
# @return [Typing::PointHash] `x`, `y` center point of the rect
|
|
64
|
+
def rect_center_point rect; end
|
|
65
|
+
|
|
66
|
+
# Alias of #rect_center_point.
|
|
67
|
+
# @param rect [Typing::Rect, Object]
|
|
68
|
+
# @return [Typing::PointHash]
|
|
69
|
+
def center rect; end
|
|
70
|
+
|
|
71
|
+
# @param line [Typing::Line, Object] a line (`x`, `y`, `x2`, `y2`)
|
|
72
|
+
# @return [Typing::PointHash] `x`, `y` center point of the line
|
|
73
|
+
def line_center_point line; end
|
|
74
|
+
|
|
75
|
+
# @param line [Typing::Line, Object] a line (`x`, `y`, `x2`, `y2`)
|
|
76
|
+
# @return [Typing::PointHash] `x`, `y` midpoint of the line
|
|
77
|
+
def line_midpoint line; end
|
|
78
|
+
|
|
79
|
+
# @param line [Typing::Line, Object] a line (`x`, `y`, `x2`, `y2`)
|
|
80
|
+
# @return [Typing::PointHash] `x`, `y` vector of the line
|
|
81
|
+
def line_vec2 line; end
|
|
82
|
+
|
|
83
|
+
# @param p1 [Typing::Point, Object] start point
|
|
84
|
+
# @param p2 [Typing::Point, Object] end point
|
|
85
|
+
# @return [Typing::LineHash] a line (`x`, `y`, `x2`, `y2`) from `p1` to `p2`
|
|
86
|
+
def points_to_line p1, p2; end
|
|
87
|
+
|
|
88
|
+
# @param shape [Typing::Circle, Typing::Rect, Object] a circle (`x`, `y`, `radius`) or a rect
|
|
89
|
+
# @return [Typing::CircleHash] the smallest circle containing `shape`
|
|
90
|
+
def rect_to_circle shape; end
|
|
91
|
+
|
|
92
|
+
# @param shape_1 [Typing::Circle, Typing::Rect, Object] a circle (`x`, `y`, `radius`) or a rect
|
|
93
|
+
# @param shape_2 [Typing::Circle, Typing::Rect, Object] a circle (`x`, `y`, `radius`) or a rect
|
|
94
|
+
# @return [Boolean] true if the shapes intersect (rects are treated as circles)
|
|
95
|
+
def intersect_circle? shape_1, shape_2; end
|
|
96
|
+
|
|
97
|
+
# @param rect [Typing::Rect, Object]
|
|
98
|
+
# @param anchor_x [Float] e.g. `0.5` to center horizontally
|
|
99
|
+
# @param anchor_y [Float] e.g. `0.5` to center vertically
|
|
100
|
+
# @return [Typing::RectHash] a new rect anchored by `anchor_x` and `anchor_y`
|
|
101
|
+
def anchor_rect rect, anchor_x, anchor_y; end
|
|
102
|
+
|
|
103
|
+
# @param p0 [Typing::Point, Object] control point (`x`, `y`)
|
|
104
|
+
# @param p1 [Typing::Point, Object] control point
|
|
105
|
+
# @param p2 [Typing::Point, Object] control point
|
|
106
|
+
# @param p3 [Typing::Point, Object] control point
|
|
107
|
+
# @param t [Float] `0.0` to `1.0`
|
|
108
|
+
# @return [Typing::PointHash] `x`, `y` point on the curve at `t`
|
|
109
|
+
def cubic_bezier_vec2 p0, p1, p2, p3, t; end
|
|
110
|
+
|
|
111
|
+
# @param test_angle [Float] degrees
|
|
112
|
+
# @param target_angle [Float] degrees
|
|
113
|
+
# @param range [Float] degrees on either side of `target_angle`
|
|
114
|
+
# @return [Boolean] true if `test_angle` is within `range` of `target_angle`
|
|
115
|
+
def angle_within_range? test_angle, target_angle, range; end
|
|
116
|
+
|
|
117
|
+
# @param rect [Typing::Rect, Object] a rect
|
|
118
|
+
# @param other_rect [Typing::Rect, Object] a rect
|
|
119
|
+
# @return [Typing::RectHash] `rect` centered horizontally inside `other_rect` (and moved to its `y`)
|
|
120
|
+
def center_inside_rect_x rect, other_rect; end
|
|
121
|
+
|
|
122
|
+
# @param rect [Typing::Rect, Object] a rect
|
|
123
|
+
# @param other_rect [Typing::Rect, Object] a rect
|
|
124
|
+
# @return [Typing::RectHash] `rect` centered vertically inside `other_rect` (and moved to its `x`)
|
|
125
|
+
def center_inside_rect_y rect, other_rect; end
|
|
126
|
+
|
|
127
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
128
|
+
# @return [Float] length of `line`
|
|
129
|
+
def line_length line; end
|
|
130
|
+
|
|
131
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
132
|
+
# @param replace_infinity [Numeric] returned (with sign) for vertical lines
|
|
133
|
+
# @return [Numeric] slope of `line`; raises for a zero-length line
|
|
134
|
+
def line_slope line, replace_infinity: Float::INFINITY; end
|
|
135
|
+
|
|
136
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
137
|
+
# @param replace_infinity [Numeric, nil] slope to use for vertical lines
|
|
138
|
+
# @return [Numeric] y where `line` (extended) crosses `x = 0`
|
|
139
|
+
def line_y_intercept line, replace_infinity: nil; end
|
|
140
|
+
|
|
141
|
+
# @param line_one [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
142
|
+
# @param line_two [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
143
|
+
# @param replace_infinity [Numeric, nil] slope to use for vertical lines
|
|
144
|
+
# @return [Float] angle in degrees between the lines
|
|
145
|
+
def angle_between_lines line_one, line_two, replace_infinity: nil; end
|
|
146
|
+
|
|
147
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
148
|
+
# @return [Boolean] true if `line` is horizontal
|
|
149
|
+
def line_horizontal? line; end
|
|
150
|
+
|
|
151
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
152
|
+
# @return [Boolean] true if `line` is vertical
|
|
153
|
+
def line_vertical? line; end
|
|
154
|
+
|
|
155
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
156
|
+
# @param x [Numeric]
|
|
157
|
+
# @param y [Numeric]
|
|
158
|
+
# @return [Typing::LineHash, Array] a copy of `line` moved by `x`, `y`
|
|
159
|
+
def shift_line line, x, y; end
|
|
160
|
+
|
|
161
|
+
# @param line [Typing::Line, Object] `x`, `y`, `x2`, `y2`
|
|
162
|
+
# @param min_w [Numeric]
|
|
163
|
+
# @param min_h [Numeric]
|
|
164
|
+
# @return [Typing::RectHash] bounding rect of `line`, at least `min_w` by `min_h`
|
|
165
|
+
def line_rect line, min_w: 0, min_h: 0; end
|
|
166
|
+
|
|
167
|
+
# Same as #line_rect.
|
|
168
|
+
#
|
|
169
|
+
# @param line [Typing::Line, Object]
|
|
170
|
+
# @param min_w [Numeric]
|
|
171
|
+
# @param min_h [Numeric]
|
|
172
|
+
# @return [Typing::RectHash]
|
|
173
|
+
def line_to_rect line, min_w: 0, min_h: 0; end
|
|
174
|
+
|
|
175
|
+
# @param rect [Typing::Rect, Object] `x`, `y`, `w`, `h`
|
|
176
|
+
# @return [Typing::LineHash] `x`, `y`, `x2`, `y2` diagonal of `rect`
|
|
177
|
+
def rect_to_line rect; end
|
|
178
|
+
|
|
179
|
+
# @param shape [Object]
|
|
180
|
+
# @return [Boolean] true if `shape` has `w` and `h`
|
|
181
|
+
def rect? shape; end
|
|
182
|
+
|
|
183
|
+
# @param shape [Object]
|
|
184
|
+
# @return [Boolean] true if `shape` has `x2` and `y2`
|
|
185
|
+
def line? shape; end
|
|
186
|
+
|
|
187
|
+
# @param shape [Object]
|
|
188
|
+
# @return [Boolean] true if `shape` has a `radius`
|
|
189
|
+
def circle? shape; end
|
|
190
|
+
|
|
191
|
+
# Like #intersect_rect?, for any shapes with a bounding box (circles,
|
|
192
|
+
# rects, lines, points).
|
|
193
|
+
#
|
|
194
|
+
# @param inner_shape [Object]
|
|
195
|
+
# @param outer_shape [Object]
|
|
196
|
+
# @param tolerance [Float]
|
|
197
|
+
# @return [Boolean, nil]
|
|
198
|
+
def intersect_bounding_box? inner_shape, outer_shape, tolerance = 0.0; end
|
|
199
|
+
|
|
200
|
+
# Like #inside_rect?, for any shapes with a bounding box.
|
|
201
|
+
#
|
|
202
|
+
# @param inner_shape [Object]
|
|
203
|
+
# @param outer_shape [Object]
|
|
204
|
+
# @param tolerance [Float]
|
|
205
|
+
# @return [Boolean, nil]
|
|
206
|
+
def inside_bounding_box? inner_shape, outer_shape, tolerance = 0.0; end
|
|
207
|
+
|
|
208
|
+
# Value at `t` of a cubic bezier with control values `a`, `b`, `c`, `d`.
|
|
209
|
+
#
|
|
210
|
+
# @param t [Float] `0.0` to `1.0`
|
|
211
|
+
# @param a [Numeric]
|
|
212
|
+
# @param b [Numeric]
|
|
213
|
+
# @param c [Numeric]
|
|
214
|
+
# @param d [Numeric]
|
|
215
|
+
# @return [Float]
|
|
216
|
+
def cubic_bezier t, a, b, c, d; end
|
|
217
|
+
|
|
218
|
+
# Re-declarations of upstream functions with typed shapes (and
|
|
219
|
+
# signatures checked against the 7.22 runtime).
|
|
220
|
+
|
|
221
|
+
# True if two rects intersect. The default tolerance of `0.1` keeps
|
|
222
|
+
# rects that only share an edge from intersecting.
|
|
223
|
+
#
|
|
224
|
+
# @param rect_1 [Typing::Rect, Object]
|
|
225
|
+
# @param rect_2 [Typing::Rect, Object]
|
|
226
|
+
# @param tolerance [Float]
|
|
227
|
+
# @return [Boolean]
|
|
228
|
+
def intersect_rect? rect_1, rect_2, tolerance = 0.1; end
|
|
229
|
+
|
|
230
|
+
# @param inner_rect [Typing::Rect, Object]
|
|
231
|
+
# @param outer_rect [Typing::Rect, Object]
|
|
232
|
+
# @param tolerance [Float]
|
|
233
|
+
# @return [Boolean] true if `inner_rect` is inside `outer_rect`
|
|
234
|
+
def inside_rect? inner_rect, outer_rect, tolerance = 0.0; end
|
|
235
|
+
|
|
236
|
+
# A copy of `rect` scaled by `percentage` (`2.0` doubles its size).
|
|
237
|
+
# Anchors (`0.0` to `1.0`) keep that point of the rect in place.
|
|
238
|
+
#
|
|
239
|
+
# @param rect [Typing::Rect, Object]
|
|
240
|
+
# @param percentage [Float]
|
|
241
|
+
# @param anchors [Array<Float>] `anchor_x`, then `anchor_y` (defaults to `anchor_x`)
|
|
242
|
+
# @return [Typing::RectHash, Object] a Hash for a Hash, an Array for an Array; other objects are updated in place
|
|
243
|
+
def scale_rect rect, percentage, *anchors; end
|
|
244
|
+
|
|
245
|
+
# Like #scale_rect, with each axis scaled separately.
|
|
246
|
+
#
|
|
247
|
+
# @param rect [Typing::Rect, Object]
|
|
248
|
+
# @param percentage_x [Float, nil] defaults to `1.0`
|
|
249
|
+
# @param percentage_y [Float, nil] defaults to `1.0`
|
|
250
|
+
# @param anchor_x [Float, nil] defaults to `0.0`
|
|
251
|
+
# @param anchor_y [Float, nil] defaults to `0.0`
|
|
252
|
+
# @return [Typing::RectHash, Object]
|
|
253
|
+
def scale_rect_extended rect, percentage_x: nil, percentage_y: nil, anchor_x: nil, anchor_y: nil; end
|
|
254
|
+
|
|
255
|
+
# @param start_point [Typing::Point, Object]
|
|
256
|
+
# @param end_point [Typing::Point, Object]
|
|
257
|
+
# @return [Float] angle in degrees from `start_point` to `end_point`
|
|
258
|
+
def angle start_point, end_point; end
|
|
259
|
+
|
|
260
|
+
# @param start_point [Typing::Point, Object]
|
|
261
|
+
# @param end_point [Typing::Point, Object]
|
|
262
|
+
# @return [Float] angle in degrees from `end_point` to `start_point`
|
|
263
|
+
def angle_from start_point, end_point; end
|
|
264
|
+
|
|
265
|
+
# @param start_point [Typing::Point, Object]
|
|
266
|
+
# @param end_point [Typing::Point, Object]
|
|
267
|
+
# @return [Float] angle in degrees from `start_point` to `end_point`
|
|
268
|
+
def angle_to start_point, end_point; end
|
|
269
|
+
|
|
270
|
+
# @param point_one [Typing::Point, Object]
|
|
271
|
+
# @param point_two [Typing::Point, Object]
|
|
272
|
+
# @return [Float] distance between the points
|
|
273
|
+
def distance point_one, point_two; end
|
|
274
|
+
|
|
275
|
+
# @param p1 [Typing::Point, Object]
|
|
276
|
+
# @param p2 [Typing::Point, Object]
|
|
277
|
+
# @return [Float] squared distance between the points (cheaper than #distance for comparisons)
|
|
278
|
+
def distance_squared p1, p2; end
|
|
279
|
+
|
|
280
|
+
# @param point [Typing::Point, Object]
|
|
281
|
+
# @param circle_center_point [Typing::Point, Typing::Circle, Object] the center, or a circle with `radius`
|
|
282
|
+
# @param radius [Numeric, nil] omit when `circle_center_point` has a `radius`
|
|
283
|
+
# @return [Boolean] true if `point` is inside the circle
|
|
284
|
+
def point_inside_circle? point, circle_center_point, radius = nil; end
|
|
285
|
+
|
|
286
|
+
# @param rect [Typing::Rect, Object]
|
|
287
|
+
# @param other_rect [Typing::Rect, Object]
|
|
288
|
+
# @return [Typing::RectHash] `rect` centered inside `other_rect`
|
|
289
|
+
def center_inside_rect rect, other_rect; end
|
|
290
|
+
|
|
291
|
+
# @param point [Typing::Point, Object]
|
|
292
|
+
# @param line [Typing::Line, Object]
|
|
293
|
+
# @return [Symbol] `:left`, `:right`, or `:on`
|
|
294
|
+
def ray_test point, line; end
|
|
295
|
+
|
|
296
|
+
# @param line [Typing::Line, Object]
|
|
297
|
+
# @return [Typing::PointHash] normalized rise (`y`) and run (`x`) of the line
|
|
298
|
+
def line_rise_run line; end
|
|
299
|
+
|
|
300
|
+
# Treats the lines as segments (see #ray_intersect for infinite lines).
|
|
301
|
+
#
|
|
302
|
+
# @param line_one [Typing::Line, Object]
|
|
303
|
+
# @param line_two [Typing::Line, Object]
|
|
304
|
+
# @return [Typing::PointHash, nil] the point of intersection, or `nil` if the segments don't intersect
|
|
305
|
+
def line_intersect line_one, line_two; end
|
|
306
|
+
|
|
307
|
+
# Treats the lines as infinite (see #line_intersect for segments).
|
|
308
|
+
#
|
|
309
|
+
# @param line_one [Typing::Line, Object]
|
|
310
|
+
# @param line_two [Typing::Line, Object]
|
|
311
|
+
# @return [Typing::PointHash, nil] the point of intersection, or `nil` if the lines are parallel
|
|
312
|
+
def ray_intersect line_one, line_two; end
|
|
313
|
+
|
|
314
|
+
# @param point [Typing::Point, Object]
|
|
315
|
+
# @param angle [Numeric] degrees
|
|
316
|
+
# @param around [Typing::Point, Object, nil] defaults to the origin
|
|
317
|
+
# @return [Typing::PointHash] `point` rotated by `angle` around `around`
|
|
318
|
+
def rotate_point point, angle, around = nil; end
|
|
319
|
+
|
|
320
|
+
# @param line [Typing::Line, Object]
|
|
321
|
+
# @return [Float] angle of the line in degrees
|
|
322
|
+
def line_angle line; end
|
|
323
|
+
|
|
324
|
+
# @param line [Typing::Line, Object]
|
|
325
|
+
# @param point [Typing::Point, Object, nil] defaults to the start of the line
|
|
326
|
+
# @return [Typing::PointHash] the point on the (infinite) line closest to `point`
|
|
327
|
+
def line_normal line, point = nil; end
|
|
328
|
+
|
|
329
|
+
# @param point [Typing::Point, Object]
|
|
330
|
+
# @param line [Typing::Line, Object]
|
|
331
|
+
# @param tolerance [Float]
|
|
332
|
+
# @return [Boolean] true if `point` is on `line`
|
|
333
|
+
def point_on_line? point, line, tolerance = 0.1; end
|
|
334
|
+
|
|
335
|
+
# @param circle [Typing::Circle, Object]
|
|
336
|
+
# @param line [Typing::Line, Object]
|
|
337
|
+
# @return [Boolean] true if the circle intersects the line
|
|
338
|
+
def circle_intersect_line? circle, line; end
|
|
339
|
+
|
|
340
|
+
# The first rect in `haystack` that intersects `needle`. `anchor_x` and
|
|
341
|
+
# `anchor_y` are honored.
|
|
342
|
+
#
|
|
343
|
+
# @param needle [Typing::Rect, Object]
|
|
344
|
+
# @param haystack [Array<Typing::Rect, Object>]
|
|
345
|
+
# @param using [Symbol, Proc, nil] method or lambda that returns each object's rect
|
|
346
|
+
# @return [Object, nil] the matching element of `haystack`
|
|
347
|
+
def find_intersect_rect needle, haystack, using: nil; end
|
|
348
|
+
|
|
349
|
+
# Every rect in `haystack` that intersects `needle`.
|
|
350
|
+
#
|
|
351
|
+
# @param needle [Typing::Rect, Object]
|
|
352
|
+
# @param haystack [Array<Typing::Rect, Object>]
|
|
353
|
+
# @param using [Symbol, Proc, nil] method or lambda that returns each object's rect
|
|
354
|
+
# @return [Array] the matching elements of `haystack`
|
|
355
|
+
def find_all_intersect_rect needle, haystack, using: nil; end
|
|
356
|
+
|
|
357
|
+
# Builds a quad tree for #find_intersect_rect_quad_tree.
|
|
358
|
+
#
|
|
359
|
+
# @param rects [Array<Typing::Rect, Object>]
|
|
360
|
+
# @return [Object] the quad tree
|
|
361
|
+
def create_quad_tree rects; end
|
|
362
|
+
|
|
363
|
+
# A faster #find_intersect_rect for large, static collections.
|
|
364
|
+
#
|
|
365
|
+
# @param needle [Typing::Rect, Object]
|
|
366
|
+
# @param quad_tree [Object] from #create_quad_tree
|
|
367
|
+
# @return [Object, nil] the first intersecting rect
|
|
368
|
+
def find_intersect_rect_quad_tree needle, quad_tree; end
|
|
369
|
+
|
|
370
|
+
# A faster #find_all_intersect_rect for large, static collections.
|
|
371
|
+
#
|
|
372
|
+
# @param needle [Typing::Rect, Object]
|
|
373
|
+
# @param quad_tree [Object] from #create_quad_tree
|
|
374
|
+
# @return [Array] every intersecting rect
|
|
375
|
+
def find_all_intersect_rect_quad_tree needle, quad_tree; end
|
|
376
|
+
|
|
377
|
+
# Collisions within `rects`. When A and B intersect, the result has
|
|
378
|
+
# both `A => B` and `B => A`. Only the first collision per rect is found.
|
|
379
|
+
#
|
|
380
|
+
# @param rects [Array<Typing::Rect, Object>]
|
|
381
|
+
# @return [Hash{Object => Object}]
|
|
382
|
+
def find_collisions rects; end
|
|
383
|
+
|
|
384
|
+
# Calls the block with each intersecting pair of rects. With one
|
|
385
|
+
# collection, checks it against itself.
|
|
386
|
+
#
|
|
387
|
+
# @example
|
|
388
|
+
# Geometry.each_intersect_rect(players, bullets, using: :hitbox) do |player, bullet|
|
|
389
|
+
# player.hp -= 1
|
|
390
|
+
# end
|
|
391
|
+
#
|
|
392
|
+
# @param rects_1 [Array<Typing::Rect, Object>, Typing::Rect, Object]
|
|
393
|
+
# @param rects_2 [Array<Typing::Rect, Object>, Typing::Rect, Object, nil] should be the larger collection
|
|
394
|
+
# @param tolerance [Float]
|
|
395
|
+
# @param using [Symbol, Proc, nil] method or lambda that returns each object's rect
|
|
396
|
+
# @yieldparam rect_1 [Object]
|
|
397
|
+
# @yieldparam rect_2 [Object]
|
|
398
|
+
# @return [void]
|
|
399
|
+
def each_intersect_rect rects_1, rects_2 = nil, tolerance = 0.1, using: nil, █ end
|
|
400
|
+
|
|
401
|
+
# The next rect in `rects` in a direction from `rect`, for moving a
|
|
402
|
+
# selection with a keyboard or controller.
|
|
403
|
+
#
|
|
404
|
+
# @example
|
|
405
|
+
# selected = Geometry.rect_navigate(rect: selected, rects: buttons,
|
|
406
|
+
# left_right: inputs.key_down.left_right,
|
|
407
|
+
# up_down: inputs.key_down.up_down)
|
|
408
|
+
#
|
|
409
|
+
# @param rect [Typing::Rect, Object] the current selection
|
|
410
|
+
# @param rects [Array<Typing::Rect, Object>]
|
|
411
|
+
# @param left_right [Integer, nil] `-1`, `0`, or `1`
|
|
412
|
+
# @param up_down [Integer, nil] `-1`, `0`, or `1`
|
|
413
|
+
# @param directional_vector [Typing::Point, Object, nil] used instead of `left_right` and `up_down`
|
|
414
|
+
# @param wrap_x [Boolean] wrap around horizontally
|
|
415
|
+
# @param wrap_y [Boolean] wrap around vertically
|
|
416
|
+
# @param using [Symbol, Proc, nil] method or lambda that returns each object's rect
|
|
417
|
+
# @return [Object] the newly selected element of `rects` (or `rect`)
|
|
418
|
+
def rect_navigate rect:, rects:, left_right: nil, up_down: nil, directional_vector: nil, wrap_x: true, wrap_y: true, using: nil; end
|
|
419
|
+
|
|
420
|
+
# @param rect [Typing::Rect, Object]
|
|
421
|
+
# @return [Array<Typing::LineHash>] the edges of `rect`: bottom, right, top, left
|
|
422
|
+
def rect_to_lines rect; end
|
|
423
|
+
|
|
424
|
+
# @param line [Typing::Line, Object]
|
|
425
|
+
# @return [Array(Typing::PointHash, Typing::PointHash)] the start and end points of `line`
|
|
426
|
+
def line_to_points line; end
|
|
427
|
+
|
|
428
|
+
# `x`, `y`, `w`, `h` and `center` of `rect`, with anchors applied.
|
|
429
|
+
#
|
|
430
|
+
# @param rect [Typing::Rect, Object]
|
|
431
|
+
# @return [Typing::RectPropsHash]
|
|
432
|
+
def rect_props rect; end
|
|
433
|
+
|
|
434
|
+
# A copy of `rect` resized around its center, by ratio (`ratio:`,
|
|
435
|
+
# `w_ratio:`, `h_ratio:`) or by pixels (`px:`, `w_px:`, `h_px:`), not both.
|
|
436
|
+
#
|
|
437
|
+
# @param rect [Typing::Rect, Object]
|
|
438
|
+
# @param ratio [Numeric, nil]
|
|
439
|
+
# @param w_ratio [Numeric, nil] overrides `ratio` for the width
|
|
440
|
+
# @param h_ratio [Numeric, nil] overrides `ratio` for the height
|
|
441
|
+
# @param px [Numeric, nil]
|
|
442
|
+
# @param w_px [Numeric, nil] overrides `px` for the width
|
|
443
|
+
# @param h_px [Numeric, nil] overrides `px` for the height
|
|
444
|
+
# @return [Typing::RectPropsHash]
|
|
445
|
+
def zoom_rect rect:, ratio: nil, w_ratio: nil, h_ratio: nil, px: nil, w_px: nil, h_px: nil; end
|
|
446
|
+
|
|
447
|
+
# Linear interpolation from one rect to another.
|
|
448
|
+
#
|
|
449
|
+
# @param from [Typing::Rect, Object]
|
|
450
|
+
# @param to [Typing::Rect, Object]
|
|
451
|
+
# @param step [Numeric] `0.0` returns `from`, `1.0` returns `to`
|
|
452
|
+
# @param tolerance [Numeric]
|
|
453
|
+
# @return [Typing::RectPropsHash]
|
|
454
|
+
def lerp_rect from, to, step, tolerance: 0; end
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
module Typing
|
|
460
|
+
# phantom type for the Geometry functions DragonRuby mixes into Hash, Array and entities
|
|
461
|
+
module GeometryMixin
|
|
462
|
+
# @param other [Typing::Rect, Object] a rect
|
|
463
|
+
# @param tolerance [Float]
|
|
464
|
+
# @return [Boolean]
|
|
465
|
+
def intersect_rect? other, tolerance = 0.1; end
|
|
466
|
+
|
|
467
|
+
# @param other [Typing::Rect, Object] a rect
|
|
468
|
+
# @return [Boolean] true if self is inside `other`
|
|
469
|
+
def inside_rect? other; end
|
|
470
|
+
|
|
471
|
+
# @param ratio [Float]
|
|
472
|
+
# @return [Typing::RectHash] a scaled copy of self
|
|
473
|
+
def scale_rect ratio, anchor_x = 0, anchor_y = 0; end
|
|
474
|
+
|
|
475
|
+
# @param other [Typing::Point, Object] a point
|
|
476
|
+
# @return [Float] angle in degrees from self to `other`
|
|
477
|
+
def angle_to other; end
|
|
478
|
+
|
|
479
|
+
# @param other [Typing::Point, Object] a point
|
|
480
|
+
# @return [Float] angle in degrees from `other` to self
|
|
481
|
+
def angle_from other; end
|
|
482
|
+
|
|
483
|
+
# @param circle_center [Typing::Point, Object] a point
|
|
484
|
+
# @param circle_radius [Numeric]
|
|
485
|
+
# @return [Boolean]
|
|
486
|
+
def point_inside_circle? circle_center, circle_radius; end
|
|
487
|
+
|
|
488
|
+
# @param other [Typing::Rect, Object] a rect
|
|
489
|
+
# @return [Typing::RectHash] self centered inside `other`
|
|
490
|
+
def center_inside_rect other; end
|
|
491
|
+
|
|
492
|
+
# @param other [Typing::Rect, Object] a rect
|
|
493
|
+
# @return [Typing::RectHash] self centered horizontally inside `other`
|
|
494
|
+
def center_inside_rect_x other; end
|
|
495
|
+
|
|
496
|
+
# @param other [Typing::Rect, Object] a rect
|
|
497
|
+
# @return [Typing::RectHash] self centered vertically inside `other`
|
|
498
|
+
def center_inside_rect_y other; end
|
|
499
|
+
|
|
500
|
+
# @param anchor_x [Float]
|
|
501
|
+
# @param anchor_y [Float]
|
|
502
|
+
# @return [Typing::RectHash] a new rect anchored by `anchor_x` and `anchor_y`
|
|
503
|
+
def anchor_rect anchor_x, anchor_y; end
|
|
504
|
+
|
|
505
|
+
# @return [Typing::PointHash] `x`, `y` center point of self
|
|
506
|
+
def rect_center_point; end
|
|
507
|
+
|
|
508
|
+
# @return [Typing::RectHash] bounding rect of self as a line
|
|
509
|
+
def line_to_rect min_w: 0, min_h: 0; end
|
|
510
|
+
|
|
511
|
+
# @return [Typing::LineHash] `x`, `y`, `x2`, `y2` diagonal of self as a rect
|
|
512
|
+
def rect_to_line; end
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
class ::Hash
|
|
517
|
+
include Typing::GeometryMixin
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
class ::Array
|
|
521
|
+
include Typing::GeometryMixin
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
module GTK
|
|
525
|
+
class OpenEntity
|
|
526
|
+
include Typing::GeometryMixin
|
|
527
|
+
end
|
|
528
|
+
end
|