1个回答
展开全部
<body>
<div>
<canvas id="canvas" style="width: 100; height: 100;"></canvas>
<button onclick="transform();">draw</button>
</div>
<script type="text/javascript">
var canvas=document.getElementById("canvas");
function transform(){
var context = canvas.getContext("2d");
context.beginPath();
context.moveTo(100, 150);
context.lineTo(450, 50);
context.lineWidth = 10;
context.strokeStyle ="#ff0000";
context.stroke();
alert(context.toDataURL());
}
</script>
</body>
<div>
<canvas id="canvas" style="width: 100; height: 100;"></canvas>
<button onclick="transform();">draw</button>
</div>
<script type="text/javascript">
var canvas=document.getElementById("canvas");
function transform(){
var context = canvas.getContext("2d");
context.beginPath();
context.moveTo(100, 150);
context.lineTo(450, 50);
context.lineWidth = 10;
context.strokeStyle ="#ff0000";
context.stroke();
alert(context.toDataURL());
}
</script>
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |