On this page:
Point
Point  Like
Point  Like.to_  point
Point  Like.to_  point
Point.zero
Size
Size  Like
Size  Like.to_  size
Size  Like.to_  size
Size.zero
Rect
Rect.point
Rect.size
Rect  Like
Rect  Like.to_  rect
Rect  Like.to_  rect
Rect.zero
8.12

9 Point, Size, and Rectangle🔗ℹ

class

class Point(x :: Real, y :: Real)

 

annotation

PointLike

 

annotation

PointLike.to_point

 

function

fun PointLike.to_point(pt :: PointLike) :: Point

 

value

def Point.zero :: Point = Point(0, 0)

The Point class represents a point in two dimensions.

Methods that expect a point typically accept a value satisfying PointLike, which is any of the following:

The PointLike.to_point annotation is satified by any value that satisfis PointLike, and the value is converted to an equivalent Point object if it is not one already.

The PointLike.to_point function converts a PointLike value to a Point, like the PointLike.to_point annotation. An expression pt with static information from PointLike can call PointLike.to_point(pt) using pt.to_point().

Point.zero is a Point object with 0 values.

class

class Size(width :: NonnegReal, height :: NonnegReal)

 

annotation

SizeLike

 

annotation

SizeLike.to_size

 

function

fun SizeLike.to_size(sz :: SizeLike) :: Size

 

value

def Size.zero :: Size = Size(0, 0)

The Size class represents a size in two dimensions.

Methods that expect a size typically accept a value satisfying SizeLike, which is any of the following:

The SizeLike.to_size annotation, SizeLike.to_size function, and Size.zero value are anaologous to PointLike.to_point, PointLike.to_point, and Point.zero.

class

class Rect(x :: Real, y :: Real,

           width :: NonnegReal, height :: NonnegReal):

  constructor

  | (x :: Real, y :: Real,

     width :: NonnegReal, height :: NonnegReal)

  | (point :: PointLike, size :: SizeLike)

 

property

property (r :: Rect).point :: Point

 

property

property (r :: Rect).size :: Size

 

annotation

RectLike

 

annotation

RectLike.to_rect

 

function

fun RectLike.to_rect(sz :: RectLike) :: Rect

 

value

def Rect.zero :: Rect = Rect(0, 0, 0, 0)

The Rect class represents a rectagular region, where x and y correspond to the top-left of the rectangle. The Rect.point property produces x and y in a Point, while Rect.size property produces width and height in a Size.

Methods that expect a rectangle typically accept a value satisfying RectLike, which is any of the following:

The RectLike.to_rect annotation, RectLike.to_rect function, and Rect.zero value are anaologous to PointLike.to_point, PointLike.to_point, and Point.zero.