math

package
v0.0.0-...-cb98339 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ColorTransformMultiplyFactor = math.MaxUint8 + 1
View Source
const TransformCompareEpsilon = 1e-12

Variables

View Source
var DefaultRotateSkew = Vector2[float64]{
	X: 0,
	Y: 0,
}
View Source
var DefaultScale = Vector2[float64]{
	X: 1,
	Y: 1,
}
View Source
var DefaultTranslation = Vector2[float64]{
	X: 0,
	Y: 0,
}

Functions

func Lerp

func Lerp[T constraints.Integer | constraints.Float](start, end T, ratio float64) T

Types

type Color

type Color struct {
	R, G, B, Alpha uint8
}

func LerpColor

func LerpColor(start, end Color, ratio float64) Color

func (Color) Distance

func (c Color) Distance(o Color, alpha bool) float64

func (Color) Equals

func (c Color) Equals(o Color, alpha bool) bool

func (Color) Packed

func (c Color) Packed() PackedColor

func (Color) String

func (c Color) String() string

func (Color) ToLinearRGB

func (c Color) ToLinearRGB() Color

func (Color) ToSRGB

func (c Color) ToSRGB() Color

type ColorTransform

type ColorTransform struct {
	Multiply struct {
		Red   types.Fixed8
		Green types.Fixed8
		Blue  types.Fixed8
		Alpha types.Fixed8
	}
	Add struct {
		Red   int16
		Green int16
		Blue  int16
		Alpha int16
	}
}

func ColorTransformFromSWF

func ColorTransformFromSWF(cx types.CXFORM) (t ColorTransform)

func ColorTransformFromSWFAlpha

func ColorTransformFromSWFAlpha(cx types.CXFORMWITHALPHA) (t ColorTransform)

func IdentityColorTransform

func IdentityColorTransform() ColorTransform

func (ColorTransform) ApplyAdditionToColor

func (t ColorTransform) ApplyAdditionToColor(color Color) Color

func (ColorTransform) ApplyMultiplyToColor

func (t ColorTransform) ApplyMultiplyToColor(color Color) Color

func (ColorTransform) ApplyToColor

func (t ColorTransform) ApplyToColor(color Color) Color

func (ColorTransform) Combine

func (ColorTransform) IsIdentity

func (t ColorTransform) IsIdentity() bool

func (ColorTransform) String

func (t ColorTransform) String() string

type MatrixTransform

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

MatrixTransform The transformation matrix used by Flash display objects. The matrix is a 2x3 affine transformation matrix. A Vector2(x, y) is transformed by the matrix in the following way:

[a c tx] * [x] = [a*x + c*y + tx]
[b d ty]   [y]   [b*x + d*y + ty]
[0 0 1 ]   [1]   [1             ]

Objects in Flash can only move in units of types.Twip, or 1/20 pixels.

