七、融合

七、融合

HTML 5 canvas globalCompositeOperation 属性

UtSTxI.png

1
2
3
4
5
6
7
8
9
10
11
12
// 获取元素
var canvas = document.getElementById("myCanvas");
// 获取画笔
var ctx = canvas.getContext("2d");

// 绘制矩形
ctx.fillRect(0, 0, 200, 200);

// 改变填充色
ctx.fillStyle = "orange";
// 绘制矩形
ctx.fillRect(100, 100, 200, 200);

UtSjIg.png

1
2
3
4
5
6
7
8
9
10
11
// 绘制矩形
ctx.fillRect(0, 0, 200, 200);

// 在 canvas 中有一个属性可以改变新老图形的覆盖方式
console.log(ctx.globalCompositeOperation);
ctx.globalCompositeOperation = "destination-over";
console.log(ctx.globalCompositeOperation);
// 改变填充色
ctx.fillStyle = "orange";
// 绘制矩形
ctx.fillRect(100, 100, 200, 200);

UtpAdU.png

点击查看

本文标题:七、融合

文章作者:Mango

发布时间:2020年07月14日 - 13:25:09

最后更新:2020年07月14日 - 13:27:10

原始链接:https://mango185.github.io/post/10c4f7b5.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------------本文结束 感谢您的阅读-------------------