API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classCircle

@codexo/exojs / math / stable

Mutable circle shape defined by a centre position and radius. Implements Collidable for use in the collision pipeline. For SAT-based collision the circle is approximated as a regular polygon with Circle.collisionSegments sides; normals and vertices are cached and regenerated lazily when the shape mutates. `Circle.temp` is a shared scratch instance for intermediate calculations.

6
props
13
methods
0
events
Import
import { Circle } from '@codexo/exojs'

Mutable circle shape defined by a centre position and radius. Implements Collidable for use in the collision pipeline.

For SAT-based collision the circle is approximated as a regular polygon with Circle.collisionSegments sides; normals and vertices are cached and regenerated lazily when the shape mutates.

`Circle.temp` is a shared scratch instance for intermediate calculations.

Constructors1
new(x: number, y: number, radius: number): Circle
Methods13
clone(): this
Compute a full CollisionResponse between this shape and target. Returns null in two cases: - the shapes do not overlap, **or** - the specific shape-pair combination does not support response generation (e.g. Line against any shape, Ellipse against Ellipse or Polygon). Use intersectsWith for a universal boolean overlap check that works across all supported shape pairs.
contains(x: number, y: number): boolean
Returns true if the point (x, y) is inside this shape.
copy(circle: Circle): this
destroy(): void
equals(__namedParameters: Partial<Circle>): boolean
The axis-aligned bounding box of this object. Pass out to write into a rectangle you own - every implementer honours it, so this form is always safe to retain and never allocates. Without out, the math shape values (Rectangle, Circle, Polygon, ...) return a **fresh** rectangle, while a node or view that maintains a cached box (see SceneNode.getBounds) returns that cached instance, which the next invalidation overwrites.
Returns the edge normals for the approximated collision polygon. The returned array is cached and reused across calls - the same array reference is returned on consecutive calls when nothing has changed. This matches the Sprite.getNormals() behaviour introduced in 0.6.19. The cache is invalidated automatically when x, y, radius, position, setPosition, setRadius, set, or copy mutate the circle.
Test whether this shape overlaps target using a fast boolean algorithm (no penetration depth or normal computed). Prefer this over collidesWith when only the yes/no result is needed.
set(x: number, y: number, radius: number): this
setPosition(x: number, y: number): this
Set the circle's centre to (x, y). Invalidates the normal and vertex caches. Returns this for chaining.
setRadius(radius: number): this
Set the circle's radius. No-op when the value has not changed. Invalidates the normal and vertex caches. Returns this for chaining.
Properties6
collisionSegments: number
Number of polygon segments used to approximate the circle boundary for SAT collision tests. Increasing this improves accuracy at the cost of more normal comparisons. Default: 32.
radius: number
x: number
y: number
Source