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

相关推荐
天空之城--15 小时前
Android Koin 完全指南:从原理到实践
android
zhangphil16 小时前
Android main thread主线程Choreographer doFrame发生FullSuspendCheck
android
TimeFine20 小时前
智能眼镜开发:获取真实的音频路由
android
pengyu20 小时前
【Kotlin 协程修仙录 · 渡劫境 · 中阶】 | 造化神兵:自定义 CoroutineDispatcher 与调度器的终极定制
android·kotlin
pengyu20 小时前
【Kotlin 协程修仙录 · 渡劫境 · 初阶】 | 飞升雷劫:CPS 变换与挂起函数字节码终极透视
android·kotlin
TimeFine20 小时前
智能眼镜开发:眼镜Touch后收音与触发播放系统音乐的矛盾处理
android
TimeFine21 小时前
智能眼镜开发:眼镜侧收集音频
android
又见情义21 小时前
Android 系统设置从平板版迁移至TV版实践
android
末代iOS程序员华仔21 小时前
iOS 5.6 条例解决方法
flutter·ios·swift
杉氧1 天前
打破边界(一):实战编写 Android/iOS 原生模块 (Native Modules)
android·react native·前端框架