Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context SetTransform / GetTransform / ApplyTransform #175

Open
bit101 opened this issue Jul 13, 2022 · 0 comments
Open

Context SetTransform / GetTransform / ApplyTransform #175

bit101 opened this issue Jul 13, 2022 · 0 comments

Comments

@bit101
Copy link

bit101 commented Jul 13, 2022

The Context struct has a matrix property and various methods to manipulate that matrix. But although you can create a new Matrix, there is no way to apply a matrix to the context in one shot. Other packages I've used in the past have had one method such as SetTransform which replaces the current transform matrix with a new matrix, and ApplyTransform which applies a full matrix as an additional transform to the current matrix. As well as a method to get the current transform.

I believe this would be as simple as:

func (dc *Context) SetTransform(matrix gg.Matrix) {
	dc.matrix = matrix
}

func (dc *Context) ApplyTransform(matrix gg.Matrix) {
	dc.matrix = dc.matrix.Multiply(matrix)
}

func (dc *Context) GetTransform() gg.Matrix {
        return dc.matrix
}

Though I might have gotten the order reversed in the second one.

The Get and Set methods would be the most useful and if you had those, you could roll your own Apply method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant