P5.js: Add function to return the current transformation matrix

Created on 25 Dec 2017  路  3Comments  路  Source: processing/p5.js

Nature of issue?

  • [ ] Found a bug
  • [ ] Existing feature enhancement
  • [x] New feature request

Most appropriate sub-area of p5.js?

  • [ ] Color
  • [x] Core
  • [ ] Data
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [x] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Other (specify if possible)

New feature details:

Currently there's no way to save a transformation matrix and then restore it at a later time. Perhaps getCurrentMatrix() could return the current transformation matrix stack collapsed down to something we can pass to applyMatrix(...) later to restore that state. Perhaps it would be better to have this work for the entire drawing context, although that is something the user can track themselves. This is useful if we want to non-locally restore the current drawing state, e.g if we have a deep tree-like structure that is expensive to draw all at once it would be cool to do something like setTimeout(() => nextLevel(), 15) but currently it's not possible since we can't easily get the transformation state (and so it's different by the time the setTimeout fires).

All 3 comments

hi @aman-tiwari check out this comment here, i believe the status of matrix support in the browser is still about the same: https://github.com/processing/p5.js/issues/1873#issuecomment-290992218

Oh okay I see, thank you I'll try and use the workaround

Would getTransform be considered?

Was this page helpful?
0 / 5 - 0 ratings