zgeo

package
v0.0.0-...-aa698f8 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: BSD-3-Clause Imports: 22 Imported by: 15

Documentation

Index

Constants

View Source
const (
	Left Alignment = 1 << iota
	Right
	Top
	HorCenter
	VertCenter
	Bottom
	HorExpand
	VertExpand
	HorShrink
	VertShrink
	HorOut
	VertOut

	Proportional
	MarginIsOffset // MarginIsOffset is a special flag used to offset a center alignment in absolute, instead of relative to sides.

	AlignmentNone Alignment = 0
	BottomLeft              = Bottom | Left
	BottomRight             = Bottom | Right
	BottomCenter            = Bottom | HorCenter
	TopLeft                 = Top | Left
	TopRight                = Top | Right
	TopCenter               = Top | HorCenter
	CenterLeft              = Left | VertCenter
	CenterRight             = Right | VertCenter

	Center    = HorCenter | VertCenter
	Expand    = HorExpand | VertExpand
	Shrink    = HorShrink | VertShrink
	HorScale  = HorExpand | HorShrink
	VertScale = VertExpand | VertShrink
	Scale     = HorScale | VertScale
	Out       = HorOut | VertOut

	VertPos    = Top | VertCenter | Bottom
	HorPos     = Left | HorCenter | Right
	Vertical   = VertPos | VertScale | VertOut
	Horizontal = HorPos | HorScale | HorOut
)

Variables

View Source
var ColorAqua = ColorNew(0, 1, 1, 1)
View Source
var ColorBlack = ColorNewGray(0, 1)
View Source
var ColorBlue = ColorNew(0, 0, 1, 1)
View Source
var ColorBrown = ColorNew(0.65, 0.26, 0.16, 1)
View Source
var ColorClear = ColorNewGray(0, 0)
View Source
var ColorCyan = ColorNew(0, 1, 1, 1)
View Source
var ColorDarkGray = ColorNewGray(0.25, 1)
View Source
var ColorDarkGreen = ColorNew(0, 0.5, 0, 1)
View Source
var ColorFuchsia = ColorNew(1, 0, 1, 1)
View Source
var ColorGray = ColorNewGray(0.5, 1)
View Source
var ColorGreen = ColorNew(0, 1, 0, 1)
View Source
var ColorLightGray = ColorNewGray(0.75, 1)
View Source
var ColorLime = ColorNew(0, 1, 0, 1)
View Source
var ColorMagenta = ColorNew(1, 0, 1, 1)
View Source
var ColorMaroon = ColorNew(0.5, 0, 0, 1)
View Source
var ColorNavy = ColorNew(0, 0, 0.5, 1)
View Source
var ColorOlive = ColorNew(0.5, 0.5, 0, 1)
View Source
var ColorOrange = ColorNew(1, 0.5, 0, 1)
View Source
var ColorPink = ColorNew(1, 0.8, 0.8, 1)
View Source
var ColorPurple = ColorNew(0.5, 0, 0.5, 1)
View Source
var ColorRed = ColorNew(1, 0, 0, 1)
View Source
var ColorSilver = ColorNew(0.75, 0.75, 0.75, 1)
View Source
var ColorTeal = ColorNew(0, 0.5, 0.5, 1)
View Source
var ColorWhite = ColorNewGray(1, 1)
View Source
var ColorYellow = ColorNew(1, 1, 0, 1)
View Source
var FontDefaultName = "Helvetica"
View Source
var FontDefaultSize = 14.0

DefaultSize This is used

View Source
var MatrixIdentity = Matrix{1, 0, 0, 1, 0, 0}

Functions

func ColorF

func ColorF(c Color) func() Color

func ForVectors

func ForVectors(positions []Pos, close bool, handle func(s Pos, v Pos) bool)

iterates through positions, making vector between them, optionally closing

func GetHemisphereDirectionsFromGeoAlignment

func GetHemisphereDirectionsFromGeoAlignment(alignment Alignment, separator, langCode string) string

func GoGrayColor

func GoGrayColor(gray float32) color.Gray

