admin管理员组文章数量:1405636
I am currently working on a "Photo Collage Maker" project which needs larger canvas area and hundreds of objects(text, images, shapes, clip-arts etc.). The problem is while moving, scaling and rotating those objects, Fabric.js render all the objects which makes it too slow. I want to render only the selected objects on top of the fabric canvas. I have tested renderOnAddition, renderTop also but they are not what I want.
I want the following:
canvas.on('object:moving', function(e) {
var activeObject = e.target;
//canvas.renderAll();
canvas.renderObjects(activeObject);
});
Now instead of canvas.renderAll()
, I need method like canvas.renderObjects(activeObject)
. How can I achieve this functionality in Fabric.js?
Here is my project : Edit Photos For Free
I am currently working on a "Photo Collage Maker" project which needs larger canvas area and hundreds of objects(text, images, shapes, clip-arts etc.). The problem is while moving, scaling and rotating those objects, Fabric.js render all the objects which makes it too slow. I want to render only the selected objects on top of the fabric canvas. I have tested renderOnAddition, renderTop also but they are not what I want.
I want the following:
canvas.on('object:moving', function(e) {
var activeObject = e.target;
//canvas.renderAll();
canvas.renderObjects(activeObject);
});
Now instead of canvas.renderAll()
, I need method like canvas.renderObjects(activeObject)
. How can I achieve this functionality in Fabric.js?
Here is my project : Edit Photos For Free
Share Improve this question edited Apr 4, 2016 at 4:16 user1693593 asked May 6, 2013 at 6:43 ep4fep4f 4201 gold badge5 silver badges14 bronze badges 4- 2 You must render all, there is no other way. It doesn't metter state of which object had changed, the drawing proccess is drawing pixels. Like frames in a digital video, even if it is a static picture, there are still 25 frames ... – arty Commented May 6, 2013 at 15:04
- If it's not possible, for the sake of fabricjs performance, how can i implement cacheAsBitmap property so that only the moving part is rendered and all other static parts are cached as bitmap. Any ideas and algorithm to implement this on fabricjs ? – ep4f Commented May 8, 2013 at 9:31
- sorry, can't help here. good luck – arty Commented May 8, 2013 at 12:12
- 1 This ment is possibly related to what you want to do: github./kangax/fabric.js/issues/318 – Alexander Kludt Commented Jun 18, 2013 at 14:06
2 Answers
Reset to default 1Your best bet is to have a second canvas, in front of the main one, on which you move/scale/rotate the current item(s).
You mention wanting to render the selected objects on top of the fabric canvas, so this should meet your requirements.
On ending the move/scale/rotate you will have to restore the original canvas elements, apply your changes, and allow it to do a full redraw.
May be there are many renderAll() methods
Chech if that is case you need to use requestRenderAll() method
本文标签: javascriptRender selected object only while movingscaling and rotatingStack Overflow
版权声明:本文标题:javascript - Render selected object only while moving, scaling and rotating - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744287527a2598953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论