-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[SVG IMPORT] Shapes with transformMatrix have misplaced and/or stretched controls. #1520
Comments
Current toSvg has some problem. http://www.deltalink.it/andreab/fabric/tests.html you find an orange button that says "test" and allow you to export current canvas to SVG. |
Hey, Thank you for the comment first. I exported the following: <?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="900" height="500" xml:space="preserve"><desc>Created with Fabric.js 1.4.9</desc><defs></defs><g transform="translate(5 23.9)"><text font-family="Helvetica" font-size="36" font-weight="normal" style="stroke: #000000; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #000000; opacity: 1;" transform="translate(-4.5 35)"></text></g><circle cx="undefined" cy="undefined" r="30" style="stroke: #00FF00; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #00FF00; opacity: 1;" transform="translate(336.5 197.5) scale(2.64 2.64) "/>
<rect x="-15" y="-15" rx="0" ry="-15" width="30" height="30" style="stroke: #FF0000; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #FF0000; opacity: 1;" transform="translate(127.75 188.25) scale(3.73 3.73)"/>
</svg> |
ok ok, i deleted the r of ry by error, and it became y. Now is fixed. |
It seems that the transformations screw up the bounding box |
I'm checking every aspect of it for the export. Are you grouping the objects or loading them ungrouped? cause that matter a lot. I need time :) and a bit of luck. |
I don't group them because I need to be able to move every single object independently. |
By the way, how can I get the whole thing to build? |
It seems that a circle gets height and width from the width & height attribute. Which means if the canvas has a height of 300px and a width of 400px, the circle will have a height of 300px and a width of 400px. This is why the selection box of my circle is as big as the canvas itself |
Yes but everything is very delicate. |
I fixed the circle height and width problem, the commit you can see on my fork: https://github.com/saeschdivara/fabric.js |
Yes, I can see that but it doesn't seem to me logic that in the creation of an object by an svg element the height should be determined by the height of the canvas itself. |
I did a first fix. This means even after an import you can click on the object and select the correct one (This fix can be seen on my fork as the last commit as of today). |
For sure And maybe the setCoord or viewportTransform has to handle even the this.transformMatrix. That's why i always group the svgs. @kangax is transformMatrix property supported on single shapes ore is not intended to? |
Could you please tell me where would I have to call this. _transform(ctx,noTransform) in _renderControls? Thanks for the tip about _renderControls. Now I can see the selection area on the objects. |
circle initialize method: this.callSuper('initialize', options); switch position of the function as this. |
Could you please send me the changes you made to the export? |
@asturur didn't we fix this one? |
the problem is that importing single shapes from svg fails if shapes have a transform matrix on them. |
please share svg, complete load code, and please upgrade to fabric 1.4.13. |
hi, switch to version 1.4.13 and the problem continues, I give you the information you ask me, extract the string str = ""; $scope.myLoadSvg = function(str) { fabric.loadSVGFromString(str, function(objects) { }; http://demos.iroxit.com/cyes/media/cano.svg OR Load with but is grouped around and I need to manipulate separate objects so Therefore I need to ungroup and watch the drawing border well. fabric.loadSVGFromURL(pathImage, function(objects, options) {
thank you ! |
So listen, having
This will allow you to have control over them BUT will not give you perfect shape of the SVG. |
But everything is set to ( 0,0) :( :( :( Anything I can do? fabric.loadSVGFromString(str, function(objects) { |
you can do but this work just for translate. you can do something till is a matter of scale + rotate + translate. but a generic matrix is a stop for now. |
If you create the svg in the first place, maybe you could use json instead. |
works , thank you very much, very helpful, Greetings from Mexico !!! |
The fix is not finished otherways i would happily release it. |
Hi, were you able to work on this one? looking forward for fix on this one. thanks. |
Hey Thanks a lot for keeping me updated! :) I appreciate that work is in progress on it. |
Not yet, lot of cleaning is necessary. |
I marked it for 2.0 (@asturur feel free to do it yourself in the future) |
I' m facing kind of similar problem , but I'm not sure if the root cause is the same. At some point I am loading shapes to canvas from SVG. If the rotate transform is not set on my canvas viewport, the controls are looking fine. The scale and translate transforms seems to work as expect but when the rotate transformation is added the controls are broken, there seems that some kind of rotation is applied to them and the effect is very strange, they look totally broken. Am I seeing the same problem as described in this bug or is a new problem (since i don t set transformmatrix on the shape but instead the transform is applied on canvas viewport)? I am using fabric 1.5.0, so any help or possible workaround for my problem would be highly appreciated. |
if you are talking about viewportTransform, rotation is not supported. all viewport transform are just scaling and translate. if you wanna be sure you can open a different issue adding a fiddle with a code sample. |
Currently looking to complex svg with both path and other shapes and GRADIENTS. |
is it possible to place the selection area via object-options? |
I created a simple example of importing text and converting it to an IText. The selection box is incorrect when you attempt to edit. I am assuming this is the same issue? |
there are some precision problem removing the transform matrix, that is why
we did not develop it further for now
On Apr 5, 2017 09:59, "Dinesh kumar krishna" <[email protected]> wrote:
Hi,
In lates released 7.9 still loading sg without group scatter in canvas. Not
at actual position.
fabric.loadSVGFromURL("file.svg",function(objects,options){
canvas.add.apply(canvas, objects); });
Original svg
[image: screenshot from 2017-04-05 13-27-22]
<https://cloud.githubusercontent.com/assets/19422873/24695503/bc583672-1a03-11e7-9b1f-a18ac1d0a14a.png>
After upload
[image: fireshot capture 078 - my yii application_ -
http___localhost_diy_web_logo_edit]
<https://cloud.githubusercontent.com/assets/19422873/24695522/c955342e-1a03-11e7-91d8-5855ebb9f0aa.png>
I need to change color or edit elements of svg. So cann't group.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1520 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABI4QKF9BZzsQNXoA0Gn5B25z4I3epc3ks5rs0n3gaJpZM4CP8W4>
.
|
For who may be still interested, this thing is finally solved in #3969. |
Thanks! |
i m closing this issue. Setting the transformMatrix directly yo an object will still give out of box controls. transformaMatrix will stay as object property for who wants to draw custom things and is not in need of controls, for all other people a new method will be created ( to be named ) that will take as an input the transformMatrix, and mix it with current object properties. This is already possible using calcTransformMatrix, multiplyTransformMatrices and qrDecompose, but maybe there will be a oneline helper |
I tried to load an svg which was created by fabric.js (toSVG). Loading was possible but the selection area of the canvas objects are totally wrong (as can be seen in the screenshot)
The fabric.js version is 1.4.9
In the fiddle you cannot even select the objects: http://jsfiddle.net/saskyrar/L8cmw/2/
Here is the svg:
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: