gopxl / pixel

A hand-crafted 2D game library in Go.
MIT License
244 stars 10 forks source link

Define bounds on both circle and rect for use with interfaces #30

Open duysqubix opened 1 year ago

duysqubix commented 1 year ago

In my project I have a basic Shape interface defined as

type Shape interface {
    Area() float64
    Bounds() pixel.Rect
    Contains(point pixel.Vec) bool
}

It would be super useful if the pixel shapes matched this interface. Rect of course would just return itself.

Working on a physics engine built on top of pixel (🤫), and I'm trying to keep to native pixel structs as much as possible. This would give me a lot of flexibility in working with them.

Not sure if it makes sense to add the interface itself to pixel or not, but I would certainly use it.

Original issue: https://github.com/faiface/pixel/pull/316