svgpath 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 56

svgpath

This is a Dart port of Fontello's svgpath JavaScript library.

Low level toolkit for SVG paths transformations. Sometime you can't use transform attributes and have to apply changes to svg paths directly. Then this package is for you :) !

This package works both in browser and on server.

API

new SvgPath(path)

Constructor. Creates new SvgPath class instance.

.abs()

Converts all path commands to absolute.

.rel()

Converts all path commands to relative. Useful to reduce output size.

.scale(sx [, sy])

Rescale path (the same as SVG scale transformation). sy = sx by default.

.translate(x [, y])

Translate path (the same as SVG translate transformation). y = 0 by default.

.rotate(angle [, rx, ry])

Rotate path to angle degrees around (rx, ry) point. If rotation center not set, (0, 0) used. The same as SVG rotate transformation.

.skewX(degrees)

Skew path along the X axis by degrees angle.

.skewY(degrees)

Skew path along the Y axis by degrees angle.

.matrix([ m1, m2, m3, m4, m5, m6 ])

Apply 2x3 affine transform matrix to path. Params - array. The same as SVG matrix transformation.

.transform(string)

Any SVG transform or their combination. For example rotate(90) scale(2,3). The same format, as described in SVG standard for transform attribute.

.unshort()

Converts smooth curves T/t/S/s with "missed" control point to generic curves (Q/q/C/c).

.unarc()

Replaces all arcs with bezier curves.

.toString() -> String

Returns final path string.

.round(precision)

Round all coordinates to given decimal precision. By default round to integer. Useful to reduce resulting output string size.

.iterate(function(segment, index, x, y) [, keepLazyStack])

Apply iterator to all path segments.

  • Each iterator receives segment, index, x and y params. Where (x, y) - absolute coordinates of segment start point.
  • Iterator can modify current segment directly (return nothing in this case).
  • Iterator can return array of new segments to replace current one ([] means that current segment should be deleted).

If second param keepLazyStack set to true, then iterator will not evaluate stacked transforms prior to run. That can be useful to optimize calculations.

Changelog

1.0.0

  • Fix matrix value helper function.

0.1.0

  • Implement BoundingBox

0.0.1

  • Initial version

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  svgpath: "^1.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:svgpath/svgpath.dart';
        
Version Uploaded Documentation Archive
1.0.0 Jan 15, 2017 Go to the documentation of svgpath 1.0.0 Download svgpath 1.0.0 archive
0.1.0 Jan 6, 2017 Go to the documentation of svgpath 0.1.0 Download svgpath 0.1.0 archive
0.0.1 Dec 31, 2016 Go to the documentation of svgpath 0.0.1 Download svgpath 0.0.1 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
25 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
73 / 100
Overall score:
Weighted score of the above. [more]
56
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:svgpath/svgpath.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 15 hints.

    Run dartfmt to format lib/src/a2c.dart.

    Strong-mode analysis of lib/src/ellipse.dart gave the following hint:

    line: 10 col: 15
    'PI' is deprecated and shouldn't be used.

    Similar analysis of the following files failed:

    • lib/src/matrix.dart (hint)
    • lib/src/svgpath.dart (hint)
    • lib/src/transform_parse.dart (hint)
  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use svgpath.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
Dev dependencies
path
test >=0.12.0 <0.13.0