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

相关推荐
氦客16 分钟前
Android Compose 图层的合成 : BlendMode
android·compose·jetpack·layer·blendmode·graphics·图层的合成
5008437 分钟前
HCCL 集合通信编程:多卡协同的正确姿势
java·flutter·性能优化·electron·wpf
Sahadev_1 小时前
GitMemo 安卓版发布了:现在可以随时随地查看和记录自己的笔记
android·笔记·创业创新
龙之叶1 小时前
Android 12:在 ActivityStarter 层拦截分享、搜索与 HTTP 外链
android·chrome·http
牛奔2 小时前
Android 开发通用解决方案:使用 ADB 彻底卸载已安装 App(解决版本降级安装失败问题)
android·adb
tryqaaa_3 小时前
学习日志(三)【php语法学习,iscc校赛wp】
android·网络协议·学习·安全·web安全·web
你听得到113 小时前
从 Figma 走查到 AI 可验证产物:我如何重构客户端 UI 交付链路
前端·vue.js·flutter
plainGeekDev3 小时前
Kotlin协程面试题:suspend原理都说不清,协程你真会用?
android·面试·kotlin
Kapaseker3 小时前
Android 官方开始拥抱 WebView
android
ujainu小3 小时前
CANN hixl:大模型 PD 分离场景的零拷贝通信库
android·java·缓存