canvas合成和裁剪

  1. 属性

    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(); 裁剪一块儿区域
  2. 合成使用示例

    ctx.fillStyle='blue';
    ctx.fillRect(150,150,200,200) // 源图形
    ctx.globalCompositeOperation="source-over";
    ctx.fillStyle='orange';
    ctx.fillRect(100,100,200,200); // 目标图形
  3. 裁剪使用示例

    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);

最新文章

  1. 《转载》跟我学spring3
  2. 【超级干货】手机移动端WEB资源整合
  3. wcscpy_s与wcsncpy
  4. oracle存储过程、函数、序列、包
  5. iOS-RegexKitLite导入错误
  6. 分布式拒绝服务攻击(DDoS)原理及防范
  7. Wix打包相关资源
  8. [AFUI]App Framework
  9. table extraction
  10. jasper2
  11. phpcms v9 分页
  12. 青云B轮获2000万美元VC的背后逻辑:用技术超越巨头
  13. 用AsyncTask实现多线程
  14. xhEditor struts2实现图片上传
  15. Unity3DGUI:常用控件
  16. mongodb更新数据
  17. CoreCLR源码探索(六) NullReferenceException是如何发生的
  18. Wireshark网络端点和会话
  19. go语言调度器源代码情景分析之三:内存
  20. document.getElementById 和 document.getElementsByClassName获取DOM元素的区别

热门文章

  1. Redis为什么要把所有数据放到内存中?
  2. thinkphp3.2笔记(5)创建项目 创建模型 实例化
  3. data模块
  4. 拖拉记录上下移动--Ajax UI
  5. Android之水波纹点击效果(RippleView)
  6. java裁剪图片
  7. UVALive-3972 March of the Penguins (最大流:节点容量)
  8. Java中字符串比较的注意点
  9. nginx会话保持之sticky模块
  10. web 常用富文本编辑器