relpos

package
v1.4.31 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: BSD-3-Clause Imports: 4 Imported by: 136

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

View Source
var KiT_Relations = kit.Enums.AddEnum(RelationsN, kit.NotBitFlag, nil)
View Source
var KiT_XAligns = kit.Enums.AddEnum(XAlignsN, kit.NotBitFlag, nil)
View Source
var KiT_YAligns = kit.Enums.AddEnum(YAlignsN, kit.NotBitFlag, nil)

Functions

This section is empty.

Types

type Rel

type Rel struct {

	// spatial relationship between this layer and the other layer
	Rel Relations `desc:"spatial relationship between this layer and the other layer"`

	// [viewif: Rel=[FrontOf,Behind,Above,Below]] horizontal (x-axis) alignment relative to other
	XAlign XAligns `viewif:"Rel=[FrontOf,Behind,Above,Below]" desc:"horizontal (x-axis) alignment relative to other"`

	// [viewif: Rel=[LeftOf,RightOf,Above,Below]] vertical (y-axis) alignment relative to other
	YAlign YAligns `viewif:"Rel=[LeftOf,RightOf,Above,Below]" desc:"vertical (y-axis) alignment relative to other"`

	// name of the other layer we are in relationship to
	Other string `desc:"name of the other layer we are in relationship to"`

	// scaling factor applied to layer size for displaying
	Scale float32 `desc:"scaling factor applied to layer size for displaying"`

	// number of unit-spaces between us
	Space float32 `desc:"number of unit-spaces between us"`

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

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

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 added in v1.3.45

func NewAbove(other string) Rel

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

func NewBehind added in v1.3.45

func NewBehind(other string, space float32) Rel

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

func NewRightOf added in v1.3.45

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 mat32.Vec3, osz mat32.Vec2, sz mat32.Vec2) mat32.Vec3

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

type Relations

type Relations int

Relations are different spatial relationships (of layers)

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

	RelationsN
)

The relations

func (*Relations) FromString

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

func (Relations) MarshalJSON

func (ev Relations) MarshalJSON() ([]byte, error)

func (Relations) String

func (i Relations) String() string

func (*Relations) UnmarshalJSON

func (ev *Relations) UnmarshalJSON(b []byte) error

type XAligns

type XAligns int

XAligns are different horizontal alignments

const (
	Left XAligns = iota
	Middle
	Right

	XAlignsN
)

func (*XAligns) FromString

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

func (XAligns) MarshalJSON

func (ev XAligns) MarshalJSON() ([]byte, error)

func (XAligns) String

func (i XAligns) String() string

func (*XAligns) UnmarshalJSON

func (ev *XAligns) UnmarshalJSON(b []byte) error

type YAligns

type YAligns int

YAligns are different vertical alignments

const (
	Front YAligns = iota
	Center
	Back

	YAlignsN
)

func (*YAligns) FromString

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

func (YAligns) MarshalJSON

func (ev YAligns) MarshalJSON() ([]byte, error)

func (YAligns) String

func (i YAligns) String() string

func (*YAligns) UnmarshalJSON

func (ev *YAligns) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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