首页 网络科技 正文

编程代码圆脸怎么编

//Createanewcanvaselement.varmyCanvas=document.createElement("canvas");myCanvas.width=600;//setthewidthandheightofthecanvasmyCanvas.height=400;document.getElementById("...

编程代码圆脸怎么编?

下面是一段示例代码,可以用来绘制一张圆脸:

//Create a new canvas element.

var myCanvas = document.createElement("canvas");

myCanvas.width = 600; //set the width and height of the canvas

myCanvas.height = 400;

document.getElementById("body").appendChild(myCanvas); //Add it to the DOM

//Draw an oval/circle shape

var ctx=myCanvas.getContext("2d");

ctx.fillStyle="#FF0000"; //Set up color, lineWidth and style

ctx .lineWidth=5;

ctx .beginPath();

ctx .arc(300,200,150,0,Math.PI*2,true); //draw a circle on your canvas using arc() method with given parameters: center x coord., center y coord., radius size & start angle (here 0), end angle (here Math PI*2).

本文转载自互联网,如有侵权,联系删除