Documentation ¶
Overview ¶
Package image defines various functions useful with image of any type.
Index ¶
- type Point
- func (p Point[E]) Add(q Point[E]) Point[E]
- func (p Point[E]) Div(k E) Point[E]
- func (p Point[E]) DivPoint(k Point[E]) Point[E]
- func (p Point[E]) Eq(q Point[E]) bool
- func (p Point[E]) In(r Rectangle[E]) bool
- func (p Point[E]) Mod(r image.Rectangle) image.Point
- func (p Point[E]) Mul(k E) Point[E]
- func (p Point[E]) MulPoint(k Point[E]) Point[E]
- func (p Point[E]) RoundPoint() image.Point
- func (p Point[E]) String() string
- func (p Point[E]) Sub(q Point[E]) Point[E]
- type Rectangle
- func FromRectInt[E constraints.Number](rect image.Rectangle) Rectangle[E]
- func Rect[E constraints.Number](x0, y0, x1, y1 E) Rectangle[E]
- func ScaleRectangleBySize[E constraints.Integer](rect Rectangle[E], size Point[E], limit Rectangle[E]) Rectangle[E]
- func UnionPoints[E constraints_.Number](pts ...Point[E]) Rectangle[E]
- func UnionRectangles[E constraints_.Number](rs ...Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) Add(p Point[E]) Rectangle[E]
- func (r Rectangle[E]) Area() E
- func (r Rectangle[E]) At(x, y E) color.Color
- func (r Rectangle[E]) Border(inset E) [4]Rectangle[E]
- func (r Rectangle[E]) BorderPoint(inset Point[E]) [4]Rectangle[E]
- func (r Rectangle[E]) BorderRectangle(inset Rectangle[E]) [4]Rectangle[E]
- func (r Rectangle[E]) Bounds() Rectangle[E]
- func (r Rectangle[E]) Canon() Rectangle[E]
- func (r Rectangle[E]) ColorModel() color.Model
- func (r Rectangle[E]) Div(k E) Rectangle[E]
- func (r Rectangle[E]) DivPoint(p Point[E]) Rectangle[E]
- func (r Rectangle[E]) DivRectangle(p Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) Dx() E
- func (r Rectangle[E]) Dy() E
- func (r Rectangle[E]) Empty() bool
- func (r Rectangle[E]) Eq(s Rectangle[E]) bool
- func (r Rectangle[E]) FlexIn(container Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) In(s Rectangle[E]) bool
- func (r Rectangle[E]) Inset(n E) Rectangle[E]
- func (r Rectangle[E]) InsetPoint(n Point[E]) Rectangle[E]
- func (r Rectangle[E]) InsetRectangle(n Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) Intersect(s Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) Mul(k E) Rectangle[E]
- func (r Rectangle[E]) MulPoint(p Point[E]) Rectangle[E]
- func (r Rectangle[E]) MulRectangle(p Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) Overlaps(s Rectangle[E]) bool
- func (r Rectangle[E]) RGBA64At(x, y E) color.RGBA64
- func (r Rectangle[E]) RoundRectangle() image.Rectangle
- func (r Rectangle[E]) Scale(size Point[E]) Rectangle[E]
- func (r Rectangle[E]) ScaleByFactor(factor Point[E]) Rectangle[E]
- func (r Rectangle[E]) Size() Point[E]
- func (r Rectangle[E]) String() string
- func (r Rectangle[E]) Sub(p Point[E]) Rectangle[E]
- func (r Rectangle[E]) Union(s Rectangle[E]) Rectangle[E]
- func (r Rectangle[E]) UnionPoints(pts ...Point[E]) Rectangle[E]
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 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]) Mod ¶
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]) RoundPoint ¶
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]) Area ¶ added in v1.2.79
func (r Rectangle[E]) Area() E
Area returns r's area, as width * height.
func (Rectangle[E]) Border ¶ added in v1.2.79
Border returns four rectangles that together contain those points between r and r.Inset(inset). Visually:
00000000 00000000 11....22 11....22 11....22 33333333 33333333
The inset may be negative, in which case the points will be outside r.
Some of the returned rectangles may be empty. None of the returned rectangles will overlap.
func (Rectangle[E]) BorderPoint ¶ added in v1.2.79
BorderPoint returns four rectangles that together contain those points between r and r.Inset(inset). Visually:
00000000 00000000 11....22 11....22 11....22 33333333 33333333
The inset may be negative, in which case the points will be outside r.
Some of the returned rectangles may be empty. None of the returned rectangles will overlap.
func (Rectangle[E]) BorderRectangle ¶ added in v1.2.79
BorderRectangle returns four rectangles that together contain those points between r and r.Inset(inset). Visually:
00000000 00000000 11....22 11....22 11....22 33333333 33333333
The inset may be negative, in which case the points will be outside r.
Some of the returned rectangles may be empty. None of the returned rectangles will overlap.
func (Rectangle[E]) Canon ¶
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 ¶
ColorModel implements the Image interface.
func (Rectangle[E]) DivPoint ¶ added in v1.2.81
DivPoint returns the rectangle r translated by r./p.
func (Rectangle[E]) DivRectangle ¶ added in v1.2.81
DivRectangle returns the rectangle r translated by r./p.
func (Rectangle[E]) Eq ¶
Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.
func (Rectangle[E]) FlexIn ¶ added in v1.2.79
FlexIn flex rect into box, shrink but not grow to fit the space available in its flex container
func (Rectangle[E]) Inset ¶
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]) InsetPoint ¶ added in v1.2.79
InsetPoint returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than n.X+n.Y then an empty rectangle near the center of r will be returned.
func (Rectangle[E]) InsetRectangle ¶ added in v1.2.79
InsetRectangle returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than (n.Min.X+n.Max.X, n.Min.Y+n.Max.Y), then an empty rectangle near the center of r will be returned.
func (Rectangle[E]) Intersect ¶
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]) MulPoint ¶ added in v1.2.81
MulPoint returns the rectangle r translated by r.*p.
func (Rectangle[E]) MulRectangle ¶ added in v1.2.81
MulRectangle returns the rectangle r translated by r.*p.
func (Rectangle[E]) RoundRectangle ¶
func (Rectangle[E]) Scale ¶ added in v1.2.81
Scale scale rectangle's size to size, by expand from the mid-point of rect.
func (Rectangle[E]) ScaleByFactor ¶
ScaleByFactor scale rectangle's size to factor * size, by expand from the mid-point of rect.
func (Rectangle[E]) UnionPoints ¶
UnionPoints returns the smallest rectangle that contains all points.