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

相关推荐
StarsGreen4 小时前
Android中的seccomp相关信息介绍
android
阿杰m9 小时前
Android源码第二十四章:OTA 与 APEX——重启后换了什么?
android
用户081268037419 小时前
差点格式化一台 Redmi K80:一次 WebView 翻车的无损救援实录
android·debug·webview
阿杰m9 小时前
Android源码第二十五章:WebView 与 Chromium——网页何时画上屏?
android·android studio
StarsGreen9 小时前
Android中特殊文件的相关说明
android
Digitally12 小时前
6 款优质安卓备份提取工具与备份方案
android
恋猫de小郭14 小时前
Flutter A2UI 1.0 ,原来的 genui 也正式换成了这一套 SDK 了
android·前端·flutter
LinXunFeng16 小时前
A2UI 1.0 详解:让 AI 生成 Flutter 界面,还不怕它乱写
前端·flutter·agent
Wellijohn1 天前
一个 Android 老兵的十年开源路:从 167 star 的滑动控件,到本地优先的 AI Agent
android·人工智能·开源
好的佩奇1 天前
Dart 之元数据与注解
android·flutter·dart