jointjs
Version:
JavaScript diagramming library
20 lines (17 loc) • 1.22 kB
HTML
<p><i>alias:</i> <b>refD</b></p>
<p>Set <code>d</code> attribute of the <code><path></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 not 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 path is translated so that this gap disappears. The rendered path then fits perfectly into the reference element's bounding box.</p>
<pre><code>var Path = joint.dia.Element.define('examples.Path', {
attrs: {
path: {
refDResetOffset: 'M 10 10 30 10 30 30 z', // path offset of 10,10 will be discarded
fill: 'red',
stroke: 'black'
}
}
}, {
markup: 'path'
});
var p = (new Path()).resize(40, 40).addTo(graph);
// the rendered path's `d` attribute will be 'M 0 0 40 0 40 40 z'
// can be obtained by `p.findView(paper).vel.findOne('path').attr('d');`</code></pre>