canvas (画布)

canvas (画布)

1、默认尺寸300*150

2、getcontext(“2d”)获取笔

--->var ctx = myEle.getContext("2d");

3、rect(x, y, 宽, 高,)

--->ctx.rect(250, 200, 300,300);
    ctx.shadowBlur=100;
    ctx.shadowColor="greenyellow";
    ctx.fillStyle="red";
    ctx.fill();

4、fill 填充

--->ctx.rect(250, 200, 300,300);
    ctx.shadowBlur=100;
    ctx.shadowColor="greenyellow";
    ctx.fillStyle="red";
    ctx.fill();

5、stoke 画边

--->ctx.strokeStyle="yellow";
    ctx.stroke();

6、
--->每次画都要用beginpath清空

--->closepath回到起点

7、save和restore

--->save 保存当前状态

--->restore  回到上一个save状态

原文地址:https://www.cnblogs.com/paul-du/p/5440479.html