【问题标题】:flutter : how to flip this path clip Bezierflutter : 如何翻转这个路径剪辑 Bezier
【发布时间】:2020-09-17 01:11:46
【问题描述】:

我有这个形状 enter image description here

我想把它翻转成这样

enter image description here

这是原始代码

class CustomMenuClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    Paint paint = Paint();
    paint.color = Colors.white;

    final width = size.width;
    final height = size.height;

    Path path = Path();
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 8, 10, 16);
    path.quadraticBezierTo(width - 1, height / 2 - 20, width, height / 2);
    path.quadraticBezierTo(width + 1, height / 2 + 20, 10, height - 16);
    path.quadraticBezierTo(0, height - 8, 0, height);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return true;
  }
} 

这是github repository 如果是半圆,我不介意。

【问题讨论】:

标签: flutter bezier clip-path flutter-clippath


【解决方案1】:

我认为应该是这样的:

     Path getClip(Size size) {
        Paint paint = Paint();
        paint.color = Colors.white;
    
        final width = size.width;
        final height = size.height;
    
        Path path = Path();
        path.moveTo(width, 0);
        path.quadraticBezierTo(16, 10, 8, 0);
        path.quadraticBezierTo(height / 2,  width, height / 2 - 20 ,width - 1);
        path.quadraticBezierTo( height - 16, 10, height / 2 + 20, height - 16width + 1);
        path.quadraticBezierTo(height, 0, height - 8, 0);
        path.close();
        return path;
      }

我不建议这样做,因为不同的设备可能会重现不同的行为。也许使用size.widthsize.height 可能是更好的响应方式。

【讨论】:

  • @Sam 我会测试它并更改它以查看它有什么问题,将更新答案。
猜你喜欢
  • 1970-01-01
  • 2020-08-10
  • 2021-11-28
  • 2018-11-13
  • 2013-06-27
  • 1970-01-01
  • 2021-02-25
  • 2016-09-18
  • 2013-04-16
相关资源
最近更新 更多