学习一些常用的混合模式之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 都保留。

相关推荐
冬奇Lab5 小时前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读
城东米粉儿8 小时前
Android MediaPlayer 笔记
android
Jony_9 小时前
Android 启动优化方案
android
阿巴斯甜9 小时前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇9 小时前
AOSP15 Input专题InputReader源码分析
android
_小马快跑_13 小时前
Kotlin | 协程调度器选择:何时用CoroutineScope配置,何时用launch指定?
android
_小马快跑_13 小时前
Kotlin | 从SparseArray、ArrayMap的set操作符看类型检查的不同
android
_小马快跑_13 小时前
Android | 为什么有了ArrayMap还要再设计SparseArray?
android
_小马快跑_13 小时前
Android TextView图标对齐优化:使用LayerList精准控制drawable位置
android
_小马快跑_13 小时前
Kotlin协程并发控制:多线程环境下的顺序执行
android