geom

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RayHexTopRight    = Ray{60}
	RayHexTopLeft     = Ray{300}
	RayHexBottomRight = Ray{120}
	RayHexBottomLeft  = Ray{240}
)
View Source
var (
	RayUp    = Ray{0}
	RayRight = Ray{90}
	RayDown  = Ray{180}
	RayLeft  = Ray{270}
)

Functions

func Cos

func Cos(a Angle) float64

func Sin

func Sin(a Angle) float64

func Tan

func Tan(a Angle) float64

func Transform added in v0.4.0

func Transform[E Element](in E, fns ...Transformation) E

Types

type Angle

type Angle interface {
	Degrees() float64
	Radians() float64
	Equals(Angle) bool
}

func Acos

func Acos(x float64) Angle

func Asin

func Asin(x float64) Angle

func Atan

func Atan(x float64) Angle

func Degrees

func Degrees(d float64) Angle

func Radians

func Radians(r float64) Angle

type AngleFromUp added in v0.4.0

type AngleFromUp struct {
	// contains filtered or unexported fields
}

func NewAngleFromUp added in v0.4.0

func NewAngleFromUp(angle Angle, direction Direction) AngleFromUp

func (AngleFromUp) Angle added in v0.4.0

func (a AngleFromUp) Angle() Angle

func (AngleFromUp) Direction added in v0.4.0

func (a AngleFromUp) Direction() Direction

type BottomLeftLineTagOpt added in v0.4.0

type BottomLeftLineTagOpt lineTagOpt

func TagBottomLeftLine added in v0.4.0

func TagBottomLeftLine(t *LineTag) BottomLeftLineTagOpt

func (BottomLeftLineTagOpt) Hexagon added in v0.4.0

func (opt BottomLeftLineTagOpt) Hexagon(h *hexagonTags)

type BottomLeftPointTagOpt added in v0.4.0

type BottomLeftPointTagOpt pointTagOpt

func TagBottomLeftPoint added in v0.4.0

func TagBottomLeftPoint(t *PointTag) BottomLeftPointTagOpt

func (BottomLeftPointTagOpt) Hexagon added in v0.4.0

func (opt BottomLeftPointTagOpt) Hexagon(h *hexagonTags)

func (BottomLeftPointTagOpt) Rectangle added in v0.4.0

func (opt BottomLeftPointTagOpt) Rectangle(r *rectangleOpts)

type BottomLineTagOpt added in v0.4.0

type BottomLineTagOpt lineTagOpt

func TagBottomLine added in v0.4.0

func TagBottomLine(t *LineTag) BottomLineTagOpt

func (BottomLineTagOpt) Hexagon added in v0.4.0

func (opt BottomLineTagOpt) Hexagon(h *hexagonTags)

func (BottomLineTagOpt) Rectangle added in v0.4.0

func (opt BottomLineTagOpt) Rectangle(r *rectangleOpts)

type BottomRightLineTagOpt added in v0.4.0

type BottomRightLineTagOpt lineTagOpt

func TagBottomRightLine added in v0.4.0

func TagBottomRightLine(t *LineTag) BottomRightLineTagOpt

func (BottomRightLineTagOpt) Hexagon added in v0.4.0

func (opt BottomRightLineTagOpt) Hexagon(h *hexagonTags)

type BottomRightPointTagOpt added in v0.4.0

type BottomRightPointTagOpt pointTagOpt

func TagBottomRightPoint added in v0.4.0

func TagBottomRightPoint(t *PointTag) BottomRightPointTagOpt

func (BottomRightPointTagOpt) Hexagon added in v0.4.0

func (opt BottomRightPointTagOpt) Hexagon(h *hexagonTags)

func (BottomRightPointTagOpt) Rectangle added in v0.4.0

func (opt BottomRightPointTagOpt) Rectangle(r *rectangleOpts)

type BoundingBox added in v0.4.0

type BoundingBox struct {
	Min, Max *Point
}

func (BoundingBox) BottomLeft added in v0.4.0

func (bb BoundingBox) BottomLeft() *Point

func (BoundingBox) BottomRight added in v0.4.0

func (bb BoundingBox) BottomRight() *Point

func (BoundingBox) Center added in v0.4.0

func (bb BoundingBox) Center() *Point

func (BoundingBox) Height added in v0.4.0

func (bb BoundingBox) Height() float64

func (BoundingBox) TopLeft added in v0.4.0

