我想在基于优惠券的背景图动态生成带文字的优惠券,有什么轮子可以使用吗?或者有其他什么思路,比如不在后台在前台处理?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
<script>
var text="www.html5party.com"
function change(){
text=document.getElementById("text").value;
init();
}
function init(){
watermark('canvas','http://www.html5party.com/wp-content/uploads/2013/04/google-glasses-1.jpg',text);
}
function watermark(id,imgsrc,txt) {
canvas = document.getElementById(id);
if (canvas.getContext){
ctx = canvas.getContext('2d');
var img1 = new Image();
img1.src=imgsrc;
img1.onload = function(){
var imgWidth=img1.width;
var imgHeight=img1.height;
canvas.width= imgWidth;
canvas.height=imgHeight;
ctx.drawImage(img1,0,0);
ctx.fillStyle = 'rgba(0, 0, 0, 0.25)';
ctx.font = '30px sans-serif';
ctx.fillText(txt, canvas.width-(txt.length*15),canvas.height-30);
ctx.fillStyle = 'rgba(255, 255, 255, 0.25)';
ctx.fillText(txt, canvas.width-(txt.length*15)-2,canvas.height-32)
}
}
}
</script>