func MaxCellsInLength

func MaxCellsInLength(spacing, cellSize, inSize float64) int

MaxCellsInLength returns how many cells with an cellSize and spacing with fit in inSize

func MaxCellsInSize

func MaxCellsInSize(spacing, cellSize, inSize Size) (x, y int)

func PosLongLatToMeters

func PosLongLatToMeters(pos1 Pos, pos2 Pos) float64

func TSL

func TSL(s, lang string) string

Types

type Alignment

type Alignment zbits.NamedBit

func AlignmentFromString

func AlignmentFromString(str string) Alignment

func (Alignment) And

func (a Alignment) And(b Alignment) Alignment

func (Alignment) FlippedHorizontal

func (a Alignment) FlippedHorizontal() Alignment

func (Alignment) FlippedVertical

func (a Alignment) FlippedVertical() Alignment

func (Alignment) Has

func (a Alignment) Has(mask Alignment) bool

func (Alignment) HasAll

func (a Alignment) HasAll(mask Alignment) bool

func (Alignment) MarshalJSON

func (a Alignment) MarshalJSON() ([]byte, error)

func (Alignment) Only

func (a Alignment) Only(vertical bool) Alignment

func (Alignment) SplitIntoIndividual

func (a Alignment) SplitIntoIndividual() (all []Alignment)

For an Alignment that has multiple x/y alignments (i.e Left and Right), SplitIntoIndividual returns a slice of all combinations of them with only a single x/y combination each

func (Alignment) String

func (a Alignment) String() string

func (Alignment) Subtracted

func (a Alignment) Subtracted(sub Alignment) Alignment

func (Alignment) Swapped

func (a Alignment) Swapped() Alignment

Swapped returns a new alignment where all the vertical alignments are the equivalent of what the horizontal ones were, and visa versa.

func (Alignment) Union

func (a Alignment) Union(b Alignment) Alignment

func (*Alignment) UnmarshalJSON

func (a *Alignment) UnmarshalJSON(b []byte) error

func (Alignment) Vector

func (a Alignment) Vector() Pos

type BoolSize

type BoolSize struct {
	W bool `json:"w"`
	H bool `json:"h"`
}

type Circle

type Circle struct {
	Center Pos
	Radius float64
}

type Color

type Color struct {
	Valid  bool
	Colors RGBA
}

func ColorFromGo

func ColorFromGo(c color.Color) Color

func ColorFromSlice

func ColorFromSlice(s []float32) Color

ColorFromSlice returns a opaque gray for 1 item, graya for 2, opaque rgb for 3, and rgba for 4

func ColorFromString

func ColorFromString(str string) Color

func ColorNew

func ColorNew(r, g, b, a float32) (c Color)

func ColorNew255

func ColorNew255(r, g, b, a int) (c Color)

func ColorNewGray

func ColorNewGray(white, a float32) (c Color)

func ColorNewHSBA

func ColorNewHSBA(hsba HSBA) (c Color)

func ColorRandom

func ColorRandom() Color

func KelvinToColor

func KelvinToColor(kelvin float32) Color

func (Color) AlteredContrast

func (c Color) AlteredContrast(contrast float32) Color

func (Color) ContrastingGray

func (c Color) ContrastingGray() Color

func (Color) Difference

func (c Color) Difference(a Color) float32

Difference returns the difference brween c and a, where 0 is same, 1 is black to white. Opacity is used, so each 4 components contribute 25% each

func (Color) GoColor

func (c Color) GoColor() (gcol color.NRGBA64)

func (Color) GoGrayColor

func (c Color) GoGrayColor() color.Gray

func (Color) GrayScale

func (c Color) GrayScale() float32

func (Color) GrayScaleAndAlpha

func (c Color) GrayScaleAndAlpha() (float32, float32)

func (Color) HSBA

func (c Color) HSBA() (hsba HSBA)

func (Color) Hex

func (c Color) Hex() string

func (Color) HexNoAlpha

func (c Color) HexNoAlpha() string

func (Color) MarshalJSON

func (c Color) MarshalJSON() ([]byte, error)

func (Color) Mixed

func (c Color) Mixed(withColor Color, amount float32) Color

Mixed() returns amount portion of withColor and 1-amount of c mixed. amount is first multiplied by withColor's alpha. The resulting alpha is the product of the two color alphas. If either color is not valid, the other one is returned.

func (Color) MixedColor

func (c Color) MixedColor(withColor Color, amount float32) Color

MixedColor creates a color using HSBA with HS from withColor and BA from c. It is then mixed into c, effectively changing its color.

func (Color) MultipliedBrightness

func (c Color) MultipliedBrightness(multiply float32) Color

func (Color) Opacity

func (c Color) Opacity() float32

func (Color) OpacityInverted

func (c Color) OpacityInverted() Color

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA returns r, g, b, a as 0-255 uint32 values. Makes it conform to image/color Color interface

func (Color) RGBAValue

func (c Color) RGBAValue() RGBA

func (*Color) SetFromString

func (c *Color) SetFromString(str string)

func (*Color) SetOpacity

func (c *Color) SetOpacity(opacity float32)

func (Color) Slice32

func (c Color) Slice32() []float32

func (Color) SliceInt255

func (c Color) SliceInt255() []int

func (*Color) UnmarshalJSON

func (c *Color) UnmarshalJSON(b []byte) error

func (Color) WithOpacity

func (c Color) WithOpacity(opacity float32) Color

type FPos

type FPos struct {
	X float32 `json:"x"`
	Y float32 `json:"y"`
}

func (FPos) Pos

func (p FPos) Pos() Pos

type FSize

type FSize struct {
	W float32 `json:"w"`
	H float32 `json:"h"`
}

type Font

type Font struct {
	Name  string    `json:"name"`
	Style FontStyle `json:"style"`
	Size  float64   `json:"size"`
}

TODO: Make font NOT pointer when passing around. Too easy to change something used elsewhere then

func FontDefault

func FontDefault(incSize float64) *Font

func FontNew

func FontNew(name string, size float64, style FontStyle) *Font

func FontNice

func FontNice(size float64, style FontStyle) *Font

func (*Font) LineHeight

func (f *Font) LineHeight() float64

func (*Font) NewWithSize

func (f *Font) NewWithSize(size float64) *Font

func (*Font) NewWithStyle

func (f *Font) NewWithStyle(style FontStyle) *Font

func (*Font) PointSize

func (f *Font) PointSize() float64

type FontSetter

type FontSetter interface {
	SetFont(*Font)
}

type FontStyle

type FontStyle int
const (
	FontStyleUndef      FontStyle = 0
	FontStyleNormal     FontStyle = 1
	FontStyleBold       FontStyle = 2
	FontStyleItalic     FontStyle = 4
	FontStyleBoldItalic FontStyle = FontStyleBold | FontStyleItalic
)

func FontStyleFromStr

func FontStyleFromStr(str string) FontStyle

func (FontStyle) String

func (s FontStyle) String() string

type HSBA

type HSBA struct {
	H float32 `json:"H"`
	S float32 `json:"S"`
	B float32 `json:"B"`
	A float32 `json:"A"`
}

type IPos

type IPos struct {
	X int
	Y int
}

func (*IPos) ToPos

func (p *IPos) ToPos() Pos

type ISize

type ISize struct {
	W int `json:"w"`
	H int `json:"h"`
}

type LayoutCell

type LayoutCell struct {
	Alignment        Alignment // Alignment is how cell is placed within parent rect and siblings. If AlignmentNone, it is not placed at all
	Margin           Rect      // Margin is the size around object in cell
	MaxSize          Size      // MaxSize is maximum size of object before margin. Can be only W or H
	MinSize          Size      // MinSize is minimum size of object before margin. Can be only W or H
	Collapsed        bool      // Collapsed is a cell that currently is not shown or takes up space.
	Free             bool      // Free Cells are placed using simple aligning to parent rect, not stacked etc
	OriginalSize     Size      // Original size of object before layout
	Divider          float64   // This cell is a divider, wants its value subtracted from item before it, added to item after
	RelativeToName   string    // If Free, and set, it is aligned to other cell with name
	ShowIfExtraSpace float64   // If set, show only if enough extra space left over
	Name             string    // A name for debugging/aligning
}

