学习一些常用的混合模式之BlendMode. dst_atop

Discards the destination pixels that are not covered by source pixels. Draws remaining destination pixels over source pixels.

公式:

js 复制代码
    canvas.saveLayer(Rect.fromLTWH(0, 0, width, height), Paint());
    Paint dstPaint = Paint()..color = Colors.red;
    dstPaint.style = ui.PaintingStyle.fill;
    canvas.drawImageRect(image1!, Rect.fromLTWH(0, 0, image!.width.toDouble(), image!.height.toDouble()), Rect.fromLTWH(0, 0, width/2, height/2), dstPaint);

    var srcPaint = Paint()
      ..color = Colors.red
      ..strokeWidth = 10
      ..blendMode = ui.BlendMode.dstATop; // 源颜色:蓝色; // 混合模式
    canvas.drawRect(Rect.fromLTWH(0, 0, width, height).deflate(30), srcPaint);

效果图:

重叠部分展示 dst 非重叠部分 src 跟 dst 都保留。

相关推荐
见山是山-见水是水1 小时前
鸿蒙flutter第三方库适配 - 读书笔记
flutter·华为·harmonyos
Utopia^2 小时前
鸿蒙flutter第三方库适配 - 图片压缩工具
flutter·华为·harmonyos
冬奇Lab4 小时前
MediaPlayer 播放器架构:NuPlayer 的 Source/Decoder/Renderer 三驾马车
android·音视频开发·源码阅读
见山是山-见水是水5 小时前
鸿蒙flutter第三方库适配 - 车辆管理
flutter·华为·harmonyos
炸炸鱼.6 小时前
Python 操作 MySQL 数据库
android·数据库·python·adb
Utopia^6 小时前
鸿蒙flutter第三方库适配 - 番茄钟专注
flutter·华为·harmonyos
用户41659673693557 小时前
nextlib 项目架构与深度技术指南 (Architecture & Technical Master Guide)
android
aq55356008 小时前
Laravel10.x重磅升级,新特性一览
android·java·开发语言
Trouvaille ~8 小时前
【MySQL篇】数据类型:存储数据的基础
android·数据库·mysql·adb·字符集·数据类型·基础入门
程序员老刘9 小时前
放弃折腾后端服务器后,这才是独立开发MVP的最优解
flutter·客户端·firebase