[SWF19 pp.22-24](https://web.archive.org/web/20220205011833if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=22)

func IdentityTransform

func IdentityTransform() MatrixTransform

func LerpMatrix

func LerpMatrix(start, end MatrixTransform, ratio float64) MatrixTransform

func MatrixTransformFromSWF

func MatrixTransformFromSWF(m types.MATRIX, scale float64) MatrixTransform

func NewMatrixTransform

func NewMatrixTransform(scale, rotateSkew, translation Vector2[float64]) MatrixTransform

func RotateTransform

func RotateTransform(angle float64) MatrixTransform

func ScaleTransform

func ScaleTransform(scale Vector2[float64]) MatrixTransform

func SkewXTransform

func SkewXTransform(angle float64) MatrixTransform

func SkewYTransform

func SkewYTransform(angle float64) MatrixTransform

func TranslateTransform

func TranslateTransform[T ~int64 | ~float64](translate Vector2[T]) MatrixTransform

func (MatrixTransform) ApplyToVector

func (m MatrixTransform) ApplyToVector(v Vector2[float64], applyTranslation bool) Vector2[float64]

func (MatrixTransform) Combine

func (MatrixTransform) Equals

func (m MatrixTransform) Equals(o MatrixTransform, epsilon float64) bool

func (MatrixTransform) EqualsExact

func (m MatrixTransform) EqualsExact(o MatrixTransform) bool

func (MatrixTransform) EqualsWithoutTranslation

func (m MatrixTransform) EqualsWithoutTranslation(o MatrixTransform, epsilon float64) bool

func (MatrixTransform) GetA

func (m MatrixTransform) GetA() float64

GetA Gets the ScaleX factor

func (MatrixTransform) GetB

func (m MatrixTransform) GetB() float64

GetB Gets the RotateSkewX factor

func (MatrixTransform) GetC

func (m MatrixTransform) GetC() float64

GetC Gets the RotateSkewY factor

func (MatrixTransform) GetD

func (m MatrixTransform) GetD() float64

GetD Gets the ScaleY factor

func (MatrixTransform) GetMatrix

func (m MatrixTransform) GetMatrix() mat.Matrix

func (MatrixTransform) GetMatrixWithoutTranslation

func (m MatrixTransform) GetMatrixWithoutTranslation() mat.Matrix

func (MatrixTransform) GetTX

func (m MatrixTransform) GetTX() float64

func (MatrixTransform) GetTY

func (m MatrixTransform) GetTY() float64

func (MatrixTransform) GetTranslation

func (m MatrixTransform) GetTranslation() Vector2[float64]

func (MatrixTransform) Inverse

func (m MatrixTransform) Inverse() *MatrixTransform

func (MatrixTransform) IsIdentity

func (m MatrixTransform) IsIdentity() bool

func (MatrixTransform) MinimumStrokeWidth

func (m MatrixTransform) MinimumStrokeWidth() float64

MinimumStrokeWidth Given a matrix, calculates the scale for stroke widths. TODO: Verify the actual behavior; I think it's more like the average between scaleX and scaleY. Does not yet support vertical/horizontal stroke scaling flags.

func (MatrixTransform) Multiply

func (MatrixTransform) String

func (m MatrixTransform) String() string

type PackedColor

type PackedColor uint32

func NewPackedColor

func NewPackedColor(r, g, b, a uint8) PackedColor

func (PackedColor) Alpha

func (c PackedColor) Alpha() uint8

func (PackedColor) B

func (c PackedColor) B() uint8

func (PackedColor) Color

func (c PackedColor) Color() Color

func (PackedColor) G

func (c PackedColor) G() uint8

func (PackedColor) R

func (c PackedColor) R() uint8

type Vector2

type Vector2[T ~int64 | ~float64] struct {
	X T
	Y T
}

func LerpVector2

func LerpVector2[T ~int64 | ~float64](start, end Vector2[T], ratio float64) Vector2[T]

func MatrixTransformApplyToVector

func MatrixTransformApplyToVector[T ~int64 | ~float64](m MatrixTransform, v Vector2[T], applyTranslation bool) Vector2[T]

func NewVector2

func NewVector2[T ~int64 | ~float64](x, y T) Vector2[T]

func Vector2ToType

func Vector2ToType[T ~int64 | ~float64, T2 ~int64 | ~float64](v Vector2[T]) Vector2[T2]

func (Vector2[T]) Abs

func (v Vector2[T]) Abs() Vector2[T]

func (Vector2[T]) AddVector

func (v Vector2[T]) AddVector(b Vector2[T]) Vector2[T]

func (Vector2[T]) Distance

func (v Vector2[T]) Distance(b Vector2[T]) float64

func (Vector2[T]) Divide

func (v Vector2[T]) Divide(size T) Vector2[T]

func (Vector2[T]) DivideVector

func (v Vector2[T]) DivideVector(b Vector2[T]) Vector2[T]

func (Vector2[T]) Dot

func (v Vector2[T]) Dot(b Vector2[T]) T

func (Vector2[T]) Equals

func (v Vector2[T]) Equals(b Vector2[T]) bool

func (Vector2[T]) Float64

func (v Vector2[T]) Float64() Vector2[float64]

func (Vector2[T]) Int64

func (v Vector2[T]) Int64() Vector2[int64]

func (Vector2[T]) Invert

func (v Vector2[T]) Invert() Vector2[T]

func (Vector2[T]) Length

func (v Vector2[T]) Length() float64

func (Vector2[T]) Max

func (v Vector2[T]) Max(b Vector2[T]) Vector2[T]

func (Vector2[T]) Min

func (v Vector2[T]) Min(b Vector2[T]) Vector2[T]

func (Vector2[T]) Multiply

func (v Vector2[T]) Multiply(size T) Vector2[T]

func (Vector2[T]) MultiplyVector

func (v Vector2[T]) MultiplyVector(b Vector2[T]) Vector2[T]

func (Vector2[T]) Normalize

func (v Vector2[T]) Normalize() Vector2[float64]

func (Vector2[T]) Normals

func (v Vector2[T]) Normals() (a, b Vector2[T])

func (Vector2[T]) SquaredDistance

func (v Vector2[T]) SquaredDistance(b Vector2[T]) T

func (Vector2[T]) SquaredLength

func (v Vector2[T]) SquaredLength() T

func (Vector2[T]) String

func (v Vector2[T]) String() string

func (Vector2[T]) SubVector

func (v Vector2[T]) SubVector(b Vector2[T]) Vector2[T]

Jump to

Keyboard shortcuts

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