Skip to content

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

@Seb-C

Description

@Seb-C

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions