Documentation ¶
Index ¶
- Variables
- func Div(a, b int) int
- func Div64(a, b int64) int64
- func Mod(a, b int) int
- func Mod64(a, b int64) int64
- func Rint(f float64) int
- type Delta
- func (d Delta) Add(d2 Delta) Delta
- func (d Delta) Div(m int) Delta
- func (d Delta) Dot(d2 Delta) int
- func (d Delta) IsZero() bool
- func (d Delta) Length() float64
- func (d Delta) Length2() int64
- func (d Delta) LengthFixed() Fixed
- func (d Delta) MarshalText() ([]byte, error)
- func (d Delta) Mod(m int) Delta
- func (d Delta) Mul(n int) Delta
- func (d Delta) Mul2(mx, my int) Delta
- func (d Delta) MulFixed(f Fixed) Delta
- func (d Delta) MulFracFixed(num, denom Fixed) Delta
- func (d Delta) Norm0() int
- func (d Delta) Norm1() int
- func (d Delta) String() string
- func (d Delta) Sub(d2 Delta) Delta
- func (d *Delta) UnmarshalText(text []byte) error
- func (d Delta) WithLengthFixed(f Fixed) Delta
- func (d Delta) WithMaxLengthFixed(f Fixed) Delta
- type Fixed
- type Orientation
- func (o Orientation) Apply(d Delta) Delta
- func (o Orientation) ApplyToRect2(pivot2 Pos, r Rect) Rect
- func (o Orientation) Concat(o2 Orientation) Orientation
- func (o Orientation) Determinant() int
- func (o Orientation) Inverse() Orientation
- func (o Orientation) MarshalText() ([]byte, error)
- func (o Orientation) String() string
- func (o *Orientation) UnmarshalText(text []byte) error
- type Orientations
- type Pos
- func (p Pos) Add(d Delta) Pos
- func (p Pos) Delta(p2 Pos) Delta
- func (p Pos) Div(m int) Pos
- func (p Pos) FromRectToRect(a Rect, b Rect) Pos
- func (p Pos) MarshalText() ([]byte, error)
- func (p Pos) Mul(n int) Pos
- func (p Pos) String() string
- func (p Pos) Sub(d Delta) Pos
- func (p *Pos) UnmarshalJSON(text []byte) error
- func (p *Pos) UnmarshalText(text []byte) error
- type Rect
- func (r Rect) Add(d Delta) Rect
- func (r Rect) Center() Pos
- func (r Rect) Delta(other Rect) Delta
- func (r Rect) DeltaPos(other Pos) Delta
- func (r Rect) Foot() Pos
- func (r Rect) GridPos(p Pos, nx int, ny int) (int, int)
- func (r Rect) Grow(d Delta) Rect
- func (r Rect) MarshalText() ([]byte, error)
- func (r Rect) Normalized() Rect
- func (r Rect) OppositeCorner() Pos
- func (r Rect) String() string
- func (r *Rect) UnmarshalText(text []byte) error
Constants ¶
This section is empty.
Variables ¶
var AllOrientations = Orientations{ Orientation{Right: East(), Down: North()}, Orientation{Right: East(), Down: South()}, Orientation{Right: North(), Down: East()}, Orientation{Right: North(), Down: West()}, Orientation{Right: South(), Down: East()}, Orientation{Right: South(), Down: West()}, Orientation{Right: West(), Down: North()}, Orientation{Right: West(), Down: South()}, }
Functions ¶
Types ¶
type Delta ¶
type Delta struct {
DX, DY int
}
Delta represents a move between two pixel positions.
func (Delta) LengthFixed ¶
func (Delta) MarshalText ¶ added in v1.2.217
func (Delta) MulFracFixed ¶
func (*Delta) UnmarshalText ¶ added in v1.2.399
func (Delta) WithLengthFixed ¶
func (Delta) WithMaxLengthFixed ¶
type Fixed ¶
type Fixed fixedUnderlying
const (
FixedOne Fixed = 1 << fixedBits
)
func NewFixedFloat64 ¶
func NewFixedInt64 ¶
func NewFixedInt64(i fixedUnderlying) Fixed
type Orientation ¶
Orientation represents a transformation matrix, written as a right and a down vector.
func ParseOrientation ¶
func ParseOrientation(s string) (Orientation, error)
ParseOrientation parses an orientation from a string. It is given by the right and down directions in that order.
func (Orientation) Apply ¶
func (o Orientation) Apply(d Delta) Delta
Apply rotates a delta by an orientation.
func (Orientation) ApplyToRect2 ¶
func (o Orientation) ApplyToRect2(pivot2 Pos, r Rect) Rect
ApplyToRect2 rotates a rectangle by the given orientation, mapping the pivot to itself. The pivot is given in doubled coordinates to support half-pixel pivots. Note: odd numbers are pixel centers, even numbers are pixel corners!
func (Orientation) Concat ¶
func (o Orientation) Concat(o2 Orientation) Orientation
Concat returns the orientation o * o2 so that o.Concat(o2).Apply(d) == o.Apply(o2.Apply(d)).
func (Orientation) Determinant ¶
func (o Orientation) Determinant() int
func (Orientation) Inverse ¶
func (o Orientation) Inverse() Orientation
Inverse returns an orientation so that o.Concat(o.Invert()) == Identity().
func (Orientation) MarshalText ¶ added in v1.2.399
func (o Orientation) MarshalText() ([]byte, error)
func (Orientation) String ¶ added in v1.2.356
func (o Orientation) String() string
func (*Orientation) UnmarshalText ¶ added in v1.2.399
func (o *Orientation) UnmarshalText(text []byte) error
type Orientations ¶ added in v1.2.356
type Orientations []Orientation
func ParseOrientations ¶ added in v1.2.4
func ParseOrientations(s string) (Orientations, error)
func (Orientations) MarshalText ¶ added in v1.2.399
func (o Orientations) MarshalText() ([]byte, error)
func (*Orientations) UnmarshalText ¶ added in v1.2.399
func (o *Orientations) UnmarshalText(text []byte) error
type Pos ¶
type Pos struct {
X, Y int
}
Pos represents a pixel position, where X points right and Y points down.
func (Pos) MarshalText ¶ added in v1.2.399
func (*Pos) UnmarshalJSON ¶ added in v1.2.399
func (*Pos) UnmarshalText ¶ added in v1.2.399
type Rect ¶
type Rect struct { // Origin is the origin of the rectangle, typically the top left corner. Origin Pos // Size is the size of the rectangle, typically positive. Size Delta }
Rect represents a rectangle.
func RectFromPoints ¶
func (Rect) DeltaPos ¶
DeltaPos returns the vector between the closest points of a rectangle and a point.
func (Rect) GridPos ¶ added in v1.3.43
GridPos converts coordinates of p within the rect into grid coords.
func (Rect) MarshalText ¶ added in v1.2.399
func (Rect) Normalized ¶
Normalized returns a rectangle such that its size is nonnegative.
func (Rect) OppositeCorner ¶
OppositeCorner returns the coordinate of the opposite corner of the rectangle. Only correct on normalized rectangles.