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

相关推荐
autumn20053 分钟前
Flutter 框架跨平台鸿蒙开发 - AR历史场景穿越
flutter·华为·ar·harmonyos
酿情师20 分钟前
PHP 反序列化漏洞与 POP 链详解:网络安全小白从零入门
android·web安全·php
AI_零食21 分钟前
开源鸿蒙跨平台Flutter开发:手账记事模板库应用
学习·flutter·华为·开源·harmonyos·鸿蒙
提子拌饭13326 分钟前
开源鸿蒙跨平台Flutter开发:家庭影像传承系统
flutter·华为·开源·harmonyos·鸿蒙
数厘27 分钟前
2.3MySQL 表结构设计:提升 SQL 查询性能的关键
android·sql·mysql
Kiri霧33 分钟前
Kotlin递归
android·开发语言·kotlin
李李李勃谦33 分钟前
Flutter 框架跨平台鸿蒙开发 - 手工作品展示
flutter·华为·harmonyos
普通网友34 分钟前
Android开发:使用Kotlin+协程+自定义注解+Retrofit的网络框架
android·kotlin·retrofit
左手厨刀右手茼蒿34 分钟前
Flutter 三方库 klutter 的鸿蒙化适配指南 - 掌握 Kotlin Multiplatform (KMP) 互操作技术、助力鸿蒙应用构建极致复用且高性能的跨端业务逻辑共享体系
flutter·harmonyos·鸿蒙·openharmony
世人万千丶36 分钟前
开源鸿蒙跨平台Flutter开发:古诗词学习应用
学习·flutter·华为·开源·harmonyos·鸿蒙