common

package
v0.4.0-preview.5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

This package provides some common functions and structs used in other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampFloat32 added in v0.1.1

func ClampFloat32(x, min, max float32) float32

ClampFloat32 limits the x value between min and max values.

func ClampFloat64 added in v0.1.1

func ClampFloat64(x, min, max float64) float64

ClampFloat64 limits the x value between min and max values.

func ClampInt added in v0.1.1

func ClampInt(x, min, max int) int

ClampInt limits the x value between min and max values.

func GoroutineId

func GoroutineId() int

func MaxFloat32 added in v0.2.7

func MaxFloat32(a, b float32) float32

MaxFloat32 returns the maximum of two floats.

func MinFloat32 added in v0.2.7

func MinFloat32(a, b float32) float32

MinFloat32 returns the minimum of two floats.

Types

type Boundary

type Boundary interface {
	IsPointInside(point a.Vector3) bool
	IsPointInside2D(point a.Vector3) bool
}

Boundary represents the boundaries of an object, like collider in unity

type Container added in v0.2.4

type Container interface {
	SetValue(value interface{})
	GetValue() interface{}
}

type DeviceInfo

type DeviceInfo struct {
}

func (DeviceInfo) FromMap

func (i DeviceInfo) FromMap(m map[string]interface{})

type EdgeInsets

type EdgeInsets struct {
	Left, Top, Right, Bottom float32
}

func NewEdgeInsets

func NewEdgeInsets(left, top, right, bottom float32) *EdgeInsets

func (*EdgeInsets) FromMap

func (e *EdgeInsets) FromMap(state a.SiMap)

func (*EdgeInsets) String

func (e *EdgeInsets) String() string

func (*EdgeInsets) ToMap

func (e *EdgeInsets) ToMap() a.SiMap

type Equatable

type Equatable interface {
	Equals(other interface{}) bool
}

Interface for making two values comparable.

type FloatRange

type FloatRange struct {
	Min, Max float32
}

FloatRange represents a range of values between min and max inclusive

func NewFloatRange

func NewFloatRange(min, max float32) FloatRange

NewFloatRange creates a new FloatRange with the given min and max values.

func (*FloatRange) GetLength

func (r *FloatRange) GetLength() float32

GetLength gets the length of the range.

func (*FloatRange) IsRangeInside added in v0.1.11

func (r *FloatRange) IsRangeInside(r2 FloatRange) bool

IsRangeInside checks if the given range is inside this range.

func (*FloatRange) IsValueInside

func (r *FloatRange) IsValueInside(value float32) bool

IsValueInside checks if specific value falls inside the range.

func (*FloatRange) Move added in v0.1.11

func (r *FloatRange) Move(d float32)

Move shifts the range's min and max values by the given value.

func (*FloatRange) Shrink

func (r *FloatRange) Shrink(d float32)

Shrink shrinks the range by the given value on both ends.

func (*FloatRange) ShrinkMax

func (r *FloatRange) ShrinkMax(d float32)

ShrinkMax shrinks the range by the given value on the max end.

func (*FloatRange) String

func (r *FloatRange) String() string

type IdGenerator

type IdGenerator struct {
	// contains filtered or unexported fields
}

func NewIdGenerator

func NewIdGenerator() *IdGenerator

func (*IdGenerator) NextId

func (g *IdGenerator) NextId() int

type Identifiable

type Identifiable interface {
	GetId() int64
}

type IntHashable

type IntHashable interface {
	GetHash() int64
}

type Platform

type Platform struct {
	// contains filtered or unexported fields
}

func PlatformFromString

func PlatformFromString(pString string) Platform

func (Platform) GetName

func (p Platform) GetName() string

func (Platform) ToString

func (p Platform) ToString() string

type Rect

type Rect struct {
	X, Y, Z FloatRange
}

Rect represents a boundary in 3D space

func NewRect

func NewRect(minX, maxX, minY, maxY, minZ, maxZ float32) *Rect

func NewRect2D

func NewRect2D(minX, maxX, minY, maxY, z float32) *Rect

func NewRectFromMinMaxPositions

func NewRectFromMinMaxPositions(min a.Vector3, max a.Vector3) *Rect

func NewRectFromPositionAndSize

func NewRectFromPositionAndSize(position a.Vector3, size a.Vector3) *Rect

func NewZeroRect

func NewZeroRect() *Rect

func (*Rect) IsPointInside

func (b *Rect) IsPointInside(v a.Vector3) bool

IsPointInside checks if specific point is inside the boundary

func (*Rect) IsPointInside2D

func (b *Rect) IsPointInside2D(v a.Vector3) bool

IsPointInside2D checks if specific point is inside the boundary ignoring z position

func (*Rect) IsRectInside

func (b *Rect) IsRectInside(rect *Rect) bool

IsRectInside checks if another rect is fully inside this rect.

func (*Rect) Max

func (b *Rect) Max() a.Vector3

Max returns the max (bottom-right) point of the rect.

func (*Rect) Min

func (b *Rect) Min() a.Vector3

Min returns the min (top-left) point of the rect.

func (*Rect) Move

func (b *Rect) Move(by a.Vector3)

Move shifts all coordinates of the rect by the given vector.

func (*Rect) Shrink

func (b *Rect) Shrink(by a.Vector3)

Shrink shrinks all dimensions of the rect by the given vector.

func (*Rect) ShrinkMax

func (b *Rect) ShrinkMax(by a.Vector3)

ShrinkMax shrinks max value of all dimensions of the rect by the given vector.

func (*Rect) Size

func (b *Rect) Size() a.Vector3

Size returns the size of the rect.

func (*Rect) String

func (b *Rect) String() string

type ScreenInfo

type ScreenInfo struct {
	// contains filtered or unexported fields
}

func NewScreenInfo

func NewScreenInfo(width, height int) ScreenInfo

func (ScreenInfo) FromMap

func (s ScreenInfo) FromMap(m map[string]interface{})

func (ScreenInfo) GetHeight

func (s ScreenInfo) GetHeight() int

func (ScreenInfo) GetSize added in v0.2.0

func (s ScreenInfo) GetSize() a.IntVector2

func (ScreenInfo) GetWidth

func (s ScreenInfo) GetWidth() int

type Toggleable added in v0.2.4

type Toggleable interface {
	SetEnabled(enabled bool)
	IsEnabled() bool
}

type ToggleableContainer added in v0.2.4

type ToggleableContainer interface {
	Toggleable
	Container
}

type ToggleableContainerImpl added in v0.2.4

type ToggleableContainerImpl struct {
	// contains filtered or unexported fields
}

func (*ToggleableContainerImpl) GetValue added in v0.2.4

func (t *ToggleableContainerImpl) GetValue() interface{}

func (*ToggleableContainerImpl) IsEnabled added in v0.2.4

func (t *ToggleableContainerImpl) IsEnabled() bool

func (*ToggleableContainerImpl) SetEnabled added in v0.2.4

func (t *ToggleableContainerImpl) SetEnabled(enabled bool)

func (*ToggleableContainerImpl) SetValue added in v0.2.4

func (t *ToggleableContainerImpl) SetValue(value interface{})

Directories

Path Synopsis
a
Package a provides most commonly used types in Amphion.
Package a provides most commonly used types in Amphion.
Package atext is used to manage and load fonts, layout and draw text.
Package atext is used to manage and load fonts, layout and draw text.
Package dispatch provides structs and interfaces to organize thread-safe communication between different modules of the program.
Package dispatch provides structs and interfaces to organize thread-safe communication between different modules of the program.

Jump to

Keyboard shortcuts

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