type Matrix

type Matrix struct {
	A, B, C, D, Tx, Ty float64
}

func MatrixForRotatingAroundPoint

func MatrixForRotatingAroundPoint(point Pos, deg float64) Matrix

func MatrixForRotationDeg

func MatrixForRotationDeg(deg float64) Matrix

func RotateMatrix

func RotateMatrix(angle float64) *Matrix

func ScaleMatrix

func ScaleMatrix(sz Size) *Matrix

func TranslateMatrix

func TranslateMatrix(delta Size) *Matrix

func (Matrix) Inverted

func (m Matrix) Inverted() (Matrix, bool)

func (Matrix) MulPos

func (m Matrix) MulPos(pt Pos) Pos

func (Matrix) MulSize

func (m Matrix) MulSize(sz Size) Size

func (Matrix) Multiplied

func (m Matrix) Multiplied(a Matrix) Matrix

func (Matrix) Rotated

func (m Matrix) Rotated(angle float64) Matrix

func (Matrix) RotatedAroundPos

func (m Matrix) RotatedAroundPos(pos Pos, angle float64) Matrix

func (Matrix) Scaled

func (m Matrix) Scaled(sz Size) Matrix

func (Matrix) TransformRect

func (m Matrix) TransformRect(rect Rect) Rect

func (Matrix) Translated

func (m Matrix) Translated(delta Size) Matrix

func (Matrix) TranslatedByPos

func (m Matrix) TranslatedByPos(delta Pos) Matrix

type Path

type Path struct {
	Nodes []PathNode `json:",omitempty"`
}

func NewOvalPath

func NewOvalPath(rect Rect) *Path

func PathNew

func PathNew() *Path

func PathNewRect

func PathNewRect(rect Rect, corner Size) *Path

func (*Path) AddOval

func (p *Path) AddOval(inrect Rect)

func (*Path) AddPath

func (p *Path) AddPath(addPath *Path, join bool, m *Matrix)

func (*Path) AddRect

func (p *Path) AddRect(rect Rect, corner Size)

func (*Path) AddStar

func (p *Path) AddStar(rect Rect, points int, inRatio float32)

func (*Path) ArcDegFromCenter

func (p *Path) ArcDegFromCenter(center Pos, radius Size, degStart float64, degEnd float64)

func (*Path) ArcTo

func (p *Path) ArcTo(rect Rect, degStart, degDelta float64, clockwise bool)

func (*Path) BezierTo

func (p *Path) BezierTo(c1 Pos, c2 Pos, end Pos)

func (*Path) Circle

func (p *Path) Circle(center Pos, radius Size)

func (*Path) Close

func (p *Path) Close()

func (*Path) Copy

func (p *Path) Copy() *Path

func (*Path) Empty

func (p *Path) Empty()

func (*Path) ForEachPart

func (p *Path) ForEachPart(forPart func(part PathNode))

func (*Path) GetPos

func (p *Path) GetPos() (Pos, bool)

func (*Path) IsEmpty

func (p *Path) IsEmpty() bool

func (*Path) LineTo

func (p *Path) LineTo(pos Pos)

func (*Path) MoveOrLineTo

func (p *Path) MoveOrLineTo(pos Pos) bool

func (*Path) MoveTo

func (p *Path) MoveTo(pos Pos)

func (*Path) NodeCount

func (p *Path) NodeCount() int

func (*Path) QuadCurveTo

func (p *Path) QuadCurveTo(a, b Pos)

func (*Path) Rect

func (p *Path) Rect() Rect

func (*Path) Rotated

func (p *Path) Rotated(deg float64, origin *Pos) *Path

func (*Path) Scan

func (p *Path) Scan(value interface{}) error

func (*Path) Transformed

func (p *Path) Transformed(m *Matrix) (newPath *Path)

