golyat

package module
v0.0.0-...-d8cfb29 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 2 Imported by: 1

README

golyat

Test Coverage Go Report Card GoDoc

import "git.fractalqb.de/fractalqb/golyat"


Go Lyaout, or simply golyat, helps to layout shapes that have bounding boxes in rows or columns just as you find it in most vector drawing programs. However golyat does only the computations and no drawing at all. Use it e.g. with

to make something useful from it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[S Scalar](a Axis, frac S) func(l, r Shape[S]) int

func Extent

func Extent[S Scalar](a Axis, s Shape[S]) S

func Extents

func Extents[S Scalar](a Axis, s ...Shape[S]) (sum S)

func Force

func Force[S Scalar](a Axis, s, t Shape[S]) S

Force computes the distance the two shapes would have to be moved apart alog the axis to avoid an overlap of their bounding boxes. The calculation takes into account possible margins that may be created by Border.

func Frac

func Frac[S Scalar](a Axis, f S, s Shape[S]) S

func Gap

func Gap[S Scalar](a Axis, s, t Shape[S]) S

func Margin

func Margin[S Scalar](a Axis, s, t Shape[S]) (m S)

func Max

func Max[S Scalar](a Axis, s Shape[S]) S

func Min

func Min[S Scalar](a Axis, s Shape[S]) S

func Move

func Move[S Scalar](a Axis, s Shape[S], d S)

Types

type Aligner

type Aligner[S Scalar] struct {
	Axis Axis
	Frac S
}

func Align

func Align[S Scalar](a Axis, f S) Aligner[S]

func (Aligner[S]) Shapes

func (al Aligner[S]) Shapes(target S, shapes ...Shape[S])

type Axis

type Axis int
const (
	X Axis = 0
	Y Axis = 1
)

func (Axis) Cross

func (a Axis) Cross() Axis

type BBoxer

type BBoxer[S Scalar] interface {
	BBox() Rect[S]
}

type Border

type Border[S Scalar] struct {
	Content         Shape[S]
	Padding, Margin Rect[S]
}

func (*Border[S]) BBox

func (b *Border[S]) BBox() Rect[S]

func (*Border[S]) Hull

func (b *Border[S]) Hull(yield func(Point[S]) bool)

func (*Border[S]) Move

func (b *Border[S]) Move(dx, dy S)

type Circle

type Circle[S Scalar] struct {
	C Point[S]
	R S
}

func (*Circle[S]) BBox

func (r *Circle[S]) BBox() Rect[S]

func (*Circle[S]) Hull

func (c *Circle[S]) Hull(yield func(Point[S]) bool)

func (*Circle[S]) Move

func (c *Circle[S]) Move(dx, dy S)

type Container

type Container[S Scalar] []Shape[S]

func (Container[S]) BBox

func (c Container[S]) BBox() Rect[S]

func (Container[S]) Hull

func (c Container[S]) Hull(yield func(Point[S]) bool)

func (Container[S]) Move

func (c Container[S]) Move(dx, dy S)

type Line

type Line[S Scalar] struct{ P, D Point[S] }

func (*Line[S]) Hull

func (l *Line[S]) Hull(yield func(Point[S]) bool)

func (*Line[S]) Move

func (l *Line[S]) Move(dx, dy S)

func (*Line[S]) Q

func (l *Line[S]) Q() Point[S]

type Point

type Point[S Scalar] [2]S

func Pt

func Pt[S Scalar](x, y S) Point[S]

func (*Point[S]) Hull

func (p *Point[S]) Hull(yield func(Point[S]) bool)

func (*Point[S]) Move

func (p *Point[S]) Move(dx, dy S)

func (Point[S]) X

func (p Point[S]) X() float64

func (Point[S]) Y

func (p Point[S]) Y() float64

type Rect

type Rect[S Scalar] struct{ Min, Max Point[S] }

func BBox

func BBox[S Scalar](s ...Shape[S]) (bb Rect[S])

func BBoxOf

func BBoxOf[S Scalar](pit iter.Seq[Point[S]]) (bb Rect[S])

func NewRect

func NewRect[S Scalar](min, max Point[S]) *Rect[S]

func (*Rect[S]) BBox

func (r *Rect[S]) BBox() Rect[S]

func (Rect[S]) Extent

func (r Rect[S]) Extent(a Axis) S

func (Rect[S]) Frac

func (r Rect[S]) Frac(a Axis, f S) S

func (Rect[S]) Hull

func (r Rect[S]) Hull(yield func(Point[S]) bool)

func (*Rect[S]) Move

func (r *Rect[S]) Move(dx, dy S)

type Scalar

type Scalar interface{ ~float32 | ~float64 }

type Shape

type Shape[S Scalar] interface {
	Hull(yield func(Point[S]) bool)
	Move(dx, dy S)
}

type Spreader

type Spreader[S Scalar] struct {
	Axis    Axis
	MinFrac S
	MaxFrac S
}

func Spread

func Spread[S Scalar](a Axis, fmin, fmax S) Spreader[S]

func (Spreader[S]) Shapes

func (sp Spreader[S]) Shapes(min, max S, shapes ...Shape[S])

func (Spreader[S]) ShapesBetween

func (sp Spreader[S]) ShapesBetween(min, max S, shapes ...Shape[S])

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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