zyy-engine

图形引擎API


图元吸附

<h1>图元吸附</h1> <h2>简要描述</h2> <p>设置图元吸附功能,可以让鼠标事件与图形元素相互作用,使鼠标点吸附到最近的图元上。</p> <h2>接口</h2> <p><code>openPointSnap(event)</code></p> <h3>成员</h3> <table> <thead> <tr> <th>参数名</th> <th>必选</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>event</td> <td>是</td> <td>object</td> <td>鼠标事件对象,包含鼠标移动时的相关信息。</td> </tr> </tbody> </table> <h3>示例</h3> <pre><code class="language-javascript">let viewer2DConfig = new BCore.Viewer.Viewer2DConfig(); mViewer2D = new BCore.Viewer.Viewer2D('bcorecontainer-2d', viewer2DConfig); document.addEventListener('mousemove', (e) =&amp;gt; { const result = mViewer2D.openPointSnap(e); console.log(result); });</code></pre> <h3>返回值说明</h3> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>mindistanceLine</td> <td>number[]</td> <td>距事件点最近的线点坐标数组,每三个数表示一个坐标。</td> </tr> <tr> <td>mousepoint</td> <td>number[]</td> <td>事件点吸附的坐标,若未吸附则返回鼠标当前位置。</td> </tr> </tbody> </table> <hr />

页面列表

ITEM_HTML