## Documentation ¶

### Overview ¶

Package fixed implements fixed-point integer types.

### Constants ¶

This section is empty.

### Variables ¶

This section is empty.

### Functions ¶

This section is empty.

### Types ¶

#### type Int26_6 ¶

`type Int26_6 int32`

Int26_6 is a signed 26.6 fixed-point number.

The integer part ranges from -33554432 to 33554431, inclusive. The fractional part has 6 bits of precision.

For example, the number one-and-a-quarter is Int26_6(1<<6 + 1<<4).

#### func I ¶

`func I(i int) Int26_6`

I returns the integer value i as an Int26_6.

For example, passing the integer value 2 yields Int26_6(128).

#### func (Int26_6) Ceil ¶

`func (x Int26_6) Ceil() int`

Ceil returns the least integer value greater than or equal to x.

Its return type is int, not Int26_6.

#### func (Int26_6) Floor ¶

`func (x Int26_6) Floor() int`

Floor returns the greatest integer value less than or equal to x.

Its return type is int, not Int26_6.

#### func (Int26_6) Mul ¶

`func (x Int26_6) Mul(y Int26_6) Int26_6`

Mul returns x*y in 26.6 fixed-point arithmetic.

#### func (Int26_6) Round ¶

`func (x Int26_6) Round() int`

Round returns the nearest integer value to x. Ties are rounded up.

Its return type is int, not Int26_6.

#### func (Int26_6) String ¶

`func (x Int26_6) String() string`

String returns a human-readable representation of a 26.6 fixed-point number.

For example, the number one-and-a-quarter becomes "1:16".

#### type Int52_12 ¶

`type Int52_12 int64`

Int52_12 is a signed 52.12 fixed-point number.

The integer part ranges from -2251799813685248 to 2251799813685247, inclusive. The fractional part has 12 bits of precision.

For example, the number one-and-a-quarter is Int52_12(1<<12 + 1<<10).

#### func (Int52_12) Ceil ¶

`func (x Int52_12) Ceil() int`

Ceil returns the least integer value greater than or equal to x.

Its return type is int, not Int52_12.

#### func (Int52_12) Floor ¶

`func (x Int52_12) Floor() int`

Floor returns the greatest integer value less than or equal to x.

Its return type is int, not Int52_12.

#### func (Int52_12) Mul ¶

`func (x Int52_12) Mul(y Int52_12) Int52_12`

Mul returns x*y in 52.12 fixed-point arithmetic.

#### func (Int52_12) Round ¶

`func (x Int52_12) Round() int`

Round returns the nearest integer value to x. Ties are rounded up.

Its return type is int, not Int52_12.

#### func (Int52_12) String ¶

`func (x Int52_12) String() string`

String returns a human-readable representation of a 52.12 fixed-point number.

For example, the number one-and-a-quarter becomes "1:1024".

#### type Point26_6 ¶

```type Point26_6 struct {
X, Y Int26_6
}```

Point26_6 is a 26.6 fixed-point coordinate pair.

It is analogous to the image.Point type in the standard library.

#### func P ¶

`func P(x, y int) Point26_6`

P returns the integer values x and y as a Point26_6.

For example, passing the integer values (2, -3) yields Point26_6{128, -192}.

#### func (Point26_6) Add ¶

`func (p Point26_6) Add(q Point26_6) Point26_6`

Add returns the vector p+q.

#### func (Point26_6) Div ¶

`func (p Point26_6) Div(k Int26_6) Point26_6`

Div returns the vector p/k.

#### func (Point26_6) In ¶

`func (p Point26_6) In(r Rectangle26_6) bool`

In returns whether p is in r.

#### func (Point26_6) Mul ¶

`func (p Point26_6) Mul(k Int26_6) Point26_6`

Mul returns the vector p*k.

#### func (Point26_6) Sub ¶

`func (p Point26_6) Sub(q Point26_6) Point26_6`

Sub returns the vector p-q.

#### type Point52_12 ¶

