0 votes

The documentation for Godot's method Rect2.abs() said: "Returns a Rect2 with equivalent position and area, modified so that the top-left corner is the origin and width and height are positive". But in the end, abs() doesn't change anything. Is this a bug or am I doing something wrong?

var square = Rect2(area.position, area.scale) # area is Node2D
print(area.name, square.position, square.abs().position)

What will be displayed:
Area1(400, 2500)(400, 2500)

in Engine by (22 points)

1 Answer

0 votes
Best answer

Hi, i asked on IRC and Akien explained me that that function does not move the Rect to the origin.

Rect2(0, 0, -100, 50).abs() should be Rect2(-100, 0, 100, 50)

What abs does it to take the Rect and transform it coordinates to positive taking left-top corner as the origin of the rect. It does not move Rect to origin. In fact, it does not move the rect, just make Rect sizes positive values.

by (3,505 points)
selected by

Oh, thanks. It seems i involuntary made a mush with another method

You are welcome!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.