func (sprite *Sprite) BoundingBoxEx(x, y, rot, hscale, vscale float64) *rect.Rect { var tx1, ty1, tx2, ty2 float64 var sint, cost float64 rect := new(rect.Rect) tx1 = -sprite.HotX * hscale ty1 = -sprite.HotY * vscale tx2 = (sprite.W - sprite.HotX) * hscale ty2 = (sprite.H - sprite.HotY) * vscale if rot != 0.0 { cost = math.Cos(rot) sint = math.Sin(rot) rect.Encapsulate(tx1*cost-ty1*sint+x, tx1*sint+ty1*cost+y) rect.Encapsulate(tx2*cost-ty1*sint+x, tx2*sint+ty1*cost+y) rect.Encapsulate(tx2*cost-ty2*sint+x, tx2*sint+ty2*cost+y) rect.Encapsulate(tx1*cost-ty2*sint+x, tx1*sint+ty2*cost+y) } else { rect.Encapsulate(tx1+x, ty1+y) rect.Encapsulate(tx2+x, ty1+y) rect.Encapsulate(tx2+x, ty2+y) rect.Encapsulate(tx1+x, ty2+y) } return rect }
func (ps ParticleSystem) BoundingBox(rect *rect.Rect) *rect.Rect { rect.SetRect(ps.boundingBox) return rect }