a

package
v0.4.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package a provides most commonly used types in Amphion.

Index

Constants

View Source
const (
	MatchParent float32 = -9_999_999 + iota*10
	WrapContent
	CenterInParent
	FillParent
)

Variables

This section is empty.

Functions

func ByteArrayToInt

func ByteArrayToInt(arr []byte) int

func ByteArrayToInt64

func ByteArrayToInt64(arr []byte) int64

func CopyByteArray

func CopyByteArray(src []byte, target []byte, start, length int) error

func Float32ToByteArray

func Float32ToByteArray(num float32) []byte

func Float64ToByteArray

func Float64ToByteArray(num float64) []byte

func Int64ToByteArray

func Int64ToByteArray(num int64) []byte

func IntToByteArray

func IntToByteArray(num int32) []byte

Types

type ByteArrayCodable

type ByteArrayCodable interface {
	ByteArrayEncodable
	ByteArrayDecodable
}

type ByteArrayDecodable

type ByteArrayDecodable interface {
	DecodeFromByteArray([]byte)
}

type ByteArrayEncodable

type ByteArrayEncodable interface {
	EncodeToByteArray() []byte
}

type Color

type Color struct {
	R, G, B, A byte
}

Color represents a color in RGBA format.

func Black

func Black() Color

func Blue

func Blue() Color

func Green

func Green() Color

func NewColor

func NewColor(params ...interface{}) Color

NewColor creates new Color struct using the specified arguments. This function can accept the following arguments: - a color hex string, - 1 byte value for grayscale color, - 3 byte values for RGB color, - 4 byte values for RGBA color. If the given arguments cannot be interpreted as a color returns black color.

func ParseHexColor added in v0.1.7

func ParseHexColor(hex string) Color

ParseHexColor parses color hex string in format #rrggbbaa, #rrggbb, #rgba or #rgb to a Color struct.

func Pink

func Pink() Color

func Red

func Red() Color

func Transparent

func Transparent() Color

func White

func White() Color

func (*Color) EncodeToByteArray

func (c *Color) EncodeToByteArray() []byte

func (*Color) Equals added in v0.1.7

func (c *Color) Equals(other interface{}) bool

func (*Color) FromMap

func (c *Color) FromMap(siMap SiMap)

func (*Color) FromString added in v0.1.7

func (c *Color) FromString(src string)

func (*Color) GetHex added in v0.1.7

func (c *Color) GetHex() string

GetHex returns a color hex string in format #rrggbbaa or #rrggbb.

func (*Color) Normalize

func (c *Color) Normalize() Vector4

Normalize returns Vector4 with normalized color values.

func (*Color) ToFloat4

func (c *Color) ToFloat4() Vector4

ToFloat4 returns Vector4 with color values.

func (*Color) ToMap

func (c *Color) ToMap() SiMap

func (*Color) ToString added in v0.1.7

func (c *Color) ToString() string

type Int32Vector2

type Int32Vector2 struct {
	X, Y int32
}

type Int32Vector3

type Int32Vector3 struct {
	X, Y, Z int32
}

type IntVector2

type IntVector2 struct {
	X, Y int
}

func NewIntVector2

func NewIntVector2(x, y int) IntVector2

func (IntVector2) Add

func (v IntVector2) Add(other IntVector2) IntVector2

func (IntVector2) Distance

func (v IntVector2) Distance(other IntVector2) int

func (IntVector2) Sub

func (v IntVector2) Sub(other IntVector2) IntVector2

func (IntVector2) ToFloat

func (v IntVector2) ToFloat() Vector2

func (IntVector2) ToFloat3

func (v IntVector2) ToFloat3() Vector3

type IntVector3

type IntVector3 struct {
	X, Y, Z int
}

Represents a point in 3D space only in integer values

func NewIntVector3

func NewIntVector3(x, y, z int) IntVector3

func OneIntVector

func OneIntVector() IntVector3

func ZeroIntVector

func ZeroIntVector() IntVector3

func (IntVector3) Add

func (v IntVector3) Add(v2 IntVector3) IntVector3

Returns a new vector - the sum of two vectors

func (IntVector3) EncodeToByteArray

func (v IntVector3) EncodeToByteArray() []byte

func (IntVector3) Equals

func (v IntVector3) Equals(other interface{}) bool

Checks if the vector is the same as other vector

func (IntVector3) Multiply

func (v IntVector3) Multiply(v2 IntVector3) IntVector3

Returns new vector - multiplication of two vectors

func (IntVector3) Ndc

func (v IntVector3) Ndc(screen IntVector3) Vector3

Transforms vector ro normalized device coordinates vector

func (IntVector3) SetXYZ

func (v IntVector3) SetXYZ(x, y, z int)

func (IntVector3) Sub

func (v IntVector3) Sub(v2 IntVector3) IntVector3

Returns a new vector - v-v2

func (IntVector3) ToFloat

func (v IntVector3) ToFloat() Vector3

func (IntVector3) ToInt32

func (v IntVector3) ToInt32() Int32Vector3

func (IntVector3) ToMap

func (v IntVector3) ToMap() SiMap

func (IntVector3) ToString

func (v IntVector3) ToString() string

type Mappable

type Mappable interface {
	ToMap() SiMap
}

type Matrix4

type Matrix4 [16]float32

func (Matrix4) MulVector

func (m Matrix4) MulVector(v Vector4) Vector4

type NamedObject added in v0.2.4

type NamedObject interface {
	GetName() string
}

type ResId added in v0.1.7

type ResId int

type SiMap

type SiMap map[string]interface{}

SiMap provides an abstraction over Go's map[string]interface{}.

func RequireSiMap

func RequireSiMap(i interface{}) SiMap

func (SiMap) ContainsKey added in v0.2.0

func (m SiMap) ContainsKey(key string) bool

func (SiMap) GetBool added in v0.1.7

func (m SiMap) GetBool(key string) bool

func (SiMap) GetFloat32 added in v0.1.7

func (m SiMap) GetFloat32(key string) float32

func (SiMap) GetFloat64 added in v0.1.7

func (m SiMap) GetFloat64(key string) float64

func (SiMap) GetInt added in v0.1.7

func (m SiMap) GetInt(key string) int

func (SiMap) GetInt32 added in v0.1.7

func (m SiMap) GetInt32(key string) int32

func (SiMap) GetInt64 added in v0.1.7

func (m SiMap) GetInt64(key string) int64

func (SiMap) GetString added in v0.1.7

func (m SiMap) GetString(key string) string

type Stringable added in v0.1.7

type Stringable interface {
	ToString() string
}

Interface for values that can be serialized as string.

type TextAlign added in v0.1.7

type TextAlign byte
const (
	TextAlignLeft   TextAlign = 0
	TextAlignRight  TextAlign = 1
	TextAlignCenter TextAlign = 2
	TextAlignTop    TextAlign = 3
	TextAlignBottom TextAlign = 4
)

type Unmappable

type Unmappable interface {
	FromMap(siMap SiMap)
}

type Unstringable added in v0.1.7

type Unstringable interface {
	FromString(src string)
}

Interface for values that can be deserialized from string.

type Vector2

type Vector2 struct {
	X, Y float32
}

type Vector3

type Vector3 struct {
	X, Y, Z float32
}

Represents a point in 3D space

func NewVector3

func NewVector3(x, y, z float32) Vector3

func NewVector3FromMap

func NewVector3FromMap(siMap SiMap) Vector3

func OneVector

func OneVector() Vector3

func ZeroVector

func ZeroVector() Vector3

func (Vector3) Add

func (v Vector3) Add(v2 Vector3) Vector3

Returns a new vector - the sum of two vectors

func (Vector3) EncodeToByteArray

func (v Vector3) EncodeToByteArray() []byte

func (Vector3) Equals

func (v Vector3) Equals(other interface{}) bool

Checks if the vector is the same as other vector

func (*Vector3) FromMap

func (v *Vector3) FromMap(siMap SiMap)

func (Vector3) Multiply

func (v Vector3) Multiply(v2 Vector3) Vector3

Returns new vector - multiplication of two vectors

func (Vector3) Ndc

func (v Vector3) Ndc(screen Vector3) Vector3

Transforms vector ro normalized device coordinates vector

func (Vector3) Round

func (v Vector3) Round() IntVector3

Rounds the valued of the vector

func (Vector3) SetXYZ

func (v Vector3) SetXYZ(x, y, z float32)

func (Vector3) String added in v0.2.1

func (v Vector3) String() string

func (Vector3) Sub

func (v Vector3) Sub(v2 Vector3) Vector3

Returns a new vector - v-v2

func (Vector3) ToMap

func (v Vector3) ToMap() SiMap

type Vector4

type Vector4 struct {
	X, Y, Z, W float32
}

func NewVector4

func NewVector4(x, y, z, w float32) Vector4

Jump to

Keyboard shortcuts

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