学习一些常用的混合模式之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全部清空。

相关推荐
一笑的小酒馆4 小时前
AndroidKMP之网络请求
android
aqi007 小时前
鸿蒙版本的JSBridge兼容与安卓配套的H5啦
android·华为·harmonyos·鸿蒙·移动应用
事圆则缓8 小时前
MVVM 的理解与设计
android·android jetpack
熊猫钓鱼>_>8 小时前
Flutter app_settings 鸿蒙适配实战:Intent 体系到 Want 的跨越
flutter·华为·harmonyos·openharmony·intent·want
码农阿豪9 小时前
我把 OpenClaw 装进旧安卓手机后,又折腾了 3 天:飞书、ADB、SSH 全部打通
android·智能手机·飞书
里欧跑得慢9 小时前
Flutter主题与样式详解
前端·css·flutter·web
有什么事10 小时前
把安卓搬上云端:云手机系统改造与内核优化拆解
android·智能手机
方白羽11 小时前
性能分析:Android Studio Profiler
android·性能优化·app
没文化的阿浩11 小时前
【MySQL】用户管理
android·mysql·adb
程序员老刘11 小时前
现在回头看,Dart取消宏是无比正确的决定
flutter·ai编程·dart