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,430 @@
|
|
|
1
|
+
module GTK
|
|
2
|
+
module Geometry
|
|
3
|
+
class << self
|
|
4
|
+
# Given two rectangle primitives this function will return true or false depending on if the two rectangles intersect or not.
|
|
5
|
+
#
|
|
6
|
+
# An optional final parameter can be passed in representing the tolerence of overlap needed to be considered a true intersection.
|
|
7
|
+
#
|
|
8
|
+
# The default value of tolerance is 0.1 which keeps the function from returning true if only the edges of the rectangles overlap.
|
|
9
|
+
#
|
|
10
|
+
# @param rect_1 [Object] rectangle1
|
|
11
|
+
# @param rect_2 [Object] rectangle2
|
|
12
|
+
# @return [Boolean] return true or false depending on if the two rectangles intersect or not.
|
|
13
|
+
def intersect_rect? rect_1, rect_2, tolerance; end
|
|
14
|
+
|
|
15
|
+
# Given two rectangle primitives this function will return true or false depending on if the first rectangle is inside of the second rectangle.
|
|
16
|
+
#
|
|
17
|
+
# @param rect_1 [Object] rectangle1
|
|
18
|
+
# @param rect_2 [Object] rectangle2
|
|
19
|
+
# @return [Boolean] return true or false depending on if the first rectangle is inside of the second rectangle.
|
|
20
|
+
def inside_rect? rect_1, rect_2; end
|
|
21
|
+
|
|
22
|
+
# Given a Rectangle this function returns a new rectangle with a scaled size.
|
|
23
|
+
#
|
|
24
|
+
# @param ratio [Float] the ratio by which to scale the rect. A ratio of 2 will double the dimensions of the rect while a ratio of 0.5 will halve its dimensions.
|
|
25
|
+
# @return [Hash] a new rectangle with a scaled size.
|
|
26
|
+
def scale_rect rect, ratio; end
|
|
27
|
+
|
|
28
|
+
# The behavior is similar to scale_rect except that you can independently control the scale of each axis.
|
|
29
|
+
#
|
|
30
|
+
# The parameters are all named.
|
|
31
|
+
#
|
|
32
|
+
# @param percentage_x [Float] percentage to change the width (default value of 1.0)
|
|
33
|
+
# @param percentage_y [Float] percentage to change the height (default value of 1.0)
|
|
34
|
+
# @param anchor_x [Float] anchor repositioning of x (default value of 0.0)
|
|
35
|
+
# @param anchor_y [Float] anchor repositioning of y (default value of 0.0)
|
|
36
|
+
# @return [Hash] a new rectangle with a scaled size.
|
|
37
|
+
def scale_rect_extended opts; end
|
|
38
|
+
|
|
39
|
+
# @param start_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
40
|
+
# @param end_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
41
|
+
# @return [Float] Returns an angle in degrees from the start_point to the end_point (if you want the value in radians call .to_radians on the value returned).
|
|
42
|
+
def angle start_point, end_point; end
|
|
43
|
+
|
|
44
|
+
# @param start_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
45
|
+
# @param end_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
46
|
+
# @return [Float] Returns an angle in degrees from the end_point to the start_point (if you want the value in radians call .to_radians on the value returned).
|
|
47
|
+
def angle_from start_point, end_point; end
|
|
48
|
+
|
|
49
|
+
# @param start_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
50
|
+
# @param end_point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
51
|
+
# @return [Float] Returns an angle in degrees to the end_point from the start_point (if you want the value in radians, you can call .to_radians on the value returned):
|
|
52
|
+
def angle_to start_point, end_point; end
|
|
53
|
+
|
|
54
|
+
# Returns 1 or -1 depending on which direction the angle needs to turn to reach the target_angle most efficiently.
|
|
55
|
+
#
|
|
56
|
+
# The angles are assumed to be in degrees.
|
|
57
|
+
#
|
|
58
|
+
# 1 means turn clockwise, and -1 means turn counter-clockwise.
|
|
59
|
+
#
|
|
60
|
+
# @param angle [Numeric]
|
|
61
|
+
# @param target_angle [Numeric]
|
|
62
|
+
# @return [Integer] Returns 1 or -1 depending on which direction the angle needs to turn to reach the target_angle most efficiently.
|
|
63
|
+
# 1 means turn clockwise, and -1 means turn counter-clockwise.
|
|
64
|
+
def angle_turn_direction angle, target_angle; end
|
|
65
|
+
|
|
66
|
+
# Given an angle and a target_angle, this function will return the smallest angle delta between the two angles.
|
|
67
|
+
#
|
|
68
|
+
# The angles are assumed to be in degrees.
|
|
69
|
+
#
|
|
70
|
+
# @param angle [Numeric]
|
|
71
|
+
# @param target_angle [Numeric]
|
|
72
|
+
# @return [Float] Given an angle and a target_angle, this function will return the smallest angle delta between the two angles.
|
|
73
|
+
def angle_delta angle, target_angle; end
|
|
74
|
+
|
|
75
|
+
# Given a test_angle, target_angle, and range (all in degrees), this function will return true if the test_angle is within the range of the target_angle on either side.
|
|
76
|
+
#
|
|
77
|
+
# The range is the number of degrees from the target_angle that the test_angle can be within to return true.
|
|
78
|
+
#
|
|
79
|
+
# @param test_angle [Float]
|
|
80
|
+
# @param target_angle [Float]
|
|
81
|
+
# @param range [Float]
|
|
82
|
+
# @return [Boolean] return true if the test_angle is within the range of the target_angle on either side.
|
|
83
|
+
def angle_within_range test_angle, target_angle, range; end
|
|
84
|
+
|
|
85
|
+
# Returns the distance between two points
|
|
86
|
+
#
|
|
87
|
+
# @param p1 [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
88
|
+
# @param p2 [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
89
|
+
# @return [Float] Returns the distance between p1 and p2
|
|
90
|
+
def distance p1, p2; end
|
|
91
|
+
|
|
92
|
+
# Returns true if a point is inside of a circle defined as a center point and radius.
|
|
93
|
+
#
|
|
94
|
+
# @param circle_center [Object]
|
|
95
|
+
# @param circle_radius [Numeric]
|
|
96
|
+
# @return [Boolean] Returns true if a point is inside of a circle defined as a center point and radius.
|
|
97
|
+
def point_inside_circle? circle_center, circle_radius; end
|
|
98
|
+
|
|
99
|
+
# Given a target rect and a reference rect, the target rect is centered inside the reference rect (a new rect is returned).
|
|
100
|
+
#
|
|
101
|
+
# @param target_rect [Object]
|
|
102
|
+
# @param reference_rect [Object]
|
|
103
|
+
# @return [Hash] centered rect
|
|
104
|
+
def center_inside_rect target_rect, reference_rect; end
|
|
105
|
+
|
|
106
|
+
# Given a point and a line, ray_test returns one of the following symbols based on the location of the point relative to the line: :left, :right, :on
|
|
107
|
+
#
|
|
108
|
+
# @param point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
109
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
110
|
+
# @return [Symbol] returns one of the following symbols based on the location of the point relative to the line: :left, :right, :on
|
|
111
|
+
def ray_test point, line; end
|
|
112
|
+
|
|
113
|
+
# Given a line, this function returns a Hash with x and y keys representing a normalized representation of the rise and run of the line.
|
|
114
|
+
#
|
|
115
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
116
|
+
# @return [Hash] returns a Hash with x and y keys representing a normalized representation of the rise and run of the line.
|
|
117
|
+
def line_rise_run line; end
|
|
118
|
+
|
|
119
|
+
# Given two lines (:x, :y, :x2, :y2), this function returns point of intersection if the line segments intersect.
|
|
120
|
+
#
|
|
121
|
+
# If the line segments do not intersect, nil is returned.
|
|
122
|
+
#
|
|
123
|
+
# If you want the lines to be treated as infinite lines, use #ray_intersect.
|
|
124
|
+
#
|
|
125
|
+
# @param line_1 [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
126
|
+
# @param line_2 [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
127
|
+
# @rerturn [Hash,nil] returns point of intersection if the line segments intersect, nil if not
|
|
128
|
+
def line_intersect line_1, line_2; end
|
|
129
|
+
|
|
130
|
+
# Given two lines (:x, :y, :x2, :y2), this function returns point of intersection if the ray (infinite line) intersect.
|
|
131
|
+
#
|
|
132
|
+
# If the lines are parallel, nil is returned.
|
|
133
|
+
#
|
|
134
|
+
# If you do not want the lines to be treated as infinite lines, use line_intersect.
|
|
135
|
+
#
|
|
136
|
+
# @param line_1 [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
137
|
+
# @param line_2 [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
138
|
+
# @rerturn [Hash,nil] returns point of intersection if the ray(infinite line) intersect, nil if not
|
|
139
|
+
def ray_intersect line_1, line_2; end
|
|
140
|
+
|
|
141
|
+
# Given a point and an angle in degrees, a new point is returned that is rotated around the origin by the degrees amount.
|
|
142
|
+
#
|
|
143
|
+
# An optional third argument can be provided to rotate the angle around a point other than the origin.
|
|
144
|
+
#
|
|
145
|
+
# @param point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
146
|
+
# @param angle [Numeric]
|
|
147
|
+
# @return [Hash] a new point is returned that is rotated around the origin by the degrees amount.
|
|
148
|
+
def rotate_point point, angle; end
|
|
149
|
+
|
|
150
|
+
# Given a rect and a collection of rects, find_intersect_rect returns the first rect that intersects with the the first parameter.
|
|
151
|
+
#
|
|
152
|
+
# :anchor_x, and anchor_y is taken into consideration if the objects respond to these methods.
|
|
153
|
+
#
|
|
154
|
+
# @param needle [Object] the rect you'd like to check for intersection on
|
|
155
|
+
# @param haystack [Array] the collection of rects you'd like to check against
|
|
156
|
+
# @return [Hash,nil] returns the first rect that intersects with the the first parameter. nil if either parameter is nil.
|
|
157
|
+
def find_intersect_rect needle, haystack; end
|
|
158
|
+
|
|
159
|
+
# Given a rect and a collection of rects, find_intersect_rect returns the first rect that intersects with the the first parameter.
|
|
160
|
+
#
|
|
161
|
+
# :anchor_x, and anchor_y is taken into consideration if the objects respond to these methods.
|
|
162
|
+
#
|
|
163
|
+
# @param needle [Object] the rect you'd like to check for intersection on
|
|
164
|
+
# @param haystack [Array] the collection of rects you'd like to check against
|
|
165
|
+
# @return [Hash] returns the first rect that intersects with the the first parameter. Returns an empty Array if either parameter is nil.
|
|
166
|
+
def find_all_intersect_rect needle, haystack; end
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# This is a faster collision algorithm for determining if a rectangle intersects any rectangle in an array.
|
|
170
|
+
#
|
|
171
|
+
# In order to use find_intersect_rect_quad_tree, you must first generate a quad tree data structure using create_quad_tree
|
|
172
|
+
#
|
|
173
|
+
# Use this function if find_intersect_rect isn’t fast enough.
|
|
174
|
+
#
|
|
175
|
+
# @param needle [Object] the rect you'd like to check for intersection on
|
|
176
|
+
# @param quad_tree [Object] the generated quad_tree created with the rects you'd like to check against
|
|
177
|
+
# @return [Hash,nil] returns the first rect that intersects with the the first parameter. nil if either parameter is nil.
|
|
178
|
+
def find_intersect_rect_quad_tree needle, quad_tree; end
|
|
179
|
+
|
|
180
|
+
# This is a faster collision algorithm for determining if a rectangle intersects any rectangle in an array.
|
|
181
|
+
#
|
|
182
|
+
# In order to use find_intersect_rect_quad_tree, you must first generate a quad tree data structure using create_quad_tree
|
|
183
|
+
#
|
|
184
|
+
# Use this function if find_intersect_rect isn’t fast enough.
|
|
185
|
+
#
|
|
186
|
+
# @param needle [Object] the rect you'd like to check for intersection on
|
|
187
|
+
# @param quad_tree [Object] the generated quad_tree created with the rects you'd like to check against
|
|
188
|
+
# @return [Array] returns an array of Rects from the quad_tree that intersect with the the first parameter.
|
|
189
|
+
def find_all_intersect_rect_quad_tree needle, quad_tree; end
|
|
190
|
+
|
|
191
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
192
|
+
# @return [Numeric] Given a line, this function will return the angle of the line in degrees.
|
|
193
|
+
def line_angle line; end
|
|
194
|
+
|
|
195
|
+
# Given two Hashes with x and y keys (or Objects that respond to x and y), this function will return the dot product of the two vectors.
|
|
196
|
+
#
|
|
197
|
+
# @param vec_1 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
198
|
+
# @param vec_2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
199
|
+
# @return [Numeric] return the dot product of the two vectors.
|
|
200
|
+
def vec2_dot_product vec_1, vec_2; end
|
|
201
|
+
|
|
202
|
+
# Given a Hash with x and y keys (or an Object that responds to x and y), this function will return a Hash with x and y keys that represents the vector normalized.
|
|
203
|
+
#
|
|
204
|
+
# @param vec_1 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
205
|
+
# @param vec_2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
206
|
+
# @return [Hash] return a Hash with x and y keys that represents the vector normalized.
|
|
207
|
+
def vec2_normalize vec2; end
|
|
208
|
+
|
|
209
|
+
# Given an Object with x, y, w, h, (and optionally anchor_x, anchor_y), this function returns a Hash in the following form.
|
|
210
|
+
#
|
|
211
|
+
# ```
|
|
212
|
+
# {
|
|
213
|
+
# x: ...,
|
|
214
|
+
# y: ...,
|
|
215
|
+
# w: ...,
|
|
216
|
+
# h: ...,
|
|
217
|
+
# center: {
|
|
218
|
+
# x: ...,
|
|
219
|
+
# y: ...,
|
|
220
|
+
# }
|
|
221
|
+
# }
|
|
222
|
+
# ```
|
|
223
|
+
#
|
|
224
|
+
# @param rect [Object] rect
|
|
225
|
+
# @return [Hash]
|
|
226
|
+
def rect_props rect; end
|
|
227
|
+
|
|
228
|
+
# Given a line, this function will return a Hash with x and y keys that represents the vector of the line.
|
|
229
|
+
#
|
|
230
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
231
|
+
# @return [Hash] a Hash with x and y keys that represents the vector of the line.
|
|
232
|
+
def line_vec2 line; end
|
|
233
|
+
|
|
234
|
+
# Given a Hash with x and y keys (or an Object that responds to x and y), this function will return the magnitude of the vector.
|
|
235
|
+
#
|
|
236
|
+
# @param vec2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
237
|
+
# @return [Numeric] the magnitude of the vector.
|
|
238
|
+
def vec2_magnitude vec2; end
|
|
239
|
+
|
|
240
|
+
# Given two Hashes with x and y keys (or Objects that respond to x and y), this function will return the distance squared between the two points.
|
|
241
|
+
#
|
|
242
|
+
# This is useful when you only want to compare distances, and don’t need the actual distance.
|
|
243
|
+
#
|
|
244
|
+
# @param vec_1 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
245
|
+
# @param vec_2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
246
|
+
# @return [Numeric] the distance squared between the two points
|
|
247
|
+
def distance_squared vec_1, vec_2; end
|
|
248
|
+
|
|
249
|
+
# Given a Hash with x and y keys (or an Object that responds to x and y), this function will return a Hash with x and y keys that represents the normal of the vector.
|
|
250
|
+
#
|
|
251
|
+
# @param vec2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
252
|
+
# @return [Hash] a Hash with x and y keys that represents the normal of the vector.
|
|
253
|
+
def vec2_normal vec2; end
|
|
254
|
+
|
|
255
|
+
# Check whether a circle intersects a line.
|
|
256
|
+
#
|
|
257
|
+
# @param circle [Object] a Hash with x, y, and radius keys (or an Object that responds to x, y, and radius).
|
|
258
|
+
# @param line [Object] a Hash with x, y, x2, and y2 keys (or an Object that responds to x, y, x2, and y2).
|
|
259
|
+
# @return [Boolean] true if the circle intersects the line, and false if it does not.
|
|
260
|
+
def circle_intersect_line? circle, line; end
|
|
261
|
+
|
|
262
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
263
|
+
# @param vec2 [Object] a Hash with x and y keys (or an Object that responds to x and y).
|
|
264
|
+
# @return [Hash] a Hash with x and y keys that represents the normal of the line relative to the point provided.
|
|
265
|
+
def line_normal line, vec2; end
|
|
266
|
+
|
|
267
|
+
# @param point [Object] a point (a Hash with x and y keys, or an Object that responds to x and y).
|
|
268
|
+
# @param line [Object] a line (a Hash with x, y, x2, and y2 keys, or an Object that responds to x, y, x2, and y2).
|
|
269
|
+
# @return [Boolean] This function will return true if the point is on the line, and false if it is not.
|
|
270
|
+
def point_on_line? point, line; end
|
|
271
|
+
|
|
272
|
+
# Given an Array of rects, returns a Hash of collisions.
|
|
273
|
+
#
|
|
274
|
+
# Each entry in the return Hash maps two rects from the input Array that intersect.
|
|
275
|
+
#
|
|
276
|
+
# Note that in the event of an intersection of rects A and B, the returned Hash will contain two entries: {A=>B,B=>A}
|
|
277
|
+
#
|
|
278
|
+
# @param rects [Array] an array of rects
|
|
279
|
+
# @return [Hash] collisions of rects within array.
|
|
280
|
+
def find_collisions rects; end
|
|
281
|
+
|
|
282
|
+
# Given a collection of rects, this function returns the next rect provided a move direction.
|
|
283
|
+
#
|
|
284
|
+
# The function is helpful for navigating controls using a keyboard or controller (like in on a menu screen).
|
|
285
|
+
#
|
|
286
|
+
# @param rect [Object]
|
|
287
|
+
# @param rects [Array] array of Rects
|
|
288
|
+
# @param left_right [Integer] A number that’s either -1, 0, or 1 indicating the x navigation direction.
|
|
289
|
+
# @param up_down [Integer] A number that’s either -1, 0, or 1 indicating the y navigation direction.
|
|
290
|
+
# @param directional_vector [Object] An object that responds to x, and y. The sign of these properties will be used to populate left_right, and up_down parameters.
|
|
291
|
+
# @param wrap_x [Boolean] Determines whether the navigation will wrap around if no navigation is found in the left_right direction. Defaulted to true.
|
|
292
|
+
# @param wrap_y [Boolean] Determines whether the navigation will wrap around if no navigation is found in the up_down direction. Defaulted to true.
|
|
293
|
+
# @param using [Proc] Optional lambda that can be passed in so the function knows which construct contains the properties x, y, w, h properties. If this parameter isn’t provided, then the source rect, rects objects are assumed to have x, y, w, h.
|
|
294
|
+
def rect_navigate opts; end
|
|
295
|
+
|
|
296
|
+
# Generates a quad tree from an array of rectangles. See #find_intersect_rect_quad_tree for usage.
|
|
297
|
+
#
|
|
298
|
+
# @param rects [Array] array of rects to form a quad_tree
|
|
299
|
+
# @return [Object] quad_tree to be used with #find_intersect_rect_quad_tree and #find_all_intersect_rect_quad_tree
|
|
300
|
+
def create_quad_tree rects; end
|
|
301
|
+
|
|
302
|
+
# Callback based many to many collision check.
|
|
303
|
+
#
|
|
304
|
+
# An implicit block is required for this function. The block will be called with each pair of intersecting rectangles.
|
|
305
|
+
#
|
|
306
|
+
# ```ruby
|
|
307
|
+
# rects_1 = [{ x: 0, y: 0, w: 100, h: 100 }]
|
|
308
|
+
# rects_2 = [{ x: 50, y: 50, w: 100, h: 100 }]
|
|
309
|
+
#
|
|
310
|
+
# args.geometry.each_intersect_rect(rects_1, rects_2) do |rect_1, rect_2|
|
|
311
|
+
# \# do something with the intersecting rectangles
|
|
312
|
+
# end
|
|
313
|
+
# ```
|
|
314
|
+
#
|
|
315
|
+
# - See [Advanced Usage](https://docs.dragonruby.org/#/api/geometry?id=advanced-usage)
|
|
316
|
+
#
|
|
317
|
+
# @param rects_1 [Object] The first parameter can be an array or a single Hash (or an object that responds to x, y, w, h).
|
|
318
|
+
# @param rects_2 [Object] The second parameter can be an array or a single Hash (or an object that responds to x, y, w, h). The second parameter should be the larger of the two sets of rectangles.
|
|
319
|
+
# @param tolerance [Float] The third parameter is optional and is the tolerance for the intersection. The default value is 0.1.
|
|
320
|
+
# @param using [Proc,Symbol] An optional using: named parameter can be given to specify what function should be used to extract the x, y, w, and h properties from the objects in the first and second parameters. If it is a Proc, it will be called with the object in the first and second parameters.
|
|
321
|
+
def each_intersect_rect rects1, rect2; end
|
|
322
|
+
|
|
323
|
+
# Given a rectangle (a something with x, y, w, h, and optionally anchor\_x, anchor\_y properties), this function returns an array of four lines representing the edges of the rectangle. The lines are ordered as: bottom, right, top, left.
|
|
324
|
+
#
|
|
325
|
+
# @param rect [Hash]
|
|
326
|
+
# @return [Array] array of four lines representing the edges of the rectangle. The lines are ordered as: bottom, right, top, left.
|
|
327
|
+
def rect_to_lines(rect)
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# Given two points (each with x and y properties), this function returns a Hash(x:, y:, x2:, y2:) representing a line. The line starts at point p1 and ends at point p2.
|
|
331
|
+
#
|
|
332
|
+
# @param p1 [Object]
|
|
333
|
+
# @param p2 [Object]
|
|
334
|
+
# @return [Hash] Hash representing a line between p1 and p2.
|
|
335
|
+
def line_to_points(p1, p2)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Given a rectangle, this function returns a new rectangle with adjusted dimensions while maintaining the center point.
|
|
339
|
+
#
|
|
340
|
+
# You can zoom using either ratio-based or pixel-based parameters, but not both.
|
|
341
|
+
#
|
|
342
|
+
# Returns Hash(x:, y:, w:, h:, center: Hash(x:, y:)).
|
|
343
|
+
#
|
|
344
|
+
# @param rect [Object]
|
|
345
|
+
# @param ratio [Numeric] uniform scaling ratio for both width and height
|
|
346
|
+
# @param w_ratio [Numeric] scaling ratio for width (overrides ratio for width)
|
|
347
|
+
# @param h_ratio [Numeric] scaling ratio for height (overrides ratio for height)
|
|
348
|
+
# @param px [Numeric] uniform pixel adjustment for both width and height
|
|
349
|
+
# @param w_px [Numeric] pixel adjustment for width (overrides px for width)
|
|
350
|
+
# @param h_px [Numeric] pixel adjustment for height (overrides px for height)
|
|
351
|
+
# @return [Hash]
|
|
352
|
+
def zoom_rect(rect, ratio, w_ratio, h_ratio, px, w_px, h_px)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Given two rectangles and an interpolation step, this function returns a new rectangle that represents the linear interpolation between the from and to rectangles.
|
|
356
|
+
#
|
|
357
|
+
# Returns Hash(x:, y:, w:, h:, center: Hash(x:, y:)).
|
|
358
|
+
#
|
|
359
|
+
# @param from [Object] the starting rectangle
|
|
360
|
+
# @param to [Object] the ending rectangle
|
|
361
|
+
# @param step [Numeric] the interpolation step (typically a value between 0.0 and 1.0, where 0.0 returns the from rect and 1.0
|
|
362
|
+
# @param tolerance [Numeric] optional tolerance parameter passed to the underlying lerp function (default 0)
|
|
363
|
+
# @return [Hash]
|
|
364
|
+
def lerp_rect(from, to, step, tolerance)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Generates basic 3D Perlin noise at the given coordinates.
|
|
368
|
+
#
|
|
369
|
+
# @param x [Numeric]
|
|
370
|
+
# @param y [Numeric]
|
|
371
|
+
# @param z [Numeric]
|
|
372
|
+
# @param x_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
373
|
+
# @param y_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
374
|
+
# @param z_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
375
|
+
# @return [Numeric] float value representing the noise at the given coordinates.
|
|
376
|
+
def perlin_noise(x, y, z, x_wrap, y_wrap, z_wrap)
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Generates 3D Perlin noise with a custom seed value for reproducible results.
|
|
380
|
+
#
|
|
381
|
+
# @param x [Numeric]
|
|
382
|
+
# @param y [Numeric]
|
|
383
|
+
# @param z [Numeric]
|
|
384
|
+
# @param x_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
385
|
+
# @param y_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
386
|
+
# @param z_wrap [Numeric] Wrapping values for tiling (use 0 for no wrapping)
|
|
387
|
+
# @param seed [Numeric] Integer seed value for reproducible noise generation
|
|
388
|
+
# @return [Numeric] float value representing the noise at the given coordinates.
|
|
389
|
+
def perlin_noise_seed(x, y, z, x_wrap, y_wrap, z_wrap, seed)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# Generates ridge noise, useful for creating mountain ridges and sharp terrain features.
|
|
393
|
+
#
|
|
394
|
+
# @param x [Numeric]
|
|
395
|
+
# @param y [Numeric]
|
|
396
|
+
# @param z [Numeric]
|
|
397
|
+
# @param lacunarity [Numeric] Controls the frequency increase per octave (typically 2.0)
|
|
398
|
+
# @param gain [Numeric] Controls the amplitude decrease per octave (typically 0.5)
|
|
399
|
+
# @param offset [Numeric] Ridge offset value (typically 1.0)
|
|
400
|
+
# @param octaves [Numeric] Number of noise layers to combine (typically 6)
|
|
401
|
+
# @return [Numeric] Returns a float value representing the ridge noise at the given coordinates.
|
|
402
|
+
def perlin_ridge_noise(x, y, z, lacunarity, gain, offset, octaves)
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Generates Fractional Brownian Motion (fBm) noise, useful for natural-looking textures like clouds, terrain, and wood grain.
|
|
406
|
+
#
|
|
407
|
+
# @param x [Numeric]
|
|
408
|
+
# @param y [Numeric]
|
|
409
|
+
# @param z [Numeric]
|
|
410
|
+
# @param lacunarity [Numeric] Controls the frequency increase per octave (typically 2.0)
|
|
411
|
+
# @param gain [Numeric] Controls the amplitude decrease per octave (typically 0.5)
|
|
412
|
+
# @param octaves [Numeric] Number of noise layers to combine (typically 6)
|
|
413
|
+
# @return [Numeric] Returns a float value representing the ridge noise at the given coordinates.
|
|
414
|
+
def perlin_fbm_noise(x, y, z, lacunarity, gain, offset, octaves)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Generates turbulence noise using absolute values, useful for marble, fire, and liquid effects.
|
|
418
|
+
#
|
|
419
|
+
# @param x [Numeric]
|
|
420
|
+
# @param y [Numeric]
|
|
421
|
+
# @param z [Numeric]
|
|
422
|
+
# @param lacunarity [Numeric] Controls the frequency increase per octave (typically 2.0)
|
|
423
|
+
# @param gain [Numeric] Controls the amplitude decrease per octave (typically 0.5)
|
|
424
|
+
# @param octaves [Numeric] Number of noise layers to combine (typically 6)
|
|
425
|
+
# @return [Numeric] Returns a float value representing the ridge noise at the given coordinates.
|
|
426
|
+
def perlin_turbulence_noise(x, y, z, lacunarity, gain, offset, octaves)
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @type [GTK::Args]
|
|
2
|
+
$args = GTK::Args.new
|
|
3
|
+
|
|
4
|
+
# @type [GTK::Inputs]
|
|
5
|
+
$inputs = GTK::Inputs.new
|
|
6
|
+
|
|
7
|
+
# @type [GTK::Outputs]
|
|
8
|
+
$outputs = GTK::Outputs.new
|
|
9
|
+
|
|
10
|
+
# @type [GTK::Runtime]
|
|
11
|
+
$gtk = GTK::Runtime.new
|
|
12
|
+
|
|
13
|
+
# @type [GTK::Runtime]
|
|
14
|
+
$dr = GTK::Runtime.new
|
|
15
|
+
|
|
16
|
+
# @type [Module<GTK::Geometry>]
|
|
17
|
+
$geometry = GTK::Geometry
|