dxfjs/writer

Solid Hatching is not working

Closed this issue · 1 comments

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);

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.