API reference

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

C

classLine

@codexo/exojs / math / stable

Mutable line segment defined by two endpoint positions. Implements Collidable for intersection tests against all shape types. Note: `collidesWith` always returns `null` - lines support boolean intersection only; SAT response is not implemented for line segments. `contains(x, y, threshold)` tests whether `(x, y)` lies on the segment within a configurable threshold (default `0.1`). `Line.temp` is a shared scratch instance.

8
props
11
methods
0
events
Import
import { Line } from '@codexo/exojs'

Mutable line segment defined by two endpoint positions. Implements Collidable for intersection tests against all shape types.

Note: `collidesWith` always returns `null` - lines support boolean intersection only; SAT response is not implemented for line segments. `contains(x, y, threshold)` tests whether `(x, y)` lies on the segment within a configurable threshold (default `0.1`).

`Line.temp` is a shared scratch instance.

Constructors1
new(x1: number, y1: number, x2: number, y2: number): Line
Methods11
clone(): this
contains(x: number, y: number, threshold: number): boolean
Returns true if the point (x, y) is inside this shape.
copy(line: Line): this
destroy(): void
equals(__namedParameters: Partial<Line>): 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.
Return the outward-facing edge normals used by the SAT solver. The array should be cached and reused across calls.
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(x1: number, y1: number, x2: number, y2: number): this
Properties8
fromX: number
fromY: number
toX: number
toY: number
temp: Line
Source