fill-path
Vector based fill tool (like floodfill)
Last updated 3 years ago by cappieh .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install fill-path 
SYNC missed versions from official npm registry.

Fill Path

Vector based fill tool (like floodfill) build with Clipper

Usage

Include fillPath in your project. fillPath accepts two arguments, paths and point.

fillPath( Paths, Point, [ { LineWidth = 1.0, Scale = 10.0, MiterLimit = 2.0, FillOffset = 'center' } ] );

Paths = [...[...Point];
Point = { x: Number, y: Number };

LineWidth = Float;
Scale = Float;
MiterLimit = Float;
FillOffset = String;

Note: the Point argument gets rounded because Clipper needs IntPoint for polygon collision.

Include fill-path

Using JSPM

import fillPath from 'Doodle3D/fill-path';

Using NPM

const fillPath = require('fill-path');

Example code

const paths = [rect(0, 0, 30, 30), rect(10, 10, 10, 10)];
const result = fillPath(paths, { x: 5, y: 5 });

// result = [ [
//   { x: 1, y: 1 },
//   { x: 1, y: 29 },
//   { x: 29, y: 29 },
//   { x: 29, y: 1 }
// ], [
//   { x: 21, y: 10 },
//   { x: 21, y: 20 },
//   { x: 20, y: 21 },
//   { x: 10, y: 21 },
//   { x: 9, y: 20 },
//   { x: 9, y: 10 },
//   { x: 10, y: 10 },
//   { x: 10, y: 9 },
//   { x: 20, y: 9 }
// ] ]

function rect(x, y, w, h) {
  return [
    { x, y },
    { x: w + x, y },
    { x: w + x, y: h + y },
    { x, y: h + y },
    { x, y }
  ];
}

Installation

Using NPM

npm install fill-path

using JSPM

jspm install github:Doodle3D/fill-path

Clone Project

git clone git@github.com:Doodle3D/fill-path.git
cd fill-path
npm install
jspm install

Test

npm run test

Example

npm run example

Current Tags

  • 1.0.8                                ...           latest (3 years ago)

12 Versions

  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |