image

package
v0.0.0-...-3d984ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	X, Y int
}

A Point is an X, Y coordinate pair. The axes increase right and down.

var ZP Point

ZP is the zero Point.

func Pt

func Pt(X, Y int) Point

Pt is shorthand for Point{X, Y}.

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Div

func (p Point) Div(k int) Point

Div returns the vector p/k.

func (Point) Eq

func (p Point) Eq(q Point) bool

Eq reports whether p and q are equal.

func (Point) In

func (p Point) In(r Rectangle) bool

In reports whether p is in r.

func (Point) Mod

func (p Point) Mod(r Rectangle) Point

Mod returns the point q in r such that p.X-q.X is a multiple of r's width and p.Y-q.Y is a multiple of r's height.

func (Point) Mul

func (p Point) Mul(k int) Point

Mul returns the vector p*k.

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

type Rectangle

type Rectangle struct {
	Min, Max Point
}

A Rectangle contains the points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y. It is well-formed if Min.X <= Max.X and likewise for Y. Points are always well-formed. A rectangle's methods always return well-formed outputs for well-formed inputs.

A Rectangle is also an Image whose bounds are the rectangle itself. At returns color.Opaque for points in the rectangle and color.Transparent otherwise.

var ZR Rectangle

ZR is the zero Rectangle.

func Rect

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

Rect is shorthand for Rectangle{Pt(x0, y0), Pt(x1, y1)}. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (Rectangle) Add

func (r Rectangle) Add(p Point) Rectangle

Add returns the rectangle r translated by p.

func (Rectangle) At

func (r Rectangle) At(x, y int) color.Color

At implements the Image interface.

func (Rectangle) Bounds

func (r Rectangle) Bounds() Rectangle

Bounds implements the Image interface.

func (Rectangle) Canon

func (r Rectangle) Canon() Rectangle

Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (Rectangle) ColorModel

func (r Rectangle) ColorModel() color.Model

ColorModel implements the Image interface.

func (Rectangle) Dx

func (r Rectangle) Dx() int

Dx returns r's width.

func (Rectangle) Dy

func (r Rectangle) Dy() int

Dy returns r's height.

func (Rectangle) Empty

func (r Rectangle) Empty() bool

Empty reports whether the rectangle contains no points.

func (Rectangle) Eq

func (r Rectangle) Eq(s Rectangle) bool

Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.

func (Rectangle) In

func (r Rectangle) In(s Rectangle) bool

In reports whether every point in r is in s.

func (Rectangle) Inset

func (r Rectangle) Inset(n int) Rectangle

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (Rectangle) Intersect

func (r Rectangle) Intersect(s Rectangle) Rectangle

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 (Rectangle) Overlaps

func (r Rectangle) Overlaps(s Rectangle) bool

Overlaps reports whether r and s have a non-empty intersection.

func (Rectangle) Size

func (r Rectangle) Size() Point

Size returns r's width and height.

func (Rectangle) Sub

func (r Rectangle) Sub(p Point) Rectangle

Sub returns the rectangle r translated by -p.

func (Rectangle) Union

func (r Rectangle) Union(s Rectangle) Rectangle

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

Directories

Path Synopsis
Package color implements a basic color library.
Package color implements a basic color library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL