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

[geometry-1] DOMMatrixInit is not too useful if a DOMMatrix constructor cannot accept such a value #581

Open
trusktr opened this issue Dec 27, 2024 · 0 comments

Comments

@trusktr
Copy link

trusktr commented Dec 27, 2024

You'd think this should be possible:

const init = {m11: 1, ..., m44: 1}

const matrix = new DOMMatrix(init)

Instead, one has to do this:

const init = {m11: 1, ..., m44: 1}

const matrix = new DOMMatrix([init.m11, ..., init.m44])

which is more cumbersome and also more wasteful (an extra array is created just to create a new DOMMatrix), or this:

const init = {m11: 1, ..., m44: 1}

const matrix = Object.assign(new DOMMatrix(), init)

which is also not as simple as it could be.

These problems could be alleviated if toFloat32Array or toFloat64Array methods would accept a target array to write to, making it easy to clone matrices without allocating new arrays:

const array = new Float32Array(16)

matrix.toFloat32Array(array) // provide an array to write to (instead of it creating a new one)

const newMatrix = new DOMMatrix(array)

(to this end, it should also just have toArray to return (or write to) a regular array)

@trusktr trusktr changed the title [geometry-1] What's the point of DOMMatrixInit if the constructor cannot accept such a value? [geometry-1] DOMMatrixInit is not too useful if a DOMMatrix constructor cannot accept such a value Dec 27, 2024
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