1i have to change active object image color currently my t-shirt color is changing but when i add design on it i am unable to change color of.
My Code To change Tshirt Color :
//setup front side canvas
canvas = new fabric.Canvas('tcanvas', {
hoverCursor: 'pointer',
selection: true,
selectionBorderColor: 'blue'
});
canvas.on({
'object:moving': function(e) {
e.target.opacity = 0.5;
},
'object:modified': function(e) {
e.target.opacity = 1;
},
'object:selected': onObjectSelected,
'selection:cleared': onSelectedCleared
});
$('.color-preview').click(function(){
var color = $(this).css("background-color");
document.getElementById("shirtDiv").style.backgroundColor = color;
$('.shirtDivs').css('background-color',color);
});
HERE I Try To change Design color
$('#image-color').miniColors({
change: function(hex, rgb) {
var activeObject = canvas.getActiveObject();
if (activeObject && activeObject.type === 'image') {
activeObject.fill = this.value;
canvas.renderAll();
}
},
open: function(hex, rgb) {
},
close: function(hex, rgb) {
}
});
Demo
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…