zoukankan      html  css  js  c++  java
  • Flutter 画贝塞尔曲线

    import 'package:flutter/cupertino.dart';
    import 'package:flutter/material.dart';

    class FixedServiceView extends StatefulWidget{
    @override
    _FixedServiceView createState() {
    return _FixedServiceView();
    }

    }

    class _FixedServiceView extends State<FixedServiceView>{
    @override
    Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final width = size.width;
    final height = size.height;

    return Container(
    margin: new EdgeInsets.fromLTRB(0, 0, 0, 10),
    height: 180,
    alignment: Alignment.center,
    color: Colors.transparent,
    child: ClipPath(
    clipper: BottomClipper(),
    child: Container(
    color: Colors.white,
    ),
    ),
    );
    }
    }

    // 曲线路径
    class BottomClipper extends CustomClipper<Path>{

    @override
    Path getClip(Size size){
    var path = Path();
    //第1个点
    path.lineTo(0, 0);
    //第2个点
    var controlPoint = Offset(size.width / 2, 40);
    var ednPoint = Offset(size.width, 0);
    path.quadraticBezierTo(
    controlPoint.dx,
    controlPoint.dy,
    ednPoint.dx,
    ednPoint.dy
    );
    //第3个点
    path.lineTo(size.width, size.height);
    //第4个点
    path.lineTo(0, size.height);

    return path;
    }
    @override
    bool shouldReclip(CustomClipper<Path> oldClipper) {
    return false;
    }
    }
  • 相关阅读:
    memset使用技巧
    04.碰撞反应
    03.键盘状态跟踪与精灵删除
    02.基本动作
    01.基本图形
    00.入门
    03.交互--鼠标,键盘
    02.action--新增精灵知识点
    01.helloworld--标签
    05.声音
  • 原文地址:https://www.cnblogs.com/diweinan/p/13503326.html
Copyright © 2011-2022 走看看