How can I add class name or other attribute to makerjs model or paths

84 Views Asked by At

I am using makerjs for the svg maker. below example I am adding two lines and polygon shape. below code will create svg with 3 path node under the svg tag.

layer is the id assigned to node. Question here is how can I apply class or custom attributes to path node?

var modelSD: IModel = {
      models: {
        polygon: shape,
        lines: {
          paths: {
            line1: new paths.Line([0, 10], [15, 30]),
            line2: new paths.Line([50, 40], [90, 120]),
          },
          layer:'lines-id'
       },
   },
};

const svg = exporter.toSVG(modelSD, { annotate: true })

i.e. current output is

<svg>  <path id="p1" d="..."/> <path id="p1" d="..."/> <path id="p1" d="..."/> </svg>

Expected should be

<svg>  <path class="custom-lines" id="p1" d="..."/> <path class="custom-lines" id="p1" d="..."/> <path class="custom-lines" id="p1" d="..."/> </svg>
0

There are 0 best solutions below