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

相关推荐
ganshenml16 小时前
【Android】 开发四角版本全解析:AS、AGP、Gradle 与 JDK 的配套关系
android·java·开发语言
我命由我1234516 小时前
Kotlin 运算符 - == 运算符与 === 运算符
android·java·开发语言·java-ee·kotlin·android studio·android-studio
摘星编程17 小时前
【RAG+LLM实战指南】如何用检索增强生成破解AI幻觉难题?
android·人工智能
火柴就是我18 小时前
学习一些常用的混合模式之BlendMode. dst
android·flutter
遥不可及zzz18 小时前
解决 Google Play 提示的 16KB 内存页面大小对齐问题:通过升级 Android Gradle 插件(AGP)
android
前端不太难18 小时前
Sliver 为什么能天然缩小 rebuild 影响面
flutter·性能优化·状态模式
SmartRadio18 小时前
在MT8791 5G硬件平台上舍弃安卓系统-运行OpenWRT系统
android·5g·mt8791
虫小宝19 小时前
导购APP高可用数据库设计:主从分离与分库分表在返利系统中的应用
android·数据库
我命由我1234519 小时前
Android Jetpack Compose - TopAppBar、BottomAppBar、Scaffold
android·java·java-ee·kotlin·android studio·android jetpack·android-studio