Skip to content

Commit 73fdeb2

Browse files
authored
AtlasBase: add l, r, t, b getters to AtlasRect (#3588)
* AtlasRect: add l, r, t, b getters Refactor AtlasRect as an abstract type with getter methods for left, right, top, and bottom coordinates. * inline toFlxRect * add package fix ci
1 parent 0860515 commit 73fdeb2

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

flixel/graphics/atlas/AtlasBase.hx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,24 @@ typedef AtlasPos =
2828
/**
2929
* Rectangle struct use for atlas json parsing, { x:Float, y:Float, w:Float, h:Float }
3030
*/
31-
typedef AtlasRect = AtlasPos & AtlasSize;
31+
@:forward
32+
abstract AtlasRect(AtlasPos & AtlasSize) from AtlasPos & AtlasSize
33+
{
34+
public var l(get, never):Float; inline function get_l() return this.x;
35+
public var r(get, never):Float; inline function get_r() return this.x + this.w;
36+
public var t(get, never):Float; inline function get_t() return this.y;
37+
public var b(get, never):Float; inline function get_b() return this.y + this.h;
38+
39+
overload public inline extern function toFlxRect(rect:flixel.math.FlxRect)
40+
{
41+
return rect.set(this.x, this.y, this.w, this.h);
42+
}
43+
44+
overload public inline extern function toFlxRect()
45+
{
46+
return flixel.math.FlxRect.get(this.x, this.y, this.w, this.h);
47+
}
48+
}
3249

3350
typedef AtlasFrame =
3451
{

0 commit comments

Comments
 (0)