0.1.7 • Published 3 years ago

idrawing v0.1.7

Weekly downloads
19
License
MIT
Repository
github
Last release
3 years ago

idrawing

Provides a common abstract interface for drawing. The resulting format depends on the chosen interface implementation (currently only SVG format is supported, DXF is planned).

Operations

The following operations are supported:

  • line
  • rect
  • circle
  • ellipse
  • polyline
  • polygon
  • polybezier
  • curve (draws a smooth curve through all given points. The curve can be closed)
  • text
  • region (represents a fill area by combining multiple closed shapes)
  • path (represents a complex shape by combining straingt or curved lines)

Quickstart

const { SvgDrawing } = require('idrawing/svg');
const fs = require('fs');

function draw(drawing) {
  const region = drawing.createRegion();
  region.include((r) => {
    r.circle(50, 50, 40);
    r.circle(90, 70, 40);
  });
  region.exclude((r) => 
    r.circle(70, 60, 10)
  );
  drawing.region(region, {fill: 'red'});
  const paths = region.outline();
  paths.forEach(path => svg.path(path, {stroke: '#000', fill: 'none'}));
}

const svg = new SvgDrawing();
draw(svg);
fs.writeFileSync(__dirname + '/example.svg', svg.svg());

example.svg

Authors

  • Yuri Spektor
0.1.7

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.0.2

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago