relpos

package
v2.0.0-dev0.1.7 Latest Latest
Warning

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

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

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 Pos

type Pos 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

	// Pos is the computed position of lower-left-hand corner of layer
	// in 3D space, computed from the relation to other layer.
	Pos math32.Vector3 `edit:"-"`
}

Pos specifies the relative spatial relationship to another layer, which determines positioning. Every layer except one "anchor" layer should be positioned relative to another, e.g., RightOf, Above, etc. This provides robust positioning in the face of layer size changes etc. Layers are arranged in X-Y planes, stacked vertically along the Z axis.

func (*Pos) AlignXPos

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

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

func (*Pos) AlignYPos

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

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

func (*Pos) Defaults

func (rp *Pos) Defaults()

Defaults sets default scale, space, offset values. The relationship and align must be set specifically. These are automatically applied if Scale = 0

func (*Pos) SetAbove

func (rp *Pos) SetAbove(other string)

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

func (*Pos) SetBehind

func (rp *Pos) SetBehind(other string, space float32)

SetBehind sets a Behind relationship with default XAlign: Left alignment and given spacing.

func (*Pos) SetPos

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

SetPos sets the relative position based on other layer position and size, using current settings. osz and sz must both have already been scaled by relevant Scale factor.

func (*Pos) SetRightOf

func (rp *Pos) SetRightOf(other string, space float32)

SetRightOf sets a RightOf relationship with default YAlign: Front alignment and given spacing.

func (*Pos) ShouldDisplay

func (rp *Pos) ShouldDisplay(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