func (Path) Value

func (p Path) Value() (driver.Value, error)

type PathLineType

type PathLineType int
const (
	PathLineSquare PathLineType = iota
	PathLineRound
	PathLineButt
)

func (*PathLineType) MarshalJSON

func (p *PathLineType) MarshalJSON() ([]byte, error)

func (*PathLineType) UnmarshalJSON

func (p *PathLineType) UnmarshalJSON(b []byte) error

type PathNode

type PathNode struct {
	Type   PathPartType
	Points []Pos `json:",omitempty"`
}

type PathPartType

type PathPartType int
const (
	PathMove PathPartType = iota
	PathLine
	PathQuadCurve
	PathCurve
	PathClose
)

func (*PathPartType) MarshalJSON

func (p *PathPartType) MarshalJSON() ([]byte, error)

func (*PathPartType) UnmarshalJSON

func (p *PathPartType) UnmarshalJSON(b []byte) error

type Pos

type Pos struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}
var (
	PosUndef = PosD(zfloat.Undefined, zfloat.Undefined)
	PosNull  Pos
)

func GetTPositionInPosPath

func GetTPositionInPosPath(path []Pos, t float64, close bool) Pos

func PosBoth

func PosBoth(n float64) Pos

func PosD

func PosD(x, y float64) Pos

func PosF

func PosF(x, y float32) Pos

func PosFromAngleDeg

func PosFromAngleDeg(deg float64) Pos

func PosFromGoPoint

func PosFromGoPoint(point image.Point) Pos

func PosFromString

func PosFromString(str string) (Pos, error)

func PosI

func PosI(x, y int) Pos

func TranslatePosInSystems

func TranslatePosInSystems(from, to Rect, pos Pos) Pos

func (Pos) Abs

func (p Pos) Abs() Pos

func (*Pos) Add

func (p *Pos) Add(a Pos)

func (Pos) AddedSize

func (p Pos) AddedSize(s Size) Pos

func (Pos) ArcTanToRad

func (pos Pos) ArcTanToRad() float64

func (Pos) Average

func (p Pos) Average() float64

func (Pos) Ceil

func (p Pos) Ceil() Pos

func (Pos) Copy

func (p Pos) Copy() Pos

func (Pos) DividedBy

func (p Pos) DividedBy(a Pos) Pos

func (Pos) DividedByD

func (p Pos) DividedByD(a float64) Pos

func (Pos) Dot

func (p Pos) Dot(a Pos) float64

func (Pos) Element

func (p Pos) Element(vertical bool) float64

func (Pos) Equals

func (p Pos) Equals(a Pos) bool

func (Pos) Floor

func (p Pos) Floor() Pos

func (Pos) GetNormalized

func (p Pos) GetNormalized() Pos

func (Pos) GetRot90CW

func (p Pos) GetRot90CW() Pos

func (Pos) GoPoint

func (p Pos) GoPoint() image.Point

func (Pos) IsNull

func (p Pos) IsNull() bool

func (Pos) IsSameDirection

func (p Pos) IsSameDirection(pos Pos) bool

func (Pos) Length

func (p Pos) Length() float64

func (Pos) Max

func (p Pos) Max(a Pos) Pos

func (Pos) Min

func (p Pos) Min(a Pos) Pos

func (Pos) Minus

func (p Pos) Minus(a Pos) Pos

func (Pos) MinusD

func (p Pos) MinusD(a float64) Pos

func (*Pos) MultiplyD

func (p *Pos) MultiplyD(a float64)

func (Pos) Negative

func (p Pos) Negative() Pos

func (Pos) Plus

func (p Pos) Plus(a Pos) Pos

func (Pos) PlusD

func (p Pos) PlusD(a float64) Pos

func (Pos) RotatedCCW

func (p Pos) RotatedCCW(angle float64) Pos

func (Pos) Round

func (p Pos) Round() Pos

func (*Pos) Scan

func (p *Pos) Scan(value interface{}) error

func (*Pos) Set

func (p *Pos) Set(x, y float64)

