-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement Box.Inflate with System.Drawing matching functionality #1616
Comments
Going to target this for |
@NogginBops so basically re-implement this from #1455 ? public void Inflate(Vector2 size)
{
size = Vector2.ComponentMax(size, -HalfSize);
_min -= size;
_max += size;
}
public Box2 Inflated(Vector2 size)
{
// create a local copy of this box
Box2 box = this;
box.Inflate(size);
return box;
} Here's the .NET 7 implementation (src): public void Inflate(int width, int height)
{
unchecked
{
X -= width;
Y -= height;
Width += 2 * width;
Height += 2 * height;
}
} |
I have this ready to PR, but I thought I'd go the extra mile and implement a real I'm no F# expert (I'm not even an F# amateur), nor am I a fan of unit tests, but I think this right. However, it fails due to what looks to me like a rounding error between C# and F#... How the heck do you deal with that? (And this is why I hate unit tests, anything non-trivial is essentially "rewriting the same code a slightly different way" and I inevitably spend more time debugging tests than real code.) module Inflate =
[<Property>]
let ``Box2.Inflate produces the expected min and max changes`` (b1 : Box2, v1 : Vector2) =
let size = Vector2.ComponentMax(v1, -b1.HalfSize);
let b = Box2(b1.Min - size, b1.Max + size)
Assert.Equal(b, b1.Inflated(v1)) Note "expected" from F# is
Maybe this is why the earlier PR skipped it? |
Description
In #1511 and #1615
Box.Inflate
got marked asObsolete
pending a change to the functionality of the function to matchSystem.Drawing.Rectangle.Inflate
.We should add a remark in the documentation of
Box.Inflate
that it used to do something else so that someone who is upgrading from4.7.7 -> 4.8.2
has any chance to find the issue when debugging.The text was updated successfully, but these errors were encountered: