dxfjs / writer

A JavaScript dxf generator written in TypeScript.
https://dxf.vercel.app
MIT License
90 stars 17 forks source link

Solid Hatching is not working #42

Closed DeepankarGupta13 closed 1 year ago

DeepankarGupta13 commented 1 year ago

hi sir, Solid hatching is not working, I tried the below code const polyline = new HatchPolylineBoundary(); polyline.add(vertex(0, 0)); polyline.add(vertex(0, 10)); polyline.add(vertex(10, 10)); polyline.add(vertex(10, 0));

const polyline1 = new HatchPolylineBoundary();
polyline1.add(vertex(1, 1));
polyline1.add(vertex(1, 9));
polyline1.add(vertex(9, 9));
polyline1.add(vertex(9, 1));

// const edges = new HatchEdgesTypeData();
// edges.addLineEdgeData(point2d(0, 0), point2d(0, 10000));
// edges.addLineEdgeData(point2d(0, 10000), point2d(10000, 10000));
// edges.addLineEdgeData(point2d(10000, 10000), point2d(10000, 0));
// edges.addLineEdgeData(point2d(10000, 0), point2d(0, 0));

const boundary = new HatchBoundaryPaths();
// Add the defined path
boundary.addPolylineBoundary(polyline, PolylineFlags.External);
boundary.addPolylineBoundary(polyline1, PolylineFlags.Outermost);

const mysolid = pattern({
    name: HatchPredefinedPatterns.SOLID,
    // scale: 0.05,
    // angle: 287.89,
    // Other properties you can define optionally
    // angle?: number;
    // scale?: number;
    // double?: boolean;
});

const hatch = dxf.addHatch(boundary, mysolid);
divya-shiv-pandey commented 1 year ago

Those looking for a workaround, you can use gradient. Set both colors to same color and Walla! It doesn't seem to support custom colors or even pre-defined colors, for gradient.