func (*Pos) SetF

func (p *Pos) SetF(x, y float32)

func (*Pos) SetOne

func (p *Pos) SetOne(vertical bool, v float64)

func (Pos) Sign

func (p Pos) Sign() Pos

func (Pos) Size

func (p Pos) Size() Size

func (Pos) String

func (p Pos) String() string

func (*Pos) Subtract

func (p *Pos) Subtract(a Pos)

func (*Pos) Swap

func (p *Pos) Swap()

func (Pos) Swapped

func (p Pos) Swapped() Pos

func (Pos) Times

func (p Pos) Times(a Pos) Pos

func (Pos) TimesD

func (p Pos) TimesD(a float64) Pos

func (Pos) ToAngleDeg

func (p Pos) ToAngleDeg() float64

func (Pos) Value

func (p Pos) Value() (driver.Value, error)

func (*Pos) ZUISetFromString

func (p *Pos) ZUISetFromString(str string)

func (Pos) ZUIString

func (p Pos) ZUIString() string

type RGBA

type RGBA struct {
	R float32 `json:"R"`
	G float32 `json:"G"`
	B float32 `json:"B"`
	A float32 `json:"A"`
}

type Rect

type Rect struct {
	Pos  Pos  `json:"pos"`
	Size Size `json:"size"`
}
var (
	RectUndef = RectFromWH(math.MaxFloat32, math.MaxFloat32)
	RectNull  Rect
)

func CellsSpanInBox

func CellsSpanInBox(box Rect, cellSize, spacing Size, cellCount int) (x, y int, area Rect)

CellsSpanInBox returns the number of *column* and *rows& *cellCount* cells of *cellSize* will span in *box*. It lays them out in rows first. If *cellCount* is <= 0, it returns for filling the box. size is the size these layed out cells will occupy.

func LayoutCellsInStack

func LayoutCellsInStack(debugName string, rect Rect, vertical bool, spacing float64, cells []LayoutCell) []Rect

LayoutCellsInStack stacks cells horizontally or vertically in rect, returning resulting slice of rects in same slice positions as input cells.

func MergeAllOverlapping

func MergeAllOverlapping(rects []Rect) []Rect

func RectFromCenterSize

func RectFromCenterSize(center Pos, size Size) Rect

func RectFromGoRect

func RectFromGoRect(rect image.Rectangle) Rect

func RectFromMarginSize

func RectFromMarginSize(m Size) Rect

func RectFromMinMax

func RectFromMinMax(min, max Pos) Rect

func RectFromWH

func RectFromWH(w, h float64) Rect

func RectFromXY2

func RectFromXY2(x, y, x2, y2 float64) Rect

func RectFromXYWH

func RectFromXYWH(x, y, w, h float64) Rect

func RectMake

func RectMake(x0, y0, x1, y1 float64) Rect

func RectMarginForSizeAndAlign

func RectMarginForSizeAndAlign(marg Size, align Alignment) Rect

func TranslateRectInSystems

func TranslateRectInSystems(from, to Rect, r Rect) Rect

func (*Rect) Add

func (r *Rect) Add(a Rect)

func (*Rect) AddPos

func (r *Rect) AddPos(a Pos)

func (Rect) Align

func (r Rect) Align(s Size, align Alignment, marg Size) Rect

func (Rect) AlignPro

func (r Rect) AlignPro(s Size, align Alignment, rmarg Rect, maxSize, minSize Size) Rect

func (Rect) BottomLeft

func (r Rect) BottomLeft() Pos

func (Rect) BottomRight

func (r Rect) BottomRight() Pos

func (Rect) Center

func (r Rect) Center() Pos

func (Rect) Centered

func (r Rect) Centered(center Pos) Rect

func (Rect) Contains

func (r Rect) Contains(pos Pos) bool

func (Rect) DividedBy

func (r Rect) DividedBy(a Size) Rect

func (Rect) DividedByD

func (r Rect) DividedByD(d float64) Rect

func (Rect) Expanded

func (r Rect) Expanded(s Size) Rect

func (Rect) ExpandedD

