struct Godot::Rect2

Overview

2D axis-aligned bounding box defined by a position and size with 32-bit floating point precision.

Defined in:

libgodot/types/rect2.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(x : Number, y : Number, width : Number, height : Number) #

def self.new(position : Vector2 = Vector2.new, size : Vector2 = Vector2.new) #

def self.new(pointer : Pointer(Void)) #

Instance Method Detail

def !=(other : Rect2) : Bool #

def ==(other : Rect2) : Bool #

def abs : Rect2 #

Returns a Rect2 with non-negative width and height.


def area : Float32 #

Returns the surface area of this Rect2.


def encloses(b : Rect2) : Bool #

Returns true if this Rect2 completely encloses another.


def encloses?(b : Rect2) : Bool #

def end : Vector2 #

Returns the ending point (position + size).


def end=(value : Vector2) #

def expand(to : Vector2) : Rect2 #

Returns a larger Rect2 that includes the given point.


def grow(by : Number) : Rect2 #

Returns a copy of this Rect2 grown by the given amount on all sides.


def grow_individual(left : Number, top : Number, right : Number, bottom : Number) : Rect2 #

Returns a copy of this Rect2 grown individually on each side.


def has_area? : Bool #

Returns true if this Rect2 has a positive area.


def has_point(point : Vector2) : Bool #

Returns true if the point is inside the rectangle.


def has_point?(point : Vector2) : Bool #

def intersection(b : Rect2) : Rect2 #

Returns the intersection of this Rect2 and another.


def intersects(b : Rect2, include_borders : Bool = false) : Bool #

Returns true if this Rect2 intersects with another.


def intersects?(b : Rect2) : Bool #

def is_equal_approx(other : Rect2) : Bool #

def merge(b : Rect2) : Rect2 #

Returns a larger Rect2 that encloses both this and another Rect2.


def position : Vector2 #

def position=(position : Vector2) #

def size : Vector2 #

def size=(size : Vector2) #

def to_i : Rect2i #

def to_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).