Je souhaite développer une extension pour magento qui aide à créer un t-shirt personnalisé, mais je ne sais pas comment le faire. Je souhaite proposer des fonctionnalités telles que celle-ci: http://www.inkpixi.com/item/ATV+Repair/ A252 / 329 / item.html Lien mort
Ici, vous entrez le nom, puis le nom est automatiquement inséré dans l’image .Je souhaite le fournir exactement, mais cela ne va pas.
Vous pouvez le faire si simplement avec de la canvas
var canvas = document.createElement('canvas'), ctx = canvas.getContext('2d'); canvas.width = 200; canvas.height = 200; document.body.appendChild(canvas); function sendToCanvas( ob ){ var img = new Image(); img.addEventListener('load', function(){ ctx.drawImage(img, 0, 0, canvas.width, canvas.height); ctx.font = ob.fontWeight+' '+ob.fontSize+' '+ob.fontFamily; ctx.textAlign = 'center'; ctx.fillStyle = ob.color; ctx.fillText(ob.text, canvas.width/2, canvas.height/2.5); }); img.src = ob.image; } // Defaults var cvsObj = { text : "stackoverflow", image : "http://soffr.miximages.com/javascript/hqayV16.jpg", fontFamily : "Arial", fontWeight : "bold", fontSize : "90%", color : "rgba(244, 128, 36, 0.7)" }; sendToCanvas( cvsObj ); // Send default data on init document.getElementById("text").addEventListener("input", function(){ cvsObj.text = this.value; // Modify cvsObj text sendToCanvas( cvsObj ); // Send custom data on input });
Text: