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

相关推荐
方白羽14 分钟前
Android APK安全防护
android·安全·apk
小黄人软件18 分钟前
AndroidStudio老项目 macOS运行BlueTooth蓝牙串口助手(Android+Studio源码).rar
android·macos
00后程序员张19 分钟前
苹果App Store上架指南:费用、原理与步骤详解
android·ios·小程序·https·uni-app·iphone·webview
天神哥哥啊20 分钟前
cocos联调注意事项-安卓
android
TDengine (老段)32 分钟前
TDengine TSDB 实战排障四(升级与兼容)
android·java·大数据·数据库·物联网·时序数据库·tdengine
蓝速科技1 小时前
政务自助终端信创选型与无人值守落地方案
android·大数据·数据库·人工智能·科技·技术分享·政务
m0_738185822 小时前
Flutter 鸿蒙化实战:flutter_app_badger 适配 OpenHarmony,应用角标
flutter·华为·harmonyos·鸿蒙
yuezhilangniao2 小时前
FVM 与 Flutter 环境配置完全指南:从安装到日常使用
flutter
硫酸锌012 小时前
在手机上运行Python增量备份手机数据到PC电脑
android·windows·python
hai_android3 小时前
子 View 被压小时,如何向父容器"告状"?——MEASURED_STATE_TOO_SMALL 向上传递机制
android·kotlin·android jetpack