swf2ass-go/types/shapes/Bitmap.go

40 lines
983 B
Go
Raw Normal View History

package shapes
import (
"git.gammaspectra.live/WeebDataHoarder/swf-go/types"
math2 "git.gammaspectra.live/WeebDataHoarder/swf2ass-go/types/math"
)
type Bitmap struct {
List DrawPathList
Transform math2.MatrixTransform
}
func (b Bitmap) ApplyColorTransform(transform math2.ColorTransform) Fillable {
b2 := b
2023-11-29 01:57:32 +00:00
b2.List = b2.List.ApplyColorTransform(transform).(DrawPathList)
return b2
}
2023-11-29 00:04:52 +00:00
func (b Bitmap) ApplyMatrixTransform(transform math2.MatrixTransform, applyTranslation bool) Fillable {
b2 := b
if !applyTranslation {
panic("not supported")
}
b2.Transform = transform.Combine(b2.Transform)
return b2
}
2023-11-26 19:34:44 +00:00
func (b Bitmap) Fill(shape Shape) DrawPathList {
return b.List.ApplyMatrixTransform(b.Transform, true).Fill(shape)
}
func BitmapFillFromSWF(l DrawPathList, transform types.MATRIX) Bitmap {
return Bitmap{
2023-11-29 00:04:52 +00:00
List: l,
// shape is already in pixel world, but matrix comes as twip
2023-11-29 01:57:32 +00:00
Transform: math2.MatrixTransformFromSWF(transform, 1./types.TwipFactor),
}
}