Giter Site home page Giter Site logo

hartl3y94 / dxf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dxfjs/writer

0.0 0.0 0.0 355 KB

A simple JavaScript interface to DXF written in TypeScript.

Home Page: https://github.com/tarikjabiri/dxf

License: MIT License

TypeScript 94.32% JavaScript 5.68%

dxf's Introduction

DXF (๐Ÿงฉ Still under development ๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป)

CircleCI> Language grade: JavaScript GitHub issues npm version GitHub license FOSSA Status

๐ŸŒŸ A simple JavaScript interface to DXF written in TypeScript.

โœ”๏ธ DXF is a JavaScript library, for Nodejs and Browser, it's for creating DXF files in a simple way.

โœจ influenced by ๐Ÿ”— js-dxf.

  • ๐Ÿ”ฅ Now it's supporting AC1021 and above.
  • ๐Ÿ”ฅ Creating minimal dxf content possible.
  • ๐Ÿ”ฅ Tested on ๐Ÿ”— AutoCAD, ๐Ÿ”— LibreCAD and ๐Ÿ”— DWG FastView on mobile.

๐Ÿ—ณ๏ธ Install the package

yarn add @tarikjabiri/dxf
# Or npm
npm i @tarikjabiri/dxf

โŒจ๏ธ Code example

import DXFWriter from '@tarikjabiri/dxf';

const dxf = new DXFWriter();
dxf.setTrueColor(200, 0, 207); // Set the true color.
dxf.addLine(0, 0, 100, 100);
let points = [
    [-300, 0, 0],
    [0, 200, 0],
    [300, 70, 0],
    [700, 100, 0],
    [1000, 1200, 0],
];
dxf.unsetTrueColor(); // Unset the true color.
dxf.addLineType('DOT', '. . . . . . . . . . . . . . . . . .', [0, -4])
    .addLineType(
        'ACAD_ISO11W100',
        '__ __ . __ __ . __ __ .',
        [4, -2, 4, -2, 0, -2]
    )
    .addLineType('DOT2', '.................................', [0, -2])
    .addLineType('DASHED', '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _', [4, -4]);

dxf.addLayer('l_red', DXFWriter.colors.Red, 'DASHED')
    .addLayer('l_green', DXFWriter.colors.Green, 'CONTINUOUS')
    .addLayer('l_cyan', DXFWriter.colors.Cyan, 'CONTINUOUS')
    .addLayer('l_yellow', DXFWriter.colors.Yellow, 'ACAD_ISO11W100');

dxf.setCurrentLayer('l_green')
    .addSpline(points, points, 3, 8, [], [])
    .setCurrentLayer('l_red')
    .addCircle(60, 150, 50)
    .addRectangle(20, 20, 100, 100)
    .setCurrentLayer('l_cyan')
    .addText(30, 30, 10, 'Hello World')
    .addPolyline3D(
        [
            [70, 70, 50],
            [150, 70, 0],
            [170, 170, 150],
        ],
        0
    )
    .addArc(0, 0, 120, 90, 180)
    .addPoint(65, -30, 0)
    .setCurrentLayer('l_yellow')
    .addEllipse(100, 50, 150, 0, 1, 0, 2 * Math.PI)
    .add3DFace(0, 0, 10, 20, 0, 10, 20, -20, 20, 0, -20, 20);
// โœ”๏ธ To get the dxf string just call the stringify() method
const dxfString = dxf.stringify();

For the priview of the example see ๐Ÿ”— examples directory.

โœ”๏ธ Supported entities :

  • ARC
  • CIRCLE
  • ELLIPSE
  • FACE 3D
  • LINE
  • POINT
  • POLYLINE
  • POLYLINE 3D
  • SPLINE
  • TEXT

๐Ÿ’‰ Colors integrated :

  • Red
  • Green
  • Cyan
  • Blue
  • Magenta
  • White
  • Black
  • Yellow

โ„น๏ธ References used in development :

โš–๏ธ License

FOSSA Status

๐Ÿ’ฏ Used by :

  • ๐Ÿ’– My website Mapper.

dxf's People

Contributors

fossabot avatar tarikjabiri 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.