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

The source pixels are discarded, leaving the destination intact.

代码

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
      ..blendMode = ui.BlendMode.dst; // 源颜色:蓝色; // 混合模式
    canvas.drawRect(Rect.fromLTWH(0, 0, width, height), srcPaint);

    canvas.restore();

重叠部分只保留dst的内容,清空所有的src。非重叠部分只保留dst的内容,清空所有的src。所以效果就是图片全部展示,红色矩形全部不显示。

效果图如下:

相关推荐
_李小白39 分钟前
【OSG学习笔记】Day 38: TextureVisitor(纹理访问器)
android·笔记·学习
JJay.1 小时前
Kotlin 高阶函数学习指南
android·开发语言·kotlin
jinanwuhuaguo1 小时前
截止到4月8日,OpenClaw 2026年4月更新深度解读剖析:从“能力回归”到“信任内建”的范式跃迁
android·开发语言·人工智能·深度学习·kotlin
加农炮手Jinx1 小时前
Flutter 组件 conventional 适配鸿蒙 HarmonyOS 实战:约定式提交标准,构建自动化版本治理与 CI/CD 质量治理架构
flutter·harmonyos·鸿蒙·openharmony
王码码20351 小时前
Flutter 三方库 appstream 的鸿蒙化适配指南 - 驾驭 Linux 生态元数据规范,打造高性能、标准化、国际化的 OpenHarmony 桌面应用商店分发基石
flutter·harmonyos·鸿蒙·openharmony
见山是山-见水是水1 小时前
Flutter 框架跨平台鸿蒙开发 - AR植物养护助手
flutter·华为·ar·harmonyos
JJay.2 小时前
Android Kotlin 协程使用指南
android·开发语言·kotlin
autumn20052 小时前
Flutter 框架跨平台鸿蒙开发 - 历史人物对话
服务器·flutter·华为·harmonyos
BLUcoding2 小时前
Android 布局介绍
android
summerkissyou19872 小时前
android-蓝牙-状态和协议值总结及监听例子
android·蓝牙