(dev) Strange things on opened SVGs
linuslabo opened this issue · comments
I don't really know how to open a new svg file, so for the moment I thought to just replace the blank.svg before loading Dizzy.......
When opening (this way) an existing svg made with Dizzy classes for the presentation (group_1, group_2, ecc..) that's what happens:
- 1
- Presentation goes well if you don't modify the file.
- 2
- transforming (transl, scaling or rotating) an element in default mode will teleport it inverting the TM and even if you transform it back, the presentation for it will be done transforming the canvas with the CTM of that element (not inverting it anymore)
I hope it's due to my trick to open another svg. please confirm
SOLVED:
the prob were that in new Group created for existing group in the loaded svg, transformation contained already the inverted matrix of the group - node.parentNode.getTransformToElement(node) -, while in new ones transformation was the right one (not inverted, equal to the one in attribute 'transformation' of their dom)
Easily fixable inverting it, this way: in "js/dizzy/group.js"
{... var transformMatrix = node.parentNode.getTransformToElement(node); this.dom(node); this.transform = new Transformation(transformMatrix); this.transform.inverse(); <---------------- HERE ...}
And in "js/dizzy/canvas.js" (current()) we should invert the transformation matrix before transforming the canvas, this way:
{ ... var groupTransform = group.transformation(); var inverseTransform = Transformation.createTransform(groupTransform.matrix()); inverseTransform.inverse(); <-------------------- HERE ... }
that's all folks :)