image

package
v1.2.77 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 7 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[E constraints.Number] struct {
	X, Y E
}

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

func FromPtInt

func FromPtInt[E constraints.Number](q image.Point) Point[E]

func Pt

func Pt[E constraints.Number](X, Y E) Point[E]

Pt is shorthand for Point[E]{X, Y}.

func ScaleLineSegment

func ScaleLineSegment[E constraints_.Number](segment Point[E], length E, limit Point[E]) Point[E]

ScaleLineSegment segment's size to length flexible in limit

func (Point[E]) Add

func (p Point[E]) Add(q Point[E]) Point[E]

Add returns the vector p+q.

func (Point[E]) Div

func (p Point[E]) Div(k E) Point[E]

Div returns the vector p/k.

func (Point[E]) Eq

func (p Point[E]) Eq(q Point[E]) bool

Eq reports whether p and q are equal.

func (Point[E]) In

func (p Point[E]) In(r Rectangle[E]) bool

In reports whether p is in r.

func (Point[E]) Mod

func (p Point[E]) Mod(r image.Rectangle) image.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[E]) Mul

func (p Point[E]) Mul(k E) Point[E]

Mul returns the vector p*k.

func (Point[E]) RoundPoint

func (p Point[E]) RoundPoint() image.Point

func (Point[E]) String

func (p Point[E]) String() string

String returns a string representation of p like "(3,4)".

func (Point[E]) Sub

func (p Point[E]) Sub(q Point[E]) Point[E]

Sub returns the vector p-q.

type Rectangle

type Rectangle[E constraints.Number] struct {
	Min, Max Point[E]
}

func FromRectInt

func FromRectInt[E constraints.Number](rect image.Rectangle) Rectangle[E]

func Rect

func Rect[E constraints.Number](x0, y0, x1, y1 E) Rectangle[E]

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

func ScaleRectangleBySize

func ScaleRectangleBySize[E constraints.Integer](rect Rectangle[E], size Point[E], limit Rectangle[E]) Rectangle[E]

ScaleRectangleBySize scale rect to size flexible in limit

func UnionPoints

func UnionPoints[E constraints_.Number](pts ...Point[E]) Rectangle[E]

UnionPoints returns the smallest rectangle that contains all points. an empty rectangle is a empty set, Not a point

func UnionRectangles

func UnionRectangles[E constraints_.Number](rs ...Rectangle[E]) Rectangle[E]

UnionRectangles returns the smallest rectangle that contains all rectangles, empty rectangles excluded.

func (Rectangle[E]) Add

func (r Rectangle[E]) Add(p Point[E]) Rectangle[E]

Add returns the rectangle r translated by p.

func (Rectangle[E]) At

func (r Rectangle[E]) At(x, y E) color.Color

At implements the Image interface.

func (Rectangle[E]) Bounds

func (r Rectangle[E]) Bounds() Rectangle[E]

Bounds implements the Image interface.

func (Rectangle[E]) Canon

func (r Rectangle[E]) Canon() Rectangle[E]

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[E]) ColorModel

func (r Rectangle[E]) ColorModel() color.Model

ColorModel implements the Image interface.

func (Rectangle[E]) Div added in v1.2.71

func (r Rectangle[E]) Div(k E) Rectangle[E]

Div returns the rectangle p/k.

func (Rectangle[E]) Dx

func (r Rectangle[E]) Dx() E

Dx returns r's width.

func (Rectangle[E]) Dy

func (r Rectangle[E]) Dy() E

Dy returns r's height.

func (Rectangle[E]) Empty

func (r Rectangle[E]) Empty() bool

Empty reports whether the rectangle contains no points.

func (Rectangle[E]) Eq

func (r Rectangle[E]) Eq(s Rectangle[E]) bool

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

func (Rectangle[E]) In

func (r Rectangle[E]) In(s Rectangle[E]) bool

In reports whether every point in r is in s.

func (Rectangle[E]) Inset

func (r Rectangle[E]) Inset(n E) Rectangle[E]

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[E]) Intersect

func (r Rectangle[E]) Intersect(s Rectangle[E]) Rectangle[E]

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[E]) Mul added in v1.2.71

func (r Rectangle[E]) Mul(k E) Rectangle[E]

Mul returns the rectangle r*k.

func (Rectangle[E]) Overlaps

func (r Rectangle[E]) Overlaps(s Rectangle[E]) bool

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

func (Rectangle[E]) RGBA64At

func (r Rectangle[E]) RGBA64At(x, y E) color.RGBA64

RGBA64At implements the RGBA64Image interface.

func (Rectangle[E]) RoundRectangle

func (r Rectangle[E]) RoundRectangle() image.Rectangle

func (Rectangle[E]) ScaleByFactor

func (r Rectangle[E]) ScaleByFactor(factor Point[E]) Rectangle[E]

ScaleByFactor scale rect to factor*size

func (Rectangle[E]) Size

func (r Rectangle[E]) Size() Point[E]

Size returns r's width and height.

func (Rectangle[E]) String

func (r Rectangle[E]) String() string

String returns a string representation of r like "(3,4)-(6,5)".

func (Rectangle[E]) Sub

func (r Rectangle[E]) Sub(p Point[E]) Rectangle[E]

Sub returns the rectangle r translated by -p.

func (Rectangle[E]) Union

func (r Rectangle[E]) Union(s Rectangle[E]) Rectangle[E]

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

func (Rectangle[E]) UnionPoints

func (r Rectangle[E]) UnionPoints(pts ...Point[E]) Rectangle[E]

UnionPoints returns the smallest rectangle that contains all points.

Jump to

Keyboard shortcuts

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