From 9ef3fec87f594d83159f0fb9d4b8e7389c295955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 11 Nov 2021 11:31:30 +0100 Subject: [PATCH] Rect2: Clarify docs for `has_point` excluding bottom and right borders Improve tests, as well as documentation for `expand`. (cherry picked from commit 36c4451a7b39e0503b11218903624e1ea8ee46c8) --- doc/classes/AABB.xml | 9 ++++++++- doc/classes/Rect2.xml | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index d2435cb229a..9b15793fd8a 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -39,7 +39,14 @@ - Returns this [AABB] expanded to include a given point. + Returns a copy of this [AABB] expanded to include a given point. + [b]Example:[/b] + [codeblock] + # position (-3, 2, 0), size (1, 1, 1) + var box = AABB(Vector3(-3, 2, 0), Vector3(1, 1, 1)) + # position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2) + var box2 = box.expand(Vector3(0, -1, 2)) + [/codeblock] diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index c60a20e1f1b..d5961ffd527 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -56,7 +56,14 @@ - Returns this [Rect2] expanded to include a given point. + Returns a copy of this [Rect2] expanded to include a given point. + [b]Example:[/b] + [codeblock] + # position (-3, 2), size (1, 1) + var rect = Rect2(Vector2(-3, 2), Vector2(1, 1)) + # position (-3, -1), size (3, 4), so we fit both rect and Vector2(0, -1) + var rect2 = rect.expand(Vector2(0, -1)) + [/codeblock] @@ -100,7 +107,8 @@ - Returns [code]true[/code] if the [Rect2] contains a point. + Returns [code]true[/code] if the [Rect2] contains a point. By convention, the right and bottom edges of the [Rect2] are considered exclusive, so points on these edges are [b]not[/b] included. + [b]Note:[/b] This method is not reliable for [Rect2] with a [i]negative size[/i]. Use [method abs] to get a positive sized equivalent rectangle to check for contained points.