Documentation ¶
Index ¶
- Constants
- type Number
- type Point
- type Rectangle
- func (r Rectangle[T]) Add(p Point[T]) Rectangle[T]
- func (r Rectangle[T]) Canon() Rectangle[T]
- func (r Rectangle[T]) Dx() T
- func (r Rectangle[T]) Dy() T
- func (r Rectangle[T]) Empty() bool
- func (r Rectangle[T]) Eq(s Rectangle[T]) bool
- func (r Rectangle[T]) In(s Rectangle[T]) bool
- func (r Rectangle[T]) Inset(n T) Rectangle[T]
- func (r Rectangle[T]) Intersect(s Rectangle[T]) Rectangle[T]
- func (r Rectangle[T]) Overlaps(s Rectangle[T]) bool
- func (r Rectangle[T]) Size() Size[T]
- func (r Rectangle[T]) String() string
- func (r Rectangle[T]) Sub(p Point[T]) Rectangle[T]
- func (r Rectangle[T]) Union(s Rectangle[T]) Rectangle[T]
- type Size
- type Vector
- func (v Vector) Add(w Vector) Vector
- func (v Vector) AsPoint() Point[float64]
- func (v Vector) Equal(w Vector) bool
- func (v Vector) Magnitude() float64
- func (v Vector) Multiply(scale float64) Vector
- func (v Vector) Pair() (float64, float64)
- func (v Vector) Resize(newMag float64) Vector
- func (v Vector) Unit() Vector
- func (v Vector) Zero() bool
Constants ¶
const PointSchemaStr = `` /* 359-byte string literal not displayed */
PointSchemaStr is the JSON schema for a point.
const SizeSchemaStr = `` /* 392-byte string literal not displayed */
SizeSchemaStr is the JSON schema for a size.
const VectorSchemaStr = `` /* 325-byte string literal not displayed */
VectorSchemaStr is the JSON schema for a vector.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Number ¶ added in v0.2.0
type Number interface { constraints.Float | constraints.Integer }
Number constrains type to float or integer.
type Point ¶ added in v0.2.0
type Point[T Number] struct { X T `json:"x"` Y T `json:"y"` }
Point is a 2D point.
type Rectangle ¶ added in v0.2.0
Rectangle is a generic version of image.Rectangle.
func (Rectangle[T]) Canon ¶ added in v0.2.0
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[T]) Eq ¶ added in v0.2.0
Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.
func (Rectangle[T]) Inset ¶ added in v0.2.0
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[T]) Intersect ¶ added in v0.2.0
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[T]) Overlaps ¶ added in v0.2.0
Overlaps reports whether r and s have a non-empty intersection.
func (Rectangle[T]) String ¶ added in v0.2.0
String returns a string representation of r like "(3,4)-(6,5)".
type Size ¶
type Size[T Number] struct { Width T `json:"w"` Height T `json:"h"` }
Size is a 2D size.
func (Size[T]) Center ¶ added in v0.2.0
Center makes a point that would be at the center of a rectangle with the current size, starting at (0,0).
type Vector ¶
Vector is a 2D vector.
Directories ¶
Path | Synopsis |
---|---|
mock_animation
Package mock_animation is a generated GoMock package.
|
Package mock_animation is a generated GoMock package. |
mock_control
Package mock_control is a generated GoMock package.
|
Package mock_control is a generated GoMock package. |
mock_drawing
Package mock_drawing is a generated GoMock package.
|
Package mock_drawing is a generated GoMock package. |
mock_engine
Package mock_engine is a generated GoMock package.
|
Package mock_engine is a generated GoMock package. |
examples
|
|
mock_fileindex
Package mock_fileindex is a generated GoMock package.
|
Package mock_fileindex is a generated GoMock package. |
mock_movecollide
Package mock_movecollide is a generated GoMock package.
|
Package mock_movecollide is a generated GoMock package. |
mock_resource
Package mock_resource is a generated GoMock package.
|
Package mock_resource is a generated GoMock package. |