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

效果图如下:

相关推荐
2501_91592143几秒前
iOS APP上架工具,在没有 Mac 的环境中发布苹果应用
android·macos·ios·小程序·uni-app·iphone·webview
范特西林2 分钟前
第一篇:从电源键到上帝进程——硬件觉醒与 Init 的诞生
android
养了一只皮卡丘4 分钟前
ubuntu22.04搭建mysql8.0.45 mgr (2)
android·adb
常利兵6 分钟前
深入理解Android ViewModel&SavedStateHandle:告别数据丢失,打造稳健UI架构
android·ui·架构
范特西林8 分钟前
第四篇:从点击到显示——App 启动与 Activity 生命周期全追踪
android
ke_csdn9 分钟前
安卓的视频通讯
android·音视频
范特西林9 分钟前
第二篇:Java 世界的“创世神”:Zygote 如何一秒孵化一个 App?
android
范特西林11 分钟前
第三篇:SystemServer——Android 框架层的大脑
android
robotx12 分钟前
aosp单编单刷framework模块以及恢复remount
android
Jomurphys14 分钟前
Compose 自定义 - 处理交互 Interaction
android·compose