func (bb BoundingBox) TopLeft() *Point

func (BoundingBox) TopRight added in v0.4.0

func (bb BoundingBox) TopRight() *Point

func (BoundingBox) Width added in v0.4.0

func (bb BoundingBox) Width() float64

type CenterPointTagOpt added in v0.4.0

type CenterPointTagOpt pointTagOpt

func TagCenterPoint added in v0.4.0

func TagCenterPoint(t *PointTag) CenterPointTagOpt

func (CenterPointTagOpt) Circle added in v0.4.0

func (t CenterPointTagOpt) Circle(opts *circleOpts)

type Circle added in v0.4.0

type Circle struct {
	// contains filtered or unexported fields
}

func NewCircle added in v0.4.0

func NewCircle(radius float64, inOpts ...CircleOpt) *Circle

func (*Circle) BoundingBox added in v0.4.0

func (c *Circle) BoundingBox() BoundingBox

func (*Circle) Center added in v0.4.0

func (c *Circle) Center() *Point

func (*Circle) Radius added in v0.4.0

func (c *Circle) Radius() float64

type CircleArc added in v0.4.0

type CircleArc struct {
	// contains filtered or unexported fields
}

func NewCircleArc added in v0.4.0

func NewCircleArc(center *Point, radius float64, rayAngle RayAngle) *CircleArc

func (*CircleArc) BoundingBox added in v0.4.0

func (c *CircleArc) BoundingBox() BoundingBox

func (*CircleArc) Center added in v0.4.0

func (c *CircleArc) Center() *Point

func (*CircleArc) Endpoints added in v0.4.0

func (c *CircleArc) Endpoints() (*Point, *Point)

func (*CircleArc) Radius added in v0.4.0

func (c *CircleArc) Radius() float64

func (*CircleArc) RayAngle added in v0.4.0

func (c *CircleArc) RayAngle() RayAngle

type CircleOpt added in v0.4.0

type CircleOpt interface {
	Circle(*circleOpts)
}

type Direction added in v0.4.0

type Direction bool
const (
	Clockwise        Direction = true
	CounterClockwise Direction = false
)

type Element added in v0.4.0

type Element interface {
	BoundingBox() BoundingBox
	// contains filtered or unexported methods
}

type Figure added in v0.4.0

type Figure interface {
	Element
	// contains filtered or unexported methods
}

A figure is a closed shape.

type HexagonOpt added in v0.4.0

type HexagonOpt interface {
	Hexagon(*hexagonTags)
}

type LeftLineTagOpt added in v0.4.0

type LeftLineTagOpt lineTagOpt

func TagLeftLine added in v0.4.0

func TagLeftLine(t *LineTag) LeftLineTagOpt

func (LeftLineTagOpt) Rectangle added in v0.4.0

func (opt LeftLineTagOpt) Rectangle(r *rectangleOpts)

type LeftPointTagOpt added in v0.4.0

type LeftPointTagOpt pointTagOpt

func TagLeftPoint added in v0.4.0

func TagLeftPoint(t *PointTag) LeftPointTagOpt

func (LeftPointTagOpt) Hexagon added in v0.4.0

func (opt LeftPointTagOpt) Hexagon(h *hexagonTags)

type Line added in v0.4.0

type Line struct {
	// contains filtered or unexported fields
}

func NewLine added in v0.4.0

func NewLine(p1, p2 *Point, tags ...*LineTag) *Line

func (*Line) BoundingBox added in v0.4.0

func (l *Line) BoundingBox() BoundingBox

func (*Line) Endpoints added in v0.4.0

func (l *Line) Endpoints() (*Point, *Point)

type LineTag added in v0.4.0

type LineTag struct {
	// contains filtered or unexported fields
}

func (LineTag) Get added in v0.4.0

func (lt LineTag) Get(e Element) *Line

type MultiPath added in v0.4.0

type MultiPath struct {
	// contains filtered or unexported fields
}

func NewMultiPath added in v0.4.0

func NewMultiPath(paths ...Path) *MultiPath

func (*MultiPath) BoundingBox added in v0.4.0

func (mp *MultiPath) BoundingBox() BoundingBox

func (*MultiPath) Endpoints added in v0.4.0

func (mp *MultiPath) Endpoints() (*Point, *Point)

func (*MultiPath) Extend added in v0.4.0

func (mp *MultiPath) Extend(paths ...Path) *MultiPath

