faiface/pixel

SetMatrix(matrix) + Draw(target) vs Draw(target, matrix)

Opened this issue · 0 comments

Seb-C commented

First, I'd like to just say thank you for this package. I've been using Pixel for a few months now, and I'm very happy with it.
It has the perfect balance between simplicity and not trying too hard to isolate me away the underlying logic.

As my game is growing in size and complexity, I often find it challenging to deal with the fact that SetMatrix (in many components) actually makes the component stateful, which in some situations makes it harder to have clean separate of concerns.

At the same time, I've met other challenges due to the fact that not all components have the same definition: Sometimes it's Draw(target) and sometimes it's Draw(target, matrix). As go is very strictly typed, there is no convenient solution to make all components compatible with a single Drawer interface.

Is there a fundamental and purposeful design difference between those two patterns?

target.SetMatrix(matrix)
foo.Draw(target)
foo.Draw(target, matrix)

If no, do you think that making everything use the second pattern would be a welcome change to this package?