使用代码在网页上写一个“百”字
1、思路。要想在网页上面用代码写字,我们只有使用HTML5中的画布代码中的点线工具代码来实现,只要给出一个点的坐标,这个点就可以用线条一直描绘下去。

3、使用 stroke() 代码把这里所有的点用线条进行描绘。<script>var c屏顿幂垂=document.getE造婷用痃lementById("百");var ctx=c.getContext("2d");ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(100,0);ctx.lineTo(50,0);ctx.lineTo(0,50);ctx.lineTo(0,100);ctx.lineTo(100,100);ctx.lineTo(100,50);ctx.lineTo(0,50);ctx.lineTo(0,75);ctx.lineTo(100,75);ctx.strokeStyle="#FF0000";ctx.stroke();</script>

5、用同样的方法写一个LOVE。<!DOCTYPE html><html><body><稆糨孝汶;canvas id="LOVE" width="1000" height="1000" style="border:1px solid white;" ></canvas><script>var c=document.getElementById("LOVE");var ctx=c.getContext("2d");ctx.beginPath();ctx.moveTo(0,0);ctx.lineTo(0,200);ctx.lineTo(100,200);ctx.lineTo(100,0);ctx.lineTo(200,0);ctx.lineTo(200,200);ctx.lineTo(100,200);ctx.lineTo(100,0);ctx.lineTo(200,0);ctx.lineTo(250,200);ctx.lineTo(300,0);ctx.lineTo(300,200);ctx.lineTo(400,200);ctx.lineTo(300,200);ctx.lineTo(300,100);ctx.lineTo(400,100);ctx.lineTo(300,100);ctx.lineTo(300,0);ctx.lineTo(400,0);ctx.strokeStyle="#551A8B";ctx.stroke();</script></body></html>
