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

Loading from JSON with SVG #2571

Closed
KoIIIeY opened this issue Oct 22, 2015 · 2 comments
Closed

Loading from JSON with SVG #2571

KoIIIeY opened this issue Oct 22, 2015 · 2 comments

Comments

@KoIIIeY
Copy link

KoIIIeY commented Oct 22, 2015

Example 1:

            fabric.Image.fromURL('/userboards/board-img/stickers/'+id+'.svg', function (oImg) {
                canvas.centerObject(oImg);
                canvas.add(oImg);

                canvas.setActiveObject(oImg);
            });

Example 2:

         fabric.loadSVGFromURL('/userboards/board-img/stickers/'+id+'.svg', function(objects,options){
                var sticker = new fabric.util.groupSVGElements(objects,options);
                sticker.set({ scaleX: $scope.zoom / 100, scaleY: $scope.zoom / 100 })
                    .setCoords();

                canvas.centerObject(sticker);
                canvas.add(sticker);

            }, function(item, object){

            });

After saving to JSON and reloading, in first example all ok, in second example, SVG drawed incorrectly.
SVG for test - http://board.sa-wd.ru/userboards/board-img/stickers/1.svg

@KoIIIeY
Copy link
Author

KoIIIeY commented Oct 22, 2015

Inkscape can't load linked SVGs, so I need second variant to work.

example here: http://board.sa-wd.ru/?code=aY080LTUim20151022090245 (click start)

@asturur
Copy link
Member

asturur commented Oct 22, 2015

you should specify what is drawed incorrectly.
Example 1 and Example 2 differences have nothing to do with linked SVG, in first example you are loading svg as an image.

Please use the latest source code from github, build the library and the problem should be gone.
i think is related to #2456.

Please search in old issues before opening new.

@asturur asturur closed this as completed Oct 22, 2015
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

2 participants