Documentation ¶
Index ¶
- Constants
- Variables
- func Lerp[T constraints.Integer | constraints.Float](start, end T, ratio float64) T
- type Color
- type ColorTransform
- func (t ColorTransform) ApplyAdditionToColor(color Color) Color
- func (t ColorTransform) ApplyMultiplyToColor(color Color) Color
- func (t ColorTransform) ApplyToColor(color Color) Color
- func (t ColorTransform) Combine(o ColorTransform) ColorTransform
- func (t ColorTransform) IsIdentity() bool
- func (t ColorTransform) String() string
- type MatrixTransform
- func IdentityTransform() MatrixTransform
- func LerpMatrix(start, end MatrixTransform, ratio float64) MatrixTransform
- func MatrixTransformFromSWF(m types.MATRIX, scale float64) MatrixTransform
- func NewMatrixTransform(scale, rotateSkew, translation Vector2[float64]) MatrixTransform
- func RotateTransform(angle float64) MatrixTransform
- func ScaleTransform(scale Vector2[float64]) MatrixTransform
- func SkewXTransform(angle float64) MatrixTransform
- func SkewYTransform(angle float64) MatrixTransform
- func TranslateTransform[T ~int64 | ~float64](translate Vector2[T]) MatrixTransform
- func (m MatrixTransform) ApplyToVector(v Vector2[float64], applyTranslation bool) Vector2[float64]
- func (m MatrixTransform) Combine(o MatrixTransform) MatrixTransform
- func (m MatrixTransform) Equals(o MatrixTransform, epsilon float64) bool
- func (m MatrixTransform) EqualsExact(o MatrixTransform) bool
- func (m MatrixTransform) EqualsWithoutTranslation(o MatrixTransform, epsilon float64) bool
- func (m MatrixTransform) GetA() float64
- func (m MatrixTransform) GetB() float64
- func (m MatrixTransform) GetC() float64
- func (m MatrixTransform) GetD() float64
- func (m MatrixTransform) GetMatrix() mat.Matrix
- func (m MatrixTransform) GetMatrixWithoutTranslation() mat.Matrix
- func (m MatrixTransform) GetTX() float64
- func (m MatrixTransform) GetTY() float64
- func (m MatrixTransform) GetTranslation() Vector2[float64]
- func (m MatrixTransform) Inverse() *MatrixTransform
- func (m MatrixTransform) IsIdentity() bool
- func (m MatrixTransform) MinimumStrokeWidth() float64
- func (m MatrixTransform) Multiply(o MatrixTransform) MatrixTransform
- func (m MatrixTransform) String() string
- type PackedColor
- type Vector2
- func LerpVector2[T ~int64 | ~float64](start, end Vector2[T], ratio float64) Vector2[T]
- func MatrixTransformApplyToVector[T ~int64 | ~float64](m MatrixTransform, v Vector2[T], applyTranslation bool) Vector2[T]
- func NewVector2[T ~int64 | ~float64](x, y T) Vector2[T]
- func Vector2ToType[T ~int64 | ~float64, T2 ~int64 | ~float64](v Vector2[T]) Vector2[T2]
- func (v Vector2[T]) Abs() Vector2[T]
- func (v Vector2[T]) AddVector(b Vector2[T]) Vector2[T]
- func (v Vector2[T]) Distance(b Vector2[T]) float64
- func (v Vector2[T]) Divide(size T) Vector2[T]
- func (v Vector2[T]) DivideVector(b Vector2[T]) Vector2[T]
- func (v Vector2[T]) Dot(b Vector2[T]) T
- func (v Vector2[T]) Equals(b Vector2[T]) bool
- func (v Vector2[T]) Float64() Vector2[float64]
- func (v Vector2[T]) Int64() Vector2[int64]
- func (v Vector2[T]) Invert() Vector2[T]
- func (v Vector2[T]) Length() float64
- func (v Vector2[T]) Max(b Vector2[T]) Vector2[T]
- func (v Vector2[T]) Min(b Vector2[T]) Vector2[T]
- func (v Vector2[T]) Multiply(size T) Vector2[T]
- func (v Vector2[T]) MultiplyVector(b Vector2[T]) Vector2[T]
- func (v Vector2[T]) Normalize() Vector2[float64]
- func (v Vector2[T]) Normals() (a, b Vector2[T])
- func (v Vector2[T]) SquaredDistance(b Vector2[T]) T
- func (v Vector2[T]) SquaredLength() T
- func (v Vector2[T]) String() string
- func (v Vector2[T]) SubVector(b Vector2[T]) Vector2[T]
Constants ¶
const ColorTransformMultiplyFactor = math.MaxUint8 + 1
const TransformCompareEpsilon = 1e-12
Variables ¶
var DefaultRotateSkew = Vector2[float64]{
X: 0,
Y: 0,
}
var DefaultScale = Vector2[float64]{
X: 1,
Y: 1,
}
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 (Color) Packed ¶
func (c Color) Packed() PackedColor
func (Color) ToLinearRGB ¶
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 (t ColorTransform) Combine(o ColorTransform) ColorTransform
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 (MatrixTransform) Combine ¶
func (m MatrixTransform) Combine(o MatrixTransform) MatrixTransform
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) 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) 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 (m MatrixTransform) Multiply(o MatrixTransform) MatrixTransform
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 ¶
func LerpVector2 ¶
func NewVector2 ¶
func Vector2ToType ¶
func (Vector2[T]) DivideVector ¶
func (Vector2[T]) MultiplyVector ¶
func (Vector2[T]) SquaredDistance ¶
func (Vector2[T]) SquaredLength ¶
func (v Vector2[T]) SquaredLength() T