简体   繁体   English

如何将输入文本插入图像?

[英]How to insert input text into image?

I want to develop extension for magento which help to create custom t-shirt but i don't know how to do it.I want to provide functionality like this site http://www.inkpixi.com/item/ATV+Repair/A252/329/item.html Dead link 我想为magento开发扩展,这有助于创建自定义T恤,但我不知道该怎么做。我想提供像这个网站的功能http://www.inkpixi.com/item/ATV+Repair/ A252 / 329 / item.html 死链接

here you enter the name and then name automatically insert to image .i want to provide this exactly but didn't get right matter 在这里输入名称,然后名称自动插入图像。我想提供这个,但没有得到正确的事情

You can do it so simply with 你可以用简单地做到这一点

 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://i.imgur.com/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: <input id="text" type="text"><br> 

Right click and Save as :) ! 右键单击另存为 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM