golyat

package module
v0.0.0-...-98a7000 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 1 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 https://github.com/llgcode/draw2d to make something useful from it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Align

func Align[S Scalar](on Axis[S], frac, target S, shapes ...Shape[S])

func Extent

func Extent[S Scalar](bb BBox[S], axis Axis[S]) S

func ExtentOf

func ExtentOf[S Scalar](s Shape[S], axis Axis[S]) S

func ForceOf

func ForceOf[S Scalar](s1, s2 Shape[S], axis Axis[S]) S

ForceOf computes the distance the two shapes would have to be moved apart alog the axis to avoid an overlap. The calculation takes into account possible margins that may be created by Borders.

func Frac

func Frac[S Scalar](bb BBox[S], f S, axis Axis[S]) S

func FracOf

func FracOf[S Scalar](s Shape[S], f S, axis Axis[S]) S

func Gap

func Gap[S Scalar](b1, b2 BBox[S], axis Axis[S]) S

Gap computes the width of the gap along axis between the bounding boxes b1 and b2.

func GapOf

func GapOf[S Scalar](s1, s2 Shape[S], axis Axis[S]) S

GapOf computes the gap along the axis between the bounding boxes of the two shapes s1 and s2.

func Height

func Height[S Scalar](bb BBox[S]) S

func MaxOf

func MaxOf[S Scalar](s Shape[S], axis Axis[S]) S

func MinOf

func MinOf[S Scalar](s Shape[S], axis Axis[S]) S

func Spread

func Spread[S Scalar](on Axis[S], frac, start, stop S, shapes ...Shape[S])

If only one shape that one's frac is moved to frac between start and stop

func Width

func Width[S Scalar](bb BBox[S]) S

Types

type Axis

type Axis[S Scalar] interface {
	Min(bb BBox[S]) S
	Max(bb BBox[S]) S
	Move(s Shape[S], d S)
	Cross() Axis[S]
}

type BBox

type BBox[S Scalar] interface {
	Xmin() S
	Xmax() S
	Ymin() S
	Ymax() S
}

type Border

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

func (*Border[S]) BBox

func (br *Border[S]) BBox() BBox[S]

func (*Border[S]) Move

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

type Container

type Container[S Scalar] struct {
	Rect[S]
	// contains filtered or unexported fields
}

func (*Container[S]) Add

func (c *Container[S]) Add(s Shape[S])

func (*Container[S]) AddAll

func (c *Container[S]) AddAll(ses ...Shape[S])

func (*Container[S]) Move

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

type Rect

type Rect[S Scalar] struct {
	// contains filtered or unexported fields
}

func NewRect

func NewRect[S Scalar](xMin, xMax, yMin, yMax S) *Rect[S]

func (*Rect[S]) BBox

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

func (*Rect[S]) Move

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

func (*Rect[S]) SetXmax

func (r *Rect[S]) SetXmax(x S)

func (*Rect[S]) SetXmin

func (r *Rect[S]) SetXmin(x S)

func (*Rect[S]) SetYmax

func (r *Rect[S]) SetYmax(y S)

func (*Rect[S]) SetYmin

func (r *Rect[S]) SetYmin(y S)

func (Rect[S]) Xmax

func (r Rect[S]) Xmax() S

func (Rect[S]) Xmin

func (r Rect[S]) Xmin() S

func (Rect[S]) Ymax

func (r Rect[S]) Ymax() S

func (Rect[S]) Ymin

func (r Rect[S]) Ymin() S

type Scalar

type Scalar interface{ ~float32 | ~float64 }

type Shape

type Shape[S Scalar] interface {
	BBox() BBox[S]
	Move(dx, dy S)
}

type XAxis

type XAxis[S Scalar] struct{}

func (XAxis[S]) Cross

func (XAxis[S]) Cross() Axis[S]

func (XAxis[S]) Max

func (XAxis[S]) Max(bb BBox[S]) S

func (XAxis[S]) Min

func (XAxis[S]) Min(bb BBox[S]) S

func (XAxis[S]) Move

func (XAxis[S]) Move(s Shape[S], d S)

type YAxis

type YAxis[S Scalar] struct{}

func (YAxis[S]) Cross

func (YAxis[S]) Cross() Axis[S]

func (YAxis[S]) Max

func (YAxis[S]) Max(bb BBox[S]) S

func (YAxis[S]) Min

func (YAxis[S]) Min(bb BBox[S]) S

func (YAxis[S]) Move

func (YAxis[S]) Move(s Shape[S], d S)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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