Issue with Rect2D.abs()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By OrdinaryGuy

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(, square.position, square.abs().position)

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

:bust_in_silhouette: Reply From: p7f

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.

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

OrdinaryGuy | 2019-01-18 17:24

You are welcome!

p7f | 2019-01-18 17:25