123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import 'package:flutter/material.dart';
- /// 创建剪裁路径
- class ImgClipperPath extends CustomClipper<Path> {
- final double navbarH;
- ImgClipperPath(this.navbarH);
- @override
- Path getClip(Size size) {
- var path = Path();
- // 连接到距离左上角3/4处
- path.lineTo(0.0, size.height / 2);
- // 第一个控制点
- var firstControlPoint = Offset(0, size.height);
- // 目标点是底部中间点
- var firstPoint = Offset(size.width / 3,(size.height/7)*6);
- path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
- firstPoint.dx, firstPoint.dy);
- // 第二个控制点
- var secondControlPoint = Offset(size.width, size.height);
- // 目标点是右上角 3/4 处
- var secondPoint = Offset(size.width, size.height );
- path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
- secondPoint.dx, secondPoint.dy);
- // 连接到右上角
- path.lineTo(size.width, 0.0);
- // 闭合
- path.close();
- // 返回剪裁路径
- return path;
- }
- // @override
- // Path getClip(Size size) {
- // Path path = Path();
- //
- // path.lineTo(0, 56+navbarH-26);
- // path.arcToPoint(
- // Offset(26, 56+ navbarH-26),
- // radius:const Radius.circular(26),
- // clockwise: true);
- // path.lineTo(26, 56+navbarH);
- // path.lineTo(26, size.height);
- // // path.close();
- // return path;
- // }
- @override
- bool shouldReclip(CustomClipper<Path> oldClipper) => oldClipper.hashCode != this.hashCode;
- }
|