Let's say I have a canvas containing 6 objects and a button outside the canvas.
When I click this button, 3 of these objects will become a group and will be selected, the objects will retain their positions relative to the canvas.
Is it possible?
I tried so many things, but I could manage it to work. The solution I'm looking for is similar to below.
var objectList=[1,2,3];
var newgroup = new fabric.Group();
$.each(objectList, function (i) {
var obj = canvas.item(i);
newgroup.add(obj.clone());
canvas.remove(obj);
});
canvas.add(newgroup)
canvas.setActiveGroup(newgroup);
canvas.renderAll();
source
share