HTML5 画图--文字

1:html

<div style="margin:0 auto;794px;height:1123px">
<canvas id="myCanvas" width="794" height="1123" style="border:1px solid #c3c3c3;background:url(img/ruhuotongzhi1.jpg)">
Your browser does not support the canvas element.
</canvas>
    </div>

  2:js

 var c = document.getElementById("myCanvas");
            var context = c.getContext("2d");
            var json = { "name": [{ "a": "李四" }] }
            //alert(json.name[0].a);
            context.fillStyle ='black';//字体颜色
            context.font = '20px sans-serif';//字体样式 
            context.fillText(json.name[0].a, 105, 206);//位置
            context.fillText(json.name[0].a, 509, 208);
            context.fillText(json.name[0].a, 80, 246);
            context.fillText(json.name[0].a, 550, 246);

  

原文地址:https://www.cnblogs.com/lgjc/p/5812311.html