Skip to content

Geometry ​

The Vec2, Point, Vec3, Size and Rect value types.

Always available

No import needed. These names are in scope in every file.

Vec2 struct ​

ts
struct Vec2

A 2D vector in game-defined units. An omitted field is 0.

Vec2.copy ​

ts
copy(): Vec2

A vector with the same components.

Vec2.add ​

ts
add(other: Vec2): Vec2

The component-wise sum.

Vec2.subtract ​

ts
subtract(other: Vec2): Vec2

The component-wise difference.

Vec2.scaleBy ​

ts
scaleBy(value: float): Vec2

This vector multiplied by a scalar.

Other members of Vec2 ​

ts
x: float
y: float
operator add(other: Vec2): Vec2
operator sub(other: Vec2): Vec2
operator mul(value: float): Vec2
operator neg(): Vec2
operator eq(other: Vec2): boolean
toString(): string

Point struct ​

ts
struct Point

An integer position, such as a cursor in pixels. An omitted field is 0.

ts
x: int
y: int
operator eq(other: Point): boolean
toString(): string

Vec3 struct ​

ts
struct Vec3

A 3D vector in game-defined units. An omitted field is 0.

Vec3.copy ​

ts
copy(): Vec3

A vector with the same components.

Vec3.add ​

ts
add(other: Vec3): Vec3

The component-wise sum.

Vec3.subtract ​

ts
subtract(other: Vec3): Vec3

The component-wise difference.

Vec3.scaleBy ​

ts
scaleBy(value: float): Vec3

This vector multiplied by a scalar.

Other members of Vec3 ​

ts
x: float
y: float
z: float
operator add(other: Vec3): Vec3
operator sub(other: Vec3): Vec3
operator mul(value: float): Vec3
operator neg(): Vec3
operator eq(other: Vec3): boolean
toString(): string

Size struct ​

ts
struct Size

A width and a height. An omitted field is 0.

ts
width: float
height: float
operator eq(other: Size): boolean
toString(): string

Rect struct ​

ts
struct Rect

An axis-aligned half-open rectangle: x and y are the top-left corner (inclusive), and the right and bottom edges are exclusive. Spans [x, x+width) × [y, y+height). A literal is not checked, so a negative width or height is the caller's to avoid.

Rect.right ​

ts
get right(): float

Exclusive maximum x coordinate.

Rect.bottom ​

ts
get bottom(): float

Exclusive maximum y coordinate.

Rect.center ​

ts
get center(): Vec2

The midpoint of both extents.

Rect.copy ​

ts
copy(): Rect

A rectangle with identical edges.

Rect.translated ​

ts
translated(delta: Vec2): Rect

A copy offset by delta, with the same extents.

Rect.contains ​

ts
contains(point: Vec2): boolean

True for points inside the half-open rectangle: [x, x+width) × [y, y+height).

Rect.intersects ​

ts
intersects(other: Rect): boolean

True when the rectangles overlap; touching edges or corners do not count.

Rect.fromCenter ​

ts
static fromCenter(center: Vec2, size: Vec2): Rect

A rectangle around a midpoint; throws when a size component is negative.

Rect.union ​

ts
static union(first: Rect, second: Rect): Rect

The smallest rectangle containing both inputs.

Other members of Rect ​

ts
x: float
y: float
width: float
height: float
operator eq(other: Rect): boolean
toString(): string

Generated from lang/geometry/index.tks in the ThicketScript repository.