2D上下文

js中说明的上下文表示的意思为C++中作用域(个人理解),因此2D上下文说明的是这个2D的作用域

像素:用来描述图片清晰度的小矩阵

填充和描边

填充context.fillStyle = "yellow";

描边context.strokeStyle = "red";

如果单纯的使用这两个属性,不会再网页上面显示的。

var drawing = document.getElementById("drawing");
if(drawing.getContext)
{
  var context = drawing.getContext("2d");
  context.strokeStyle = "red";
  context.fillStyle = "yellow";
  context.fillRect(20,20,150,100)
  context.strokeRect(20,20,150,100)
  console.log(context)
}

猜你喜欢

转载自www.cnblogs.com/MyUniverse/p/9986684.html