func (r Rect) ExpandedD(n float64) Rect

func (Rect) ExpandedToInt

func (r Rect) ExpandedToInt() Rect

func (Rect) GoRect

func (r Rect) GoRect() image.Rectangle

func (*Rect) IncMax

func (r *Rect) IncMax(x, y float64)

func (*Rect) IncMin

func (r *Rect) IncMin(x, y float64)

func (Rect) Intersected

func (r Rect) Intersected(rect Rect) Rect

func (Rect) IsNull

func (r Rect) IsNull() bool

func (Rect) IsUndef

func (r Rect) IsUndef() bool

func (Rect) MM

func (r Rect) MM() string

func (Rect) Max

func (r Rect) Max() Pos

func (Rect) Min

func (r Rect) Min() Pos

func (Rect) MinMax

func (r Rect) MinMax() (Pos, Pos)

func (Rect) Minus

func (r Rect) Minus(a Rect) Rect

func (Rect) MovedInto

func (r Rect) MovedInto(rect Rect) (m Rect)

func (Rect) NormalizedNegativeSize

func (r Rect) NormalizedNegativeSize() Rect

func (Rect) Overlaps

func (r Rect) Overlaps(rect Rect) bool

func (Rect) Plus

func (r Rect) Plus(a Rect) Rect

func (Rect) PlusPos

func (r Rect) PlusPos(pos Pos) Rect

func (*Rect) SetCenter

func (r *Rect) SetCenter(c Pos)

func (*Rect) SetMax

func (r *Rect) SetMax(max Pos)

func (*Rect) SetMaxX

func (r *Rect) SetMaxX(x float64)

func (*Rect) SetMaxY

func (r *Rect) SetMaxY(y float64)

func (*Rect) SetMin

func (r *Rect) SetMin(min Pos)

func (*Rect) SetMinX

func (r *Rect) SetMinX(x float64)

func (*Rect) SetMinY

func (r *Rect) SetMinY(y float64)

func (Rect) String

func (r Rect) String() string

func (*Rect) Subtract

func (r *Rect) Subtract(a Pos)

func (Rect) Swapped

func (r Rect) Swapped() Rect

Swapped returns a Rect where the vertical and horizontal components are swapped

func (Rect) TimesD

func (r Rect) TimesD(d float64) Rect

func (Rect) TopLeft

func (r Rect) TopLeft() Pos

func (Rect) TopRight

func (r Rect) TopRight() Pos

func (*Rect) Translated

func (r *Rect) Translated(t Pos) Rect

func (*Rect) UnionWithPos

func (r *Rect) UnionWithPos(pos Pos)

func (Rect) UnionedWith

func (r Rect) UnionedWith(rect Rect) Rect

func (Rect) XCenter

func (r Rect) XCenter() float64

func (Rect) YCenter

func (r Rect) YCenter() float64

type Size

type Size struct {
	W float64 `json:"w"`
	H float64 `json:"h"`
}
var (
	SizeUndef = Size{W: zfloat.Undefined, H: zfloat.Undefined}
	SizeNull  Size
)

func LayoutGetCellsStackedSize

func LayoutGetCellsStackedSize(debugName string, vertical bool, spacing float64, cells []LayoutCell) (s, max Size)

func SizeBoth

func SizeBoth(a float64) Size

SizeBoth uses a for W and H

func SizeD

func SizeD(w, h float64) Size

SizeF creates a Size from float64 w and h

func SizeF

func SizeF(w, h float32) Size

SizeF creates a Size from float64 w and h

func SizeFromString

func SizeFromString(str string) (Size, error)

func SizeI

func SizeI(w, h int) Size

SizeI creates a Size from integer w and h

func SizeI64

func SizeI64(w, h int64) Size

SizeI64 creates a Size from int64 w and h

func (*Size) Add

func (s *Size) Add(a Size)

func (*Size) AddD

func (s *Size) AddD(a float64)

func (Size) Area

func (s Size) Area() float64

Area returns the product of W, H (WxH)

func (Size) Ceil