```type Point52_12 struct {
X, Y Int52_12
}```

Point52_12 is a 52.12 fixed-point coordinate pair.

It is analogous to the image.Point type in the standard library.

#### func (Point52_12) Add ¶

`func (p Point52_12) Add(q Point52_12) Point52_12`

Add returns the vector p+q.

#### func (Point52_12) Div ¶

`func (p Point52_12) Div(k Int52_12) Point52_12`

Div returns the vector p/k.

#### func (Point52_12) In ¶

`func (p Point52_12) In(r Rectangle52_12) bool`

In returns whether p is in r.

#### func (Point52_12) Mul ¶

`func (p Point52_12) Mul(k Int52_12) Point52_12`

Mul returns the vector p*k.

#### func (Point52_12) Sub ¶

`func (p Point52_12) Sub(q Point52_12) Point52_12`

Sub returns the vector p-q.

#### type Rectangle26_6 ¶

```type Rectangle26_6 struct {
Min, Max Point26_6
}```

Rectangle26_6 is a 26.6 fixed-point coordinate rectangle. The Min bound is inclusive and the Max bound is exclusive. It is well-formed if Min.X <= Max.X and likewise for Y.

It is analogous to the image.Rectangle type in the standard library.

#### func R ¶

`func R(minX, minY, maxX, maxY int) Rectangle26_6`

R returns the integer values minX, minY, maxX, maxY as a Rectangle26_6.

For example, passing the integer values (0, 1, 2, 3) yields Rectangle26_6{Point26_6{0, 64}, Point26_6{128, 192}}.

Like the image.Rect function in the standard library, the returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

#### func (Rectangle26_6) Add ¶

`func (r Rectangle26_6) Add(p Point26_6) Rectangle26_6`

Add returns the rectangle r translated by p.

#### func (Rectangle26_6) Empty ¶

`func (r Rectangle26_6) Empty() bool`

Empty returns whether the rectangle contains no points.

#### func (Rectangle26_6) In ¶

`func (r Rectangle26_6) In(s Rectangle26_6) bool`

In returns whether every point in r is in s.

#### func (Rectangle26_6) Intersect ¶

`func (r Rectangle26_6) Intersect(s Rectangle26_6) Rectangle26_6`

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

#### func (Rectangle26_6) Sub ¶

`func (r Rectangle26_6) Sub(p Point26_6) Rectangle26_6`

Sub returns the rectangle r translated by -p.

#### func (Rectangle26_6) Union ¶

`func (r Rectangle26_6) Union(s Rectangle26_6) Rectangle26_6`

Union returns the smallest rectangle that contains both r and s.

#### type Rectangle52_12 ¶

```type Rectangle52_12 struct {
Min, Max Point52_12
}```

Rectangle52_12 is a 52.12 fixed-point coordinate rectangle. The Min bound is inclusive and the Max bound is exclusive. It is well-formed if Min.X <= Max.X and likewise for Y.

It is analogous to the image.Rectangle type in the standard library.

#### func (Rectangle52_12) Add ¶

`func (r Rectangle52_12) Add(p Point52_12) Rectangle52_12`

Add returns the rectangle r translated by p.

#### func (Rectangle52_12) Empty ¶

`func (r Rectangle52_12) Empty() bool`

Empty returns whether the rectangle contains no points.

#### func (Rectangle52_12) In ¶

`func (r Rectangle52_12) In(s Rectangle52_12) bool`

In returns whether every point in r is in s.

#### func (Rectangle52_12) Intersect ¶

`func (r Rectangle52_12) Intersect(s Rectangle52_12) Rectangle52_12`

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

#### func (Rectangle52_12) Sub ¶

`func (r Rectangle52_12) Sub(p Point52_12) Rectangle52_12`

Sub returns the rectangle r translated by -p.

#### func (Rectangle52_12) Union ¶

`func (r Rectangle52_12) Union(s Rectangle52_12) Rectangle52_12`

Union returns the smallest rectangle that contains both r and s.