canvas合成和裁剪
2024-08-20 22:53:09
canvas合成和裁剪
属性
globalCompositeOperation=type 设置覆盖类型
source-over 源覆盖在目标上
source-in 源覆盖在目标上的公共部分(只取源图形的部分)
source-out 源覆盖在目标上以外的部分
source-atop 源覆盖在目标上的公共部分与目标的交集
destination-over 目标覆盖在源上
destination-in
destination-out
destination-atop
lighter 目标和源公共部分颜色值相加,结果是颜色更亮
copy 只显示源
xor 去除源和目标的公共部分
multiply 目标和源公共部分颜色值相乘,结果是颜色更暗
screen 比lighter的效果更light
overlay multiply和screen的混合作用
darken 保留目标和源像素最暗的部分
lighten 保留目标和源像素最亮的部分
color-dodge
color-burn
hard-light
soft-light
difference
exclusion
hue
saturation
color
luminosity ctx.clip(); 裁剪一块儿区域
合成使用示例
ctx.fillStyle='blue';
ctx.fillRect(150,150,200,200) // 源图形
ctx.globalCompositeOperation="source-over";
ctx.fillStyle='orange';
ctx.fillRect(100,100,200,200); // 目标图形
裁剪使用示例
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d'); ctx.beginPath();
ctx.arc(200, 200, 60, 0, Math.PI * 2, true);
ctx.stroke();
ctx.clip(); ctx.fillStyle="green";
ctx.fillRect(150,150,50,50);
最新文章
- 《转载》跟我学spring3
- 【超级干货】手机移动端WEB资源整合
- wcscpy_s与wcsncpy
- oracle存储过程、函数、序列、包
- iOS-RegexKitLite导入错误
- 分布式拒绝服务攻击(DDoS)原理及防范
- Wix打包相关资源
- [AFUI]App Framework
- table extraction
- jasper2
- phpcms v9 分页
- 青云B轮获2000万美元VC的背后逻辑:用技术超越巨头
- 用AsyncTask实现多线程
- xhEditor struts2实现图片上传
- Unity3DGUI:常用控件
- mongodb更新数据
- CoreCLR源码探索(六) NullReferenceException是如何发生的
- Wireshark网络端点和会话
- go语言调度器源代码情景分析之三:内存
- document.getElementById 和 document.getElementsByClassName获取DOM元素的区别