Documentation ¶
Overview ¶
Package a provides most commonly used types in Amphion.
Index ¶
- Constants
- func ByteArrayToInt(arr []byte) int
- func ByteArrayToInt64(arr []byte) int64
- func CopyByteArray(src []byte, target []byte, start, length int) error
- func Float32ToByteArray(num float32) []byte
- func Float64ToByteArray(num float64) []byte
- func Int64ToByteArray(num int64) []byte
- func IntToByteArray(num int32) []byte
- type ByteArrayCodable
- type ByteArrayDecodable
- type ByteArrayEncodable
- type Color
- func (c *Color) EncodeToByteArray() []byte
- func (c *Color) Equals(other interface{}) bool
- func (c *Color) FromMap(siMap SiMap)
- func (c *Color) FromString(src string)
- func (c *Color) GetHex() string
- func (c *Color) Normalize() Vector4
- func (c *Color) ToFloat4() Vector4
- func (c *Color) ToMap() SiMap
- func (c *Color) ToString() string
- type Int32Vector2
- type Int32Vector3
- type IntVector2
- type IntVector3
- func (v IntVector3) Add(v2 IntVector3) IntVector3
- func (v IntVector3) EncodeToByteArray() []byte
- func (v IntVector3) Equals(other interface{}) bool
- func (v IntVector3) Multiply(v2 IntVector3) IntVector3
- func (v IntVector3) Ndc(screen IntVector3) Vector3
- func (v IntVector3) SetXYZ(x, y, z int)
- func (v IntVector3) Sub(v2 IntVector3) IntVector3
- func (v IntVector3) ToFloat() Vector3
- func (v IntVector3) ToInt32() Int32Vector3
- func (v IntVector3) ToMap() SiMap
- func (v IntVector3) ToString() string
- type Mappable
- type Matrix4
- type NamedObject
- type ResId
- type SiMap
- func (m SiMap) ContainsKey(key string) bool
- func (m SiMap) GetBool(key string) bool
- func (m SiMap) GetFloat32(key string) float32
- func (m SiMap) GetFloat64(key string) float64
- func (m SiMap) GetInt(key string) int
- func (m SiMap) GetInt32(key string) int32
- func (m SiMap) GetInt64(key string) int64
- func (m SiMap) GetString(key string) string
- type Stringable
- type TextAlign
- type Unmappable
- type Unstringable
- type Vector2
- type Vector3
- func (v Vector3) Add(v2 Vector3) Vector3
- func (v Vector3) EncodeToByteArray() []byte
- func (v Vector3) Equals(other interface{}) bool
- func (v *Vector3) FromMap(siMap SiMap)
- func (v Vector3) Multiply(v2 Vector3) Vector3
- func (v Vector3) Ndc(screen Vector3) Vector3
- func (v Vector3) Round() IntVector3
- func (v Vector3) SetXYZ(x, y, z float32)
- func (v Vector3) String() string
- func (v Vector3) Sub(v2 Vector3) Vector3
- func (v Vector3) ToMap() SiMap
- type Vector4
Constants ¶
const ( MatchParent float32 = -9_999_999 + iota*10 WrapContent CenterInParent FillParent )
Variables ¶
This section is empty.
Functions ¶
func ByteArrayToInt ¶
func ByteArrayToInt64 ¶
func Float32ToByteArray ¶
func Float64ToByteArray ¶
func Int64ToByteArray ¶
func IntToByteArray ¶
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 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
ParseHexColor parses color hex string in format #rrggbbaa, #rrggbb, #rgba or #rgb to a Color struct.
func Transparent ¶
func Transparent() Color
func (*Color) EncodeToByteArray ¶
func (*Color) FromString ¶ added in v0.1.7
func (*Color) GetHex ¶ added in v0.1.7
GetHex returns a color hex string in format #rrggbbaa or #rrggbb.
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 NamedObject ¶ added in v0.2.4
type NamedObject interface {
GetName() string
}
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 (SiMap) GetFloat32 ¶ added in v0.1.7
func (SiMap) GetFloat64 ¶ added in v0.1.7
type Stringable ¶ added in v0.1.7
type Stringable interface {
ToString() string
}
Interface for values that can be serialized as string.
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 Vector3 ¶
type Vector3 struct {
X, Y, Z float32
}
Represents a point in 3D space
func NewVector3 ¶
func NewVector3FromMap ¶
func ZeroVector ¶
func ZeroVector() Vector3