Giter Club home page Giter Club logo

flutter_dotted_line_array's Introduction

dotted_line_array

This Flutter Canvas library allows you to draw dotted straight line and arc with the array syntax of html5 canvas.

Features

Similar to this, this library lets you draw dotted line and arc with varying gaps and lengths using the HTML5 canvas's setLineDash() array syntax.

Getting started

Import this package and follow the syntax provided below.

Usage

setLineDash()

Parameter Class//type Description
canvas Canvas Canvas object
point1 Offset Beginning point
point2 Offset End point
paint Paint Paint object
lineDash List Array of numbers as specified by the HTML5 Canvas API's docs. Each number describes a length in pixels.

setArcDash()

Parameter Class//type Description
canvas Canvas Canvas object
x double Center of the arc X
y double Center of the arc Y
radiusX double Arc horizontal radius
radiusY double Arc vertical radius
paint Paint Paint object
startAngle double Starting angle in degrees
sweepAngle double Clockwise sweep amount starting from startAngle, also in degrees
lineDash List Array of numbers as specified by the HTML5 Canvas API's docs. Each number describes a length in degrees.

Note: For the setArcDash, I find thinking about each of the dashes' length in degrees, rather than in pixels, more intuitive.

Instead of "this arc dash, when straightened, is 5 pixels long", we can say: "this arc dash, for a circle of radius x, is 30 degrees in length"

Syntax Comparisons

Dart

const lineDash = [2, 20];

//straight line
setLineDash(canvas, point1, point2, paint, lineDash);

//Circle or ellipse
setArcDash(canvas, x, y, radiusX, radiusY, paint, startAngle, sweepAngle, lineDash);

JavaScript

ctx.setLineDash([2, 20]);

//Straight Line
ctx.lineTo(x1, y1, x2, y2);

//Circle
ctx.arc(x, y, radius, startAngle, endAngle, [, counterclockwise]);

//Circle or Ellipse
ctx.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle [, counterclockwise]);

ctx.stroke();

Result comparisons (Flutter: purple background, HTML5: white)

Note: The Flutter examples were captured on a smaller device.

[2, 20]

2,20 dart example

2,20 javascript example

[5, 10, 12]

5,10,12 dart example

5,10,12 javascript example

[1, 20, 0, 5, 2]

1,20,0,5,2 dart example

1,20,0,5,2 javascript example

[20, 3, 3, 3, 3, 3, 3, 3]

20,3,3,3,3,3,3,3 dart example

20,3,3,3,3,3,3,3 javascript example

Example Combining Straight Lines with Arcs

With [5, 5] for lines and [7.8, 7.8] for arcs

ui-example-with-equal-arrays-of-same-number

With [1.0, 2.0, 3.0, 4.0] for lines and [2.0, 4.0, 6.0, 8.0] for arcs

ui-example-with-arrays-of-different-numbers

UI design by Natawan Meechai

UI src: https://github.com/Khongchai/yawwn/blob/main/lib/widgets/progress/dotted_line_path_points.dart

flutter_dotted_line_array's People

Contributors

khongchai avatar marchacio avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

marchacio

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.