<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>

 <body>
<canvas ></canvas>
 <script>
var c=document.getElementById("canvas");
var cxt=c.getContext("2d");
cxt.beginPath();
cxt.moveTo(250,50);
cxt.lineTo(200,200);
cxt.lineTo(300,300);
cxt.closePath();//填充或闭合 需要先闭合路径才能画
//空心三角形
cxt.strokeStyle="red";
cxt.stroke();
//实心三角形
cxt.beginPath();
cxt.moveTo(350,50);
cxt.lineTo(300,200);
cxt.lineTo(400,300);
cxt.closePath();
cxt.fill();
</script>
 </body>
</html>

  

使用canvas画三角形

相关文章:

  • 2021-12-29
  • 2021-06-15
  • 2022-02-28
  • 2021-10-13
  • 2022-12-23
  • 2021-09-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-11-17
  • 2021-11-09
  • 2022-12-23
  • 2021-08-22
相关资源
相似解决方案