Giter VIP home page Giter VIP logo

dash_painter's Introduction

dash_painter

a package for flutter canvas paint dash line path easily.

1. DashPainter 如何使用

DashPainter 只负责对 路径 Path 的虚线化绘制,不承担组件职能。 一般用在拥有 Canvas 对象的回调方法中,比如自定义的 CustomPainterDecoration。 具体使用案例见 demo

const DashPainter(span: 4, step: 9).paint(canvas, path, paint);

对于所有的路径都是使用的,如下的 圆角矩形圆形

圆角矩形 圆形

2. 点划线的使用

除了虚线,还可以绘制点划线 , pointCountpointWidth两个属性,分别表示点划线数点划线长

const DashPainter(
    span: 4, // 空格长
    step: 10, // 实线长
    pointCount: 2, // 点划线个数
    pointWidth: 2 // 点划线长
).paint(canvas, path, paint);
  • 单点划线

  • 双点划线

  • 三点划线


点画线圆


DashPainter

可能很多人不会自定义画板自己绘制,或只想简单地使用。其实除了 CustomPainter 还有其他地方有 canvas。比如 Decoration 。 这里提供了 DashDecoration 的装饰,方便使用。如下实现一个渐变的单点画线圆角虚线框

Container(
  width: 100,
  height: 100,
  decoration: DashDecoration(
      pointWidth: 2,
      step: 5,
      pointCount: 1,
      radius: Radius.circular(15),
      gradient: SweepGradient(colors: [
        Colors.blue,
        Colors.red,
        Colors.yellow,
        Colors.green
      ])),
  child: Icon(
    Icons.add,
    color: Colors.orangeAccent,
    size: 40,
  ),
),

dash_painter's People

Contributors

toly1994328 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.