I am doing a project in asp.net mvc3 web app using canvas and fabric.js.I have an issue while doing, I have a group shape in that more than 3 rectangles joined together to make it one shape. Now the issue is after drag and drop the group shape from div to canvas the background color of group shape should change to gray but the background color is changing for one object shape in group shape.Here is the code so far, I have done for changing the color
function drawActiveShape(x, y, type) {
if (activeObject != null) {
hideToolMenu();
activeObject.left = x;
activeObject.top = y;
js_c_drawing.add(activeObject);
if (type == 1) {
activeObject.set('fill', 'gray');
js_c_drawing.setActiveObject(activeObject);
} else {
activeObject.item(0).set('fill', 'gray');
js_c_drawing.setActiveGroup(activeObject);
}
js_c_drawing.calcOffset();
fabric.instances.push(js_c_drawing);
}
activeObject = null;
}
can anyone tell me how to change for group shape, thanks in advance
after removing item(0) from else condition the background color is changing but dragging and dropping is not working and one more thing in item(0) if we place 1 it is changing the shape color means it will change to next object. I kept the else condition like this
else {
activeObject.item(0).item(1).set('fill', 'gray');
js_c_drawing.setActiveGroup(activeObject);
}
drag and drop operation is working but background color is not changing for any object
Finally i solved by changing one word that is change group as object
if (type == 1) {
activeObject.set('fill', 'gray');
js_c_drawing.setActiveObject(activeObject);
} else {
activeObject.item(0).set('fill', 'gray');
js_c_drawing.setActiveObject(activeObject);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.