image

package
v1.2.117 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package image defines various functions useful with image of any type.

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]) DivPoint added in v1.2.81

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

DivPoint 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]) MulPoint added in v1.2.81

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

MulPoint 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]) Area added in v1.2.79

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

Area returns r's area, as width * height.

func (Rectangle[E]) At

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

At implements the Image interface.

func (Rectangle[E]) Border added in v1.2.79

func (r Rectangle[E]) Border(inset E) [4]Rectangle[E]

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

func (r Rectangle[E]) BorderPoint(inset Point[E]) [4]Rectangle[E]

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

func (r Rectangle[E]) BorderRectangle(inset Rectangle[E]) [4]Rectangle[E]

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]) 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 r translated by r/k.

func (Rectangle[E]) DivPoint added in v1.2.81

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

DivPoint returns the rectangle r translated by r./p.

func (Rectangle[E]) DivRectangle added in v1.2.81

func (r Rectangle[E]) DivRectangle(p Rectangle[E]) Rectangle[E]

DivRectangle returns the rectangle r translated by r./p.

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]) FlexIn added in v1.2.79

func (r Rectangle[E]) FlexIn(container Rectangle[E]) Rectangle[E]

FlexIn flex rect into box, shrink but not grow to fit the space available in its flex container

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]) InsetPoint added in v1.2.79

func (r Rectangle[E]) InsetPoint(n Point[E]) Rectangle[E]

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

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

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

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 translated by r*k.

func (Rectangle[E]) MulPoint added in v1.2.81

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

MulPoint returns the rectangle r translated by r.*p.

func (Rectangle[E]) MulRectangle added in v1.2.81

func (r Rectangle[E]) MulRectangle(p Rectangle[E]) Rectangle[E]

MulRectangle returns the rectangle r translated by r.*p.

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]) Scale added in v1.2.81

func (r Rectangle[E]) Scale(size Point[E]) Rectangle[E]

Scale scale rectangle's size to size, by expand from the mid-point of rect.

func (Rectangle[E]) ScaleByFactor

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

ScaleByFactor scale rectangle's size to factor * size, by expand from the mid-point of rect.

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