UNPKG

jointjs

Version:

JavaScript diagramming library

19 lines (16 loc) 1.12 kB
<p>Set <code>d</code> attribute of the <code>&lt;path&gt;</code> subelement relatively to the dimensions and position of the element referenced by the selector in the <code>ref</code> attribute. The <code>refD</code> path data is scaled so that the path's dimensions match the reference element's dimensions, and translated so that the path's origin matches the origin of the reference element.</p> <p>The original path data offset is preserved. This means that if the top-left corner of the <code>refD</code> bounding box does not lie at <code>0,0</code>, the gap between the path and origin is preserved in the rendered shape, as well.</p> <pre><code>var Path = joint.dia.Element.define('examples.Path', { attrs: { path: { refDKeepOffset: 'M 10 10 30 10 30 30 z', // path offset is 10,10 fill: 'red', stroke: 'black' } } }, { markup: 'path' }); var p = (new Path()).resize(40, 40).addTo(graph); // the rendered path's `d` attribute will be 'M 10 10 50 10 50 50 z' // can be obtained by `p.findView(paper).vel.findOne('path').attr('d');`</code></pre>