func (s Size) Ceil() Size

func (Size) Contains

func (s Size) Contains(a Size) bool

func (Size) Copy

func (s Size) Copy() Size

func (*Size) DivideD

func (s *Size) DivideD(a float64)

func (Size) DividedBy

func (s Size) DividedBy(a Size) Size

func (Size) DividedByD

func (s Size) DividedByD(a float64) Size

func (Size) Element

func (s Size) Element(vertical bool) float64

Vertice returns the non-vertical s.W or vertical s.H

func (Size) EqualSided

func (s Size) EqualSided() Size

EqualSided returns a Size where W and H are largest of the two

func (Size) Equals

func (s Size) Equals(a Size) bool

func (Size) ExpandedInto

func (s Size) ExpandedInto(in Size) Size

ExpandTo makes s just fit in 'in' proportionally, if smaller

func (Size) Floor

func (s Size) Floor() Size

func (Size) ISize

func (s Size) ISize() ISize

func (Size) IsNull

func (s Size) IsNull() bool

IsNull returns true if S and W are zero

func (Size) IsUndef

func (s Size) IsUndef() bool

func (Size) MarshalJSON

func (s Size) MarshalJSON() ([]byte, error)

func (Size) Max

func (s Size) Max() float64

Max returns the greater of W and H

func (Size) MaxWith

func (s Size) MaxWith(a Size) Size

func (*Size) Maximize

func (s *Size) Maximize(a Size)

func (Size) Min

func (s Size) Min() float64

Min returns the lesser of W and H

func (Size) MinWith

func (s Size) MinWith(a Size) Size

func (*Size) Minimize

func (s *Size) Minimize(a Size)

func (*Size) MinimizeNonZero

func (s *Size) MinimizeNonZero(a Size)

MinimizeNonZero sets s to minimum of s and a.

func (Size) Minus

func (s Size) Minus(a Size) Size

func (Size) MinusD

func (s Size) MinusD(a float64) Size

func (*Size) MultiplyD

func (s *Size) MultiplyD(a float64)

func (*Size) MultiplyF

func (s *Size) MultiplyF(a float32)

func (Size) Negative

func (s Size) Negative() Size

func (Size) Plus

func (s Size) Plus(a Size) Size

func (Size) Pos

func (s Size) Pos() Pos

Pos converts a size to a Pos

func (Size) Round

func (s Size) Round() Size

func (Size) ScaledTo

func (s Size) ScaledTo(in Size) Size

ScaledTo makes s just fit in 'in' proportionally

func (*Size) Scan

func (s *Size) Scan(value interface{}) error

func (*Size) Set

func (s *Size) Set(w, h float64)

func (*Size) SetElement

func (s *Size) SetElement(vertical bool, n float64)

func (Size) ShrunkInto

func (s Size) ShrunkInto(in Size) Size

ShrunkInto makes s just fit in 'in' proportionally, if bigger

func (Size) String

func (s Size) String() string

func (*Size) Subtract

func (s *Size) Subtract(a Size)

func (s Size) MultipliedBy(a Size) Size { return Size{s.W * a.W, s.H * a.H} } func (s Size) MultipliedByD(a float64) Size { return Size{s.W * a, s.H * a} }

func (*Size) SubtractD

func (s *Size) SubtractD(d float64)

func (Size) Swapped

func (s Size) Swapped() Size

func (Size) Times

func (s Size) Times(a Size) Size

func (Size) TimesD

func (s Size) TimesD(a float64) Size

func (*Size) UnmarshalJSON

func (s *Size) UnmarshalJSON(b []byte) error

func (Size) Value

func (s Size) Value() (driver.Value, error)

func (*Size) ZUISetFromString

func (s *Size) ZUISetFromString(str string)

func (Size) ZUIString

func (s Size) ZUIString() string

type Sizes

type Sizes []Size

func (Sizes) GetItems

func (s Sizes) GetItems() (items zdict.Items)

func (*Sizes) IndexOf

func (s *Sizes) IndexOf(size Size) int

Jump to

Keyboard shortcuts

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