I want to draw a skeleton on a canvas (a sequence of interconnected rectangles each at a certain angle to the parent), I do this recursively the skeleton starts from the body and it turns out that both hands are already on top of it, so I don’t want to draw it right away, but to save all the canvas transformations (displacements and turns) during the first pass, and then draw each part separately according to the z-order, setting the previously obtained transform to the canvas. Attempting to save (and accumulate the values ​​of turns and translations) does not lead to anything, I tried to use the matrix, but did not achieve that what I draw then was the same as originally. Here is a snippet showing the essence of the problem: https://stackoverflow.com/questions/53984114/javascript-saving-all-transformations-of-canvas-taking-into-account-the-save

  • and if to come on the other hand - to begin drawing on a z-index and at this moment to calculate transformations? - Dmytryk
  • I'm not sure that this is the best option to get more passes through the tree of objects, there is a decision to build a scene graph, but I have not yet implemented it. - Daniil Loban

0