Back to

package f32

v0.0.0 (278e9bc)
Latest Go to latest
Published: Jun 3, 2020 | Licenses: MIT, Unlicense | Module:


Package f32 is a float32 implementation of package image's Point and Rectangle.

The coordinate space has the origin in the top left corner with the axes extending right and down.


type Point

type Point struct {
	X, Y float32

A Point is a two dimensional point.

func Pt

func Pt(x, y float32) Point

Pt is shorthand for Point{X: x, Y: y}.

func (Point) Add

func (p Point) Add(p2 Point) Point

Add return the point p+p2.

func (Point) Mul

func (p Point) Mul(s float32) Point

Mul returns p scaled by s.

func (Point) String

func (p Point) String() string

String return a string representation of p.

func (Point) Sub

func (p Point) Sub(p2 Point) Point

Sub returns the vector p-p2.

type Rectangle

type Rectangle struct {
	Min, Max Point

A Rectangle contains the points (X, Y) where Min.X <= X < Max.X, Min.Y <= Y < Max.Y.

func Rect

func Rect(x0, y0, x1, y1 float32) Rectangle

Rect is a shorthand for Rectangle{Point{x0, y0}, Point{x1, y1}}. The returned Rectangle has x0 and y0 swapped if necessary so that it's correctly formed.

func (Rectangle) Add

func (r Rectangle) Add(p Point) Rectangle

Add offsets r with the vector p.

func (Rectangle) Canon

func (r Rectangle) Canon() Rectangle

Canon returns the canonical version of r, where Min is to the upper left of Max.

func (Rectangle) Dx

func (r Rectangle) Dx() float32

Dx returns r's width.

func (Rectangle) Dy

func (r Rectangle) Dy() float32

Dy returns r's Height.

func (Rectangle) Empty

func (r Rectangle) Empty() bool

Empty reports whether r represents the empty area.

func (Rectangle) Intersect

func (r Rectangle) Intersect(s Rectangle) Rectangle

Intersect returns the intersection of r and s.

func (Rectangle) Size

func (r Rectangle) Size() Point

Size returns r's width and height.

func (Rectangle) String

func (r Rectangle) String() string

String return a string representation of r.

func (Rectangle) Sub

func (r Rectangle) Sub(p Point) Rectangle

Sub offsets r with the vector -p.

func (Rectangle) Union

func (r Rectangle) Union(s Rectangle) Rectangle

Union returns the union of r and s.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier