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 mk
fn fromVf2*(p: th::Vf2, dm: th::Vf2): Rect {
Creates a rect from two Vf2s - the position and the dimensions.
fn Rect.getPos
fn (r: ^Rect) getPos*(): th::Vf2 {
fn Rect.getDims
fn (r: ^Rect) getDims*(): th::Vf2 {
fn Rect.getEnd
fn (r: ^Rect) getEnd*(): th::Vf2 {
returns where the second point of the rectangle lies.
fn Rect.transformed
fn (r: ^Rect) transformed*(t: th::Transform): th::Quad {
Transforms a rect into a quad. Order:
- scale
- rotation
- position
fn Rect.shrink
fn (r: ^Rect) shrink*(p: th::Vf2): Rect {
Shrink the rectangle by p
pixels from all sides.
fn Rect.shift
fn (r: ^Rect) shift*(p: th::Vf2): Rect {
Shift the rectangle by p
pixels.
fn Rect.scale
fn (r: ^Rect) scale*(p: th::Vf2): Rect {
Multiply the dimensions by p
fn Rect.center
fn (r: ^Rect) center*(): th::Vf2 {
Returns the position, which is the center of the rect.
fn Rect.centerWithinRect
fn (r: ^Rect) centerWithinRect*(child: Rect): Rect {
Centers child
with the rect r
.