class CP::Shape::Box

Overview

A special case of a polygon - a rectangle.

The boxes will always be centered at the center of gravity of the body you are attaching them to. If you want to create an off-center box, you will need to use Poly.

Defined in:

chipmunk/shape.cr

Constructors

Class Method Summary

Instance methods inherited from class CP::Shape::Poly

radius : Float64 radius, radius=(radius : Number) radius=, set_verts(verts : Array(Vect) | Slice(Vect), transform : Transform = Transform::IDENTITY) set_verts, size : Int32 size, unsafe_fetch(index : Int) : Vect unsafe_fetch

Constructor methods inherited from class CP::Shape::Poly

new(body : Body | Nil, verts : Array(Vect) | Slice(Vect), transform : Transform = Transform::IDENTITY, radius : Number = 0)
new(body : Body | Nil, verts : Array(Vect) | Slice(Vect), radius : Number)
new

Class methods inherited from class CP::Shape::Poly

area(verts : Array(Vect) | Slice(Vect), radius : Number = 0) : Float64 area, centroid(verts : Array(Vect) | Slice(Vect)) : Vect centroid, convex_hull(verts : Array(Vect) | Slice(Vect), tol : Number = 0) : Tuple(Slice(Vect), Int32) convex_hull, moment(m : Number, verts : Array(Vect) | Slice(Vect), offset : Vect = CP::Vect.new(0, 0), radius : Number = 0) : Float64 moment

Instance methods inherited from class CP::Shape

area : Float64 area, bb : BB bb, body : Body | Nil body, body=(body : Body | Nil) body=, cache_bb : BB cache_bb, center_of_gravity : Vect center_of_gravity, collide(b : Shape) : ContactPointSet collide, collision_type : CollisionType collision_type, collision_type=(collision_type : Int) collision_type=, density : Float64 density, density=(density : Number) density=, elasticity : Float64 elasticity, elasticity=(elasticity : Number) elasticity=, filter : ShapeFilter filter, filter=(filter : ShapeFilter) filter=, friction : Float64 friction, friction=(friction : Number) friction=, mass : Float64 mass, mass=(mass : Number) mass=, moment : Float64 moment, point_query(p : Vect) : PointQueryInfo point_query, segment_query(a : Vect, b : Vect, radius : Number = 0) : SegmentQueryInfo | Nil segment_query, sensor=(sensor : Bool) sensor=, sensor? : Bool sensor?, space : Space | Nil space, surface_velocity : Vect surface_velocity, surface_velocity=(surface_velocity : Vect) surface_velocity=, update(transform : Transform) : BB update

Constructor Detail

def self.new(body : Body | Nil, width : Number, height : Number, radius : Number = 0) #

Initialize a box shaped polygon shape with rounded corners.


[View source]
def self.new(body : Body | Nil, box : BB, radius : Number = 0) #

Initialize an offset box shaped polygon shape with rounded corners.


[View source]

Class Method Detail

def self.moment(m : Number, width : Number, height : Number) : Float64 #

Calculate the moment of inertia for a solid box.


[View source]
def self.moment(m : Number, box : BB) : Float64 #

Calculate the moment of inertia for a solid box.


[View source]