Allow for custom "geometry" types

,

Unsure if this already exists, but I can't find it in the documentation, so I'm going to assume no...

I'm currently developing a game that is making heavy use of splines (bezier and cardinal). I'm using them for path traversal. Currently, what I have to do is create a fixed-number of points polygon from the spline ahead of time to pass to an animator:

spline = Bezier(...)
path = spline:polygon(20)
anim = gfx.animator.new(2000, path, easing.linear)

However, this is pretty sub-optimal. The animator object doesn't need discrete points internally. For example, creating an animator from a line, arc, etc. just supplies where along the arc (domain [0,1]) it is and compute where it is trivially.

It would be great if either I could have my spline class be a subclass of some parent geometry class, where I could override getPointOnPath(t) or similar, or allow the creation of an animator where the "geometry" object being supplied is a parametric function that is given t in the range [0,1] and it returns a point.

This would alleviate the need for me to create duplicate, discrete polygons from a continuous spline path.

And both options would allow for some pretty custom geometries to be created.

1 Like