Skip to content

Context SetTransform / GetTransform / ApplyTransform #175

Open

Description

@bit101

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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