func (*MultiPath) Paths added in v0.4.0

func (mu *MultiPath) Paths() iter.Seq[Path]

type Path added in v0.4.0

type Path interface {
	Element

	// The endpoints that are connected by the path.
	Endpoints() (*Point, *Point)
	// contains filtered or unexported methods
}

type PathFigure added in v0.4.0

type PathFigure struct {
	// contains filtered or unexported fields
}

A figure is a collection of paths that form a closed shape.

func Hexagon

func Hexagon(r float64, opts ...HexagonOpt) *PathFigure

func NewPathFigure added in v0.4.0

func NewPathFigure(paths ...Path) *PathFigure

NewPathFigure() creates a new figure from the given paths. Returns nil if the paths do not form a closed shape.

func NewRectangle added in v0.4.0

func NewRectangle(width, height float64, inOpts ...RectangleOpt) *PathFigure

func (*PathFigure) BoundingBox added in v0.4.0

func (f *PathFigure) BoundingBox() BoundingBox

func (*PathFigure) Paths added in v0.4.0

func (f *PathFigure) Paths() iter.Seq[Path]

type Point

type Point struct {
	// contains filtered or unexported fields
}

func NewPoint added in v0.4.0

func NewPoint(x, y float64, tags ...*PointTag) *Point

func (*Point) BoundingBox added in v0.4.0

func (p *Point) BoundingBox() BoundingBox

func (*Point) Endpoints added in v0.4.0

func (p *Point) Endpoints() (*Point, *Point)

func (*Point) X

func (p *Point) X() float64

func (*Point) Y

func (p *Point) Y() float64

type PointTag added in v0.4.0

type PointTag struct {
	// contains filtered or unexported fields
}

func (PointTag) Get added in v0.4.0

func (pt PointTag) Get(e Element) *Point

type Ray added in v0.4.0

type Ray struct {
	// contains filtered or unexported fields
}

func (Ray) Angle added in v0.4.0

func (r Ray) Angle(other Ray, d Direction) Angle

func (Ray) DxDy added in v0.4.0

func (r Ray) DxDy(distance float64) (dx, dy float64)

func (Ray) Equals added in v0.4.0

func (r Ray) Equals(other Ray) bool

func (Ray) Offset added in v0.4.0

func (r Ray) Offset(a Angle, d Direction) Ray

type RayAngle added in v0.4.0

type RayAngle struct {
	// contains filtered or unexported fields
}

func NewRayAngle added in v0.4.0

func NewRayAngle(from, to Ray, d Direction) RayAngle

func (RayAngle) Angle added in v0.4.0

func (r RayAngle) Angle() Angle

func (RayAngle) Direction added in v0.4.0

func (r RayAngle) Direction() Direction

func (RayAngle) From added in v0.4.0

func (r RayAngle) From() Ray

func (RayAngle) Includes added in v0.4.0

func (r RayAngle) Includes(ray Ray) bool

func (RayAngle) Reverse added in v0.4.0

func (r RayAngle) Reverse() RayAngle

func (RayAngle) Rotate added in v0.4.0

func (r RayAngle) Rotate(angle Angle, d Direction) RayAngle

func (RayAngle) To added in v0.4.0

func (r RayAngle) To() Ray

type RectangleOpt added in v0.4.0

type RectangleOpt interface {
	Rectangle(*rectangleOpts)
}

type RightLineTagOpt added in v0.4.0

type RightLineTagOpt lineTagOpt

func TagRightLine added in v0.4.0

func TagRightLine(t *LineTag) RightLineTagOpt

func (RightLineTagOpt) Rectangle added in v0.4.0

func (opt RightLineTagOpt) Rectangle(r *rectangleOpts)

type RightPointTagOpt added in v0.4.0

type RightPointTagOpt pointTagOpt

func TagRightPoint added in v0.4.0

func TagRightPoint(t *PointTag) RightPointTagOpt

func (RightPointTagOpt) Hexagon added in v0.4.0

func (opt RightPointTagOpt) Hexagon(h *hexagonTags)

type RoundAllCornersOpt added in v0.4.0

type RoundAllCornersOpt roundCornerOpt

func RoundAllCorners added in v0.4.0

func RoundAllCorners(radius float64) RoundAllCornersOpt

func (RoundAllCornersOpt) Rectangle added in v0.4.0

func (opt RoundAllCornersOpt) Rectangle(r *rectangleOpts)

type RoundBottomLeftCornerOpt added in v0.4.0

type RoundBottomLeftCornerOpt roundCornerOpt

func RoundBottomLeftCorner added in v0.4.0

func RoundBottomLeftCorner(radius float64) RoundBottomLeftCornerOpt

func (RoundBottomLeftCornerOpt) Rectangle added in v0.4.0

func (opt RoundBottomLeftCornerOpt) Rectangle(r *rectangleOpts)

type RoundBottomRightCornerOpt added in v0.4.0

type RoundBottomRightCornerOpt roundCornerOpt

func RoundBottomRightCorner added in v0.4.0

func RoundBottomRightCorner(radius float64) RoundBottomRightCornerOpt

func (RoundBottomRightCornerOpt) Rectangle added in v0.4.0

func (opt RoundBottomRightCornerOpt) Rectangle(r *rectangleOpts)

type RoundTopLeftCornerOpt added in v0.4.0

type RoundTopLeftCornerOpt roundCornerOpt

func RoundTopLeftCorner added in v0.4.0

func RoundTopLeftCorner(radius float64) RoundTopLeftCornerOpt

func (RoundTopLeftCornerOpt) Rectangle added in v0.4.0

func (opt RoundTopLeftCornerOpt) Rectangle(r *rectangleOpts)

type RoundTopRightCornerOpt added in v0.4.0

type RoundTopRightCornerOpt roundCornerOpt

func RoundTopRightCorner added in v0.4.0

func RoundTopRightCorner(radius float64) RoundTopRightCornerOpt

func (RoundTopRightCornerOpt) Rectangle added in v0.4.0

func (opt RoundTopRightCornerOpt) Rectangle(r *rectangleOpts)

type TopLeftLineTagOpt added in v0.4.0

type TopLeftLineTagOpt lineTagOpt

func TagTopLeftLine added in v0.4.0

func TagTopLeftLine(t *LineTag) TopLeftLineTagOpt

func (TopLeftLineTagOpt) Hexagon added in v0.4.0

func (opt TopLeftLineTagOpt) Hexagon(h *hexagonTags)

type TopLeftPointTagOpt added in v0.4.0

type TopLeftPointTagOpt pointTagOpt

func TagTopLeftPoint added in v0.4.0

func TagTopLeftPoint(t *PointTag) TopLeftPointTagOpt

func (TopLeftPointTagOpt) Hexagon added in v0.4.0

func (opt TopLeftPointTagOpt) Hexagon(h *hexagonTags)

func (TopLeftPointTagOpt) Rectangle added in v0.4.0

func (opt TopLeftPointTagOpt) Rectangle(r *rectangleOpts)

type TopLineTagOpt added in v0.4.0

type TopLineTagOpt lineTagOpt

func TagTopLine added in v0.4.0

func TagTopLine(t *LineTag) TopLineTagOpt

func (TopLineTagOpt) Hexagon added in v0.4.0

func (opt TopLineTagOpt) Hexagon(h *hexagonTags)

func (TopLineTagOpt) Rectangle added in v0.4.0

func (opt TopLineTagOpt) Rectangle(r *rectangleOpts)

type TopRightLineTagOpt added in v0.4.0

type TopRightLineTagOpt lineTagOpt

func TagTopRightLine added in v0.4.0

func TagTopRightLine(t *LineTag) TopRightLineTagOpt

func (TopRightLineTagOpt) Hexagon added in v0.4.0

func (opt TopRightLineTagOpt) Hexagon(h *hexagonTags)

type TopRightPointTagOpt added in v0.4.0

type TopRightPointTagOpt pointTagOpt

func TagTopRightPoint added in v0.4.0

func TagTopRightPoint(t *PointTag) TopRightPointTagOpt

func (TopRightPointTagOpt) Hexagon added in v0.4.0

func (opt TopRightPointTagOpt) Hexagon(h *hexagonTags)

func (TopRightPointTagOpt) Rectangle added in v0.4.0

func (opt TopRightPointTagOpt) Rectangle(r *rectangleOpts)

type Transformation added in v0.4.0

type Transformation func(Element)

func Rotate added in v0.3.7

func Rotate(angle Angle, dir Direction) Transformation

func TranslateRay added in v0.4.0

func TranslateRay(ray Ray, distance float64) Transformation

func TranslateXY added in v0.4.0

func TranslateXY(dx, dy float64) Transformation

Jump to

Keyboard shortcuts

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