relpos

package
v2.0.0-dev0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 3 Imported by: 7

README

Docs: GoDoc

Package relpos provides relative positioning values for positioning layers relative to each other in 3D space, using the following relationships:

  • Above, Below, LeftOf, RightOf, Front, Behind

Documentation

Overview

Package relpos defines a position relationship among layers, in terms of X,Y width and height of layer and associated position within a given X-Y plane, and Z vertical stacking of layers above and below each other.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rel

type Rel struct {

	// spatial relationship between this layer and the other layer
	Rel Relations

	// ] horizontal (x-axis) alignment relative to other
	XAlign XAligns

	// ] vertical (y-axis) alignment relative to other
	YAlign YAligns

	// name of the other layer we are in relationship to
	Other string

	// scaling factor applied to layer size for displaying
	Scale float32

	// number of unit-spaces between us
	Space float32

	// for vertical (y-axis) alignment, amount we are offset relative to perfect alignment
	XOffset float32

	// for horizontial (x-axis) alignment, amount we are offset relative to perfect alignment
	YOffset float32
}

Rel defines a position relationship among layers, in terms of X,Y width and height of layer and associated position within a given X-Y plane, and Z vertical stacking of layers above and below each other.

func NewAbove

func NewAbove(other string) Rel

NewAbove returns an Above relationship with default XAlign: Left, YAlign: Front alignment

func NewBehind

func NewBehind(other string, space float32) Rel

NewBehind returns a Behind relationship with default XAlign: Left alignment and given spacing

func NewRightOf

func NewRightOf(other string, space float32) Rel

NewRightOf returns a RightOf relationship with default YAlign: Front alignment and given spacing

func (*Rel) AlignXPos

func (rp *Rel) AlignXPos(xop, xosz, xsz float32) float32

AlignXPos returns the X-axis (within-plane horizontal or width) position according to alignment factors

func (*Rel) AlignYPos

func (rp *Rel) AlignYPos(yop, yosz, ysz float32) float32

AlignYPos returns the Y-axis (within-plane vertical or height) position according to alignment factors

func (*Rel) Defaults

func (rp *Rel) Defaults()

Defaults sets default scale, space, offset values -- rel, align must be set specifically These are automatically applied if Scale = 0

func (*Rel) Pos

func (rp *Rel) Pos(op math32.Vector3, osz math32.Vector2, sz math32.Vector2) math32.Vector3

Pos returns the relative position compared to other position and size, based on settings osz and sz must both have already been scaled by relevant Scale factor

func (*Rel) ShouldShow

func (rp *Rel) ShouldShow(field string) bool

type Relations

type Relations int32 //enums:enum

Relations are different spatial relationships (of layers)

const (
	NoRel Relations = iota
	RightOf
	LeftOf
	Behind
	FrontOf
	Above
	Below
)

The relations

const RelationsN Relations = 7

RelationsN is the highest valid value for type Relations, plus one.

func RelationsValues

func RelationsValues() []Relations

RelationsValues returns all possible values for the type Relations.

func (Relations) Desc

func (i Relations) Desc() string

Desc returns the description of the Relations value.

func (Relations) Int64

func (i Relations) Int64() int64

Int64 returns the Relations value as an int64.

func (Relations) MarshalText

func (i Relations) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Relations) SetInt64

func (i *Relations) SetInt64(in int64)

SetInt64 sets the Relations value from an int64.

func (*Relations) SetString

func (i *Relations) SetString(s string) error

SetString sets the Relations value from its string representation, and returns an error if the string is invalid.

func (Relations) String

func (i Relations) String() string

String returns the string representation of this Relations value.

func (*Relations) UnmarshalText

func (i *Relations) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Relations) Values

func (i Relations) Values() []enums.Enum

Values returns all possible values for the type Relations.

type XAligns

type XAligns int32 //enums:enum

XAligns are different horizontal alignments

const (
	Left XAligns = iota
	Middle
	Right
)
const XAlignsN XAligns = 3

XAlignsN is the highest valid value for type XAligns, plus one.

func XAlignsValues

func XAlignsValues() []XAligns

XAlignsValues returns all possible values for the type XAligns.

func (XAligns) Desc

func (i XAligns) Desc() string

Desc returns the description of the XAligns value.

func (XAligns) Int64

func (i XAligns) Int64() int64

Int64 returns the XAligns value as an int64.

func (XAligns) MarshalText

func (i XAligns) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*XAligns) SetInt64

func (i *XAligns) SetInt64(in int64)

SetInt64 sets the XAligns value from an int64.

func (*XAligns) SetString

func (i *XAligns) SetString(s string) error

SetString sets the XAligns value from its string representation, and returns an error if the string is invalid.

func (XAligns) String

func (i XAligns) String() string

String returns the string representation of this XAligns value.

func (*XAligns) UnmarshalText

func (i *XAligns) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (XAligns) Values

func (i XAligns) Values() []enums.Enum

Values returns all possible values for the type XAligns.

type YAligns

type YAligns int32 //enums:enum

YAligns are different vertical alignments

const (
	Front YAligns = iota
	Center
	Back
)
const YAlignsN YAligns = 3

YAlignsN is the highest valid value for type YAligns, plus one.

func YAlignsValues

func YAlignsValues() []YAligns

YAlignsValues returns all possible values for the type YAligns.

func (YAligns) Desc

func (i YAligns) Desc() string

Desc returns the description of the YAligns value.

func (YAligns) Int64

func (i YAligns) Int64() int64

Int64 returns the YAligns value as an int64.

func (YAligns) MarshalText

func (i YAligns) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*YAligns) SetInt64

func (i *YAligns) SetInt64(in int64)

SetInt64 sets the YAligns value from an int64.

func (*YAligns) SetString

func (i *YAligns) SetString(s string) error

SetString sets the YAligns value from its string representation, and returns an error if the string is invalid.

func (YAligns) String

func (i YAligns) String() string

String returns the string representation of this YAligns value.

func (*YAligns) UnmarshalText

func (i *YAligns) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (YAligns) Values

func (i YAligns) Values() []enums.Enum

Values returns all possible values for the type YAligns.

Jump to

Keyboard shortcuts

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