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

Keeps the destination pixels that cover source pixels, discards the remaining source and destination 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
      ..blendMode = ui.BlendMode.dstIn; // 源颜色:蓝色; // 混合模式
    canvas.drawRect(Rect.fromLTWH(0, 0, width, height).deflate(30), srcPaint);

    canvas.restore();

效果图:

可以看到重合部分保留了dst,非重合部分dst保留,src全部清空。

相关推荐
城东米粉儿3 小时前
Android MediaPlayer 笔记
android
Jony_3 小时前
Android 启动优化方案
android
阿巴斯甜3 小时前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇3 小时前
AOSP15 Input专题InputReader源码分析
android
_小马快跑_8 小时前
Kotlin | 协程调度器选择:何时用CoroutineScope配置,何时用launch指定?
android
_小马快跑_8 小时前
Kotlin | 从SparseArray、ArrayMap的set操作符看类型检查的不同
android
_小马快跑_8 小时前
Android | 为什么有了ArrayMap还要再设计SparseArray?
android
_小马快跑_8 小时前
Android TextView图标对齐优化:使用LayerList精准控制drawable位置
android
_小马快跑_8 小时前
Kotlin协程并发控制:多线程环境下的顺序执行
android
_小马快跑_8 小时前
Kotlin协程异常捕获陷阱:try-catch捕获异常失败了?
android