Skip to content

Debug draw

abstract class CP::Space::DebugDraw
inherits Reference #

Direct known subclasses

SFMLDebugDraw

Constants#

COLLISION_POINT_COLOR = Color.new(1.0, 0.0, 0.0)#

Color passed to drawing functions for collision points.

CONSTRAINT_COLOR = Color.new(0.0, 0.75, 0.0)#

Color passed to drawing functions for constraints.

SHAPE_OUTLINE_COLOR = Color.new(*{200, 210, 230}.map(&./(255.0)))#

Outline color passed to the drawing function.

Constructors#

.new(flags : CP::Space::DebugDraw::Flags = Flags::All)#

View source

Class methods#

.color_for_hash(hash : Int, intensity : Number) : Color#

View source

Methods#

#color_for_shape(shape : Shape) : Color#

Returns a color for a given shape.

This gives you an opportunity to color shapes based on how they are used in your engine.

View source

#draw(space : Space)#

Debug draw the current state of the space.

View source

abstract #draw_circle(pos : Vect, angle : Float64, radius : Float64, outline_color : Color, fill_color : Color)#

Draw a filled, stroked circle.

View source

abstract #draw_dot(size : Float64, pos : Vect, color : Color)#

Draw a dot.

View source

abstract #draw_fat_segment(a : Vect, b : Vect, radius : Float64, outline_color : Color, fill_color : Color)#

Draw a thick line segment.

View source

abstract #draw_polygon(verts : Slice(Vect), radius : Float64, outline_color : Color, fill_color : Color)#

Draw a convex polygon.

View source

abstract #draw_segment(a : Vect, b : Vect, color : Color)#

Draw a line segment.

View source

#flags : Flags#

View source

#flags=(flags : Flags)#

View source

struct CP::Space::DebugDraw::Color
inherits Struct #

Color type to use with the space debug drawing API.

Constructors#

.gray(l : Float, a : Float = 1.0_f32) : self#

View source

.new(r : Float, g : Float, b : Float, a : Float = 1.0_f32)#

View source

Methods#

#a : Float32#

View source

#a=(a : Float32)#

View source

#b : Float32#

View source

#b=(b : Float32)#

View source

#g : Float32#

View source

#g=(g : Float32)#

View source

#r : Float32#

View source

#r=(r : Float32)#

View source

enum CP::Space::DebugDraw::Flags #

Flags that request which things to draw (collision shapes, constraints, contact points).

Members#

DRAW_SHAPES = 1#

DRAW_CONSTRAINTS = 2#

DRAW_COLLISION_POINTS = 4#

Methods#

#draw_collision_points?#

View source

#draw_constraints?#

View source

#draw_shapes?#

View source

#none?#

View source

class SFMLDebugDraw
inherits CP::Space::DebugDraw #

Constructors#

.new(target : SF::RenderTarget, states : SF::RenderStates = SF::RenderStates::Default)#

View source

Methods#

#draw_circle(pos : CP::Vect, angle : Float64, radius : Float64, outline_color : Color, fill_color : Color)#

Draw a filled, stroked circle.

View source

#draw_dot(size : Float64, pos : CP::Vect, color : Color)#

Draw a dot.

View source

#draw_fat_segment(a : CP::Vect, b : CP::Vect, radius : Float64, outline_color : Color, fill_color : Color)#

Draw a thick line segment.

View source

#draw_polygon(verts : Slice(CP::Vect), radius : Float64, outline_color : Color, fill_color : Color)#

Draw a convex polygon.

View source

#draw_segment(a : CP::Vect, b : CP::Vect, color : Color)#

Draw a line segment.

View source

#states : SF::RenderStates#

View source

#states=(states : SF::RenderStates)#

View source

#update#

View source

class SFMLDebugDraw::RoundedPolygon
inherits SF::Shape #

Constructors#

Methods#

#assign(points, radius : Number)#

View source

#get_point(index : Int) : SF::Vector2f#

Get a point of the shape

The returned point is in local coordinates, that is, the shape's transforms (position, rotation, scale) are not taken into account. The result is undefined if index is out of the valid range.

  • index - Index of the point to get, in range 0 ... point_count

Returns: index-th point of the shape

See also: point_count

View source

#point_count : Int32#

Get the total number of points of the shape

Returns: Number of points of the shape

See also: point

View source