学习一些常用的混合模式之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。所以效果就是图片全部展示,红色矩形全部不显示。

效果图如下:

相关推荐
TechNomad3 小时前
Kotlin_Lambda编程详解
android·kotlin
熊猫_豆豆4 小时前
QT6 Android C++ 自制美观闹钟
android·c++·qt·闹钟
美狐美颜SDK开放平台4 小时前
Android/iOS直播APP平台开发中的视频美颜SDK优化技巧
android·ios·音视频·美颜sdk·第三方美颜sdk
心中有国也有家5 小时前
使用 DevEco Studio 配置 Flutter 鸿蒙签名
学习·flutter·华为·harmonyos
nice先生的狂想曲7 小时前
Stream与StreamController以及对应的使用场景
flutter·客户端
心中有国也有家7 小时前
鸿蒙Flutter开发环境从零搭建教程(Windows/macOS双平台·避坑版)
学习·flutter·华为·harmonyos
聚美智数7 小时前
黄历查询-运势查询-国际法定节假日查询-API接口介绍
android·java·数据库
私人珍藏库8 小时前
[Android] 一木百宝箱-万能百宝箱+抖音去水印等几百种功能
android·人工智能·app·软件·多功能
wupa9 小时前
在 enableEdgeToEdge 模式下处理软键盘与自定义面板协同
android
心中有国也有家9 小时前
Flutter 鸿蒙适配第一步:从 hive 迁移到 hive\_ce
hive·学习·flutter·华为·harmonyos