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 Vec2A 2D vector in game-defined units. An omitted field is 0.
Vec2.copy
ts
copy(): Vec2A vector with the same components.
Vec2.add
ts
add(other: Vec2): Vec2The component-wise sum.
Vec2.subtract
ts
subtract(other: Vec2): Vec2The component-wise difference.
Vec2.scaleBy
ts
scaleBy(value: float): Vec2This 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(): stringPoint struct
ts
struct PointAn integer position, such as a cursor in pixels. An omitted field is 0.
ts
x: int
y: int
operator eq(other: Point): boolean
toString(): stringVec3 struct
ts
struct Vec3A 3D vector in game-defined units. An omitted field is 0.
Vec3.copy
ts
copy(): Vec3A vector with the same components.
Vec3.add
ts
add(other: Vec3): Vec3The component-wise sum.
Vec3.subtract
ts
subtract(other: Vec3): Vec3The component-wise difference.
Vec3.scaleBy
ts
scaleBy(value: float): Vec3This 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(): stringSize struct
ts
struct SizeA width and a height. An omitted field is 0.
ts
width: float
height: float
operator eq(other: Size): boolean
toString(): stringRect struct
ts
struct RectAn 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(): floatExclusive maximum x coordinate.
Rect.bottom
ts
get bottom(): floatExclusive maximum y coordinate.
Rect.center
ts
get center(): Vec2The midpoint of both extents.
Rect.copy
ts
copy(): RectA rectangle with identical edges.
Rect.translated
ts
translated(delta: Vec2): RectA copy offset by delta, with the same extents.
Rect.contains
ts
contains(point: Vec2): booleanTrue for points inside the half-open rectangle: [x, x+width) × [y, y+height).
Rect.intersects
ts
intersects(other: Rect): booleanTrue when the rectangles overlap; touching edges or corners do not count.
Rect.fromCenter
ts
static fromCenter(center: Vec2, size: Vec2): RectA rectangle around a midpoint; throws when a size component is negative.
Rect.union
ts
static union(first: Rect, second: Rect): RectThe smallest rectangle containing both inputs.
Other members of Rect
ts
x: float
y: float
width: float
height: float
operator eq(other: Rect): boolean
toString(): stringGenerated from lang/geometry/index.tks in the ThicketScript repository.