struct

CP::BB

Inherits Struct / Value / Object

Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)

Constructors

new(left : Number = 0, bottom : Number = 0, right : Number = 0, top : Number = 0)
Source
new_for_circle(p : Vect, r : Number) : self

Constructs a BB fitting a circle with the position p and radius r.

Source
new_for_extents(c : Vect, hw : Number, hh : Number) : self

Constructs a BB centered on a point with the given extents (half sizes).

Source

Instance methods

area

Returns the area of the bounding box.

Source
bottom
Source
bottom=(bottom : Float64)
Source
center

Returns the center of a bounding box.

Source
clamp_vect(v : Vect) : Vect

Clamp a vector to a bounding box

Source
contains?(other : BB) : Bool

Returns true if the other BB lies completely within this one.

Source
contains?(point : Vect) : Bool

Returns true if this BB contains the point.

Source
expand(point : Vect) : BB

Returns the minimal bounding box that contains both this BB and the point.

Source
intersects?(other : BB) : Bool

Returns true if this BB intersects the other.

Source
intersects_segment?(a : Vect, b : Vect) : Bool

Return true if the bounding box intersects the line segment with ends a and b.

Source
left
Source
left=(left : Float64)
Source
merge(other : BB) : BB

Returns a bounding box that holds both bounding boxes.

Source
offset(v : Vect) : BB

Returns a bounding box offseted by v.

Source
right
Source
right=(right : Float64)
Source
segment_query(a : Vect, b : Vect) : Float64

Returns the fraction along the segment query the BB is hit.

Returns INFINITY if it doesn't hit.

Source
top=(top : Float64)
Source
wrap_vect(v : Vect) : Vect

Wrap a vector to a bounding box.

Source