Skip to content

rect.um

Marek Maskarinec edited this page Oct 9, 2022 · 2 revisions

rect.um

struct Rect*

type Rect* = struct {
	x, y, w, h: th.fu
}

A set of points representing a rectangle.

fn mk*

fn mk*(x, y, w, h: th.fu): Rect {

fn toWorld*

fn (r: ^rect.Rect) toWorld*(p: th.Vf2): th.Vf2 {

translates screen coordinates to world coordinates with cam r

fn toScreen*

fn (r: ^rect.Rect) toScreen*(p: th.Vf2): th.Vf2 {

translates world coordinates to screen coordinates with cam r

fn getPos*

fn (r: ^rect.Rect) getPos*(): th.Vf2 {

fn getDims*

fn (r: ^rect.Rect) getDims*(): th.Vf2 {

fn getEnd*

fn (r: ^rect.Rect) getEnd*(): th.Vf2 {

returns where the second point of the rectangle lies.

fn transformed*

fn (r: ^rect.Rect) transformed*(t: th.Transform): th.Quad {

Transforms a rect into a quad. Order: 1. scale 2. rotation 3. position

Clone this wiki locally