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

相关推荐
必须会一定会3 分钟前
GLM-5.3 迁移实战:强制思考、1M 上下文与官方编程基准
android·开发语言·kotlin
小孔龙18 分钟前
Android MessageQueue:从单锁队列到 DeliQueue
android
math_hongfan25 分钟前
事务下单与状态流转:ArkTS 的 JOIN 联表在鸿蒙订单里实战
android·学习·华为·harmonyos
嘟哩DuliDuli1 小时前
AI 账单变高的技术原因:重复上下文和用量归属
android·人工智能·安全·ai·软件工程
阿pin16 小时前
Android随笔-kotlin withContext
android·kotlin·withcontext
树码小子16 小时前
开启 IDEA 中的断言功能
android·java·intellij-idea
Kslient16 小时前
HeaderBehavior
android
Android-Flutter17 小时前
android 动画详解
android·kotlin
SoaringHeart18 小时前
Flutter最佳实践:Web项目中文字体首次加载乱码问题解决
前端·flutter
程序员老刘18 小时前
Flutter 3.47 更新要点:Material 正式分家,老项目先别急着更新
flutter·ai编程·客户端