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

相关推荐
liang_jy2 小时前
Android SparseArray
android·源码
liang_jy2 小时前
Activity 启动流程扩展篇(一)—— startActivityInner 任务决策全解析
android·源码
jiejiejiejie_2 小时前
Flutter for OpenHarmony 心情日记功能实战指南
flutter·华为
jiejiejiejie_3 小时前
Flutter for OpenHarmony 倒计时功能实战开发
flutter
NPE~3 小时前
[App逆向]脱壳实战
android·教程·逆向·android逆向·逆向分析
木易 士心3 小时前
别再只会用 drawCircle 了!一文搞懂 Android Canvas 底层机制
android
Math_teacher_fan3 小时前
Flutter 跨平台开发实战:鸿蒙与音乐律动艺术(六)、Lissajous 利萨茹曲线:频率耦合的轨迹艺术
flutter·ui·数学建模·华为·harmonyos·鸿蒙系统
里欧跑得慢3 小时前
17. Flutter Hero动画实现:让界面过渡更加优雅
前端·css·flutter·web
liulian09164 小时前
Flutter for OpenHarmony 跨平台开发:秒表功能实战指南
flutter
AtOR CUES5 小时前
MySQL——表操作及查询
android·mysql·adb