翻譯|使用教程|編輯:況魚杰|2019-11-21 09:30:16.270|閱讀 236 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學習。本文將會展示如何提示用戶插入和旋轉實體數組。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
問:
在使用VDF的過程中,怎樣才能提示用戶插入和旋轉實體數組?是否存在什么代碼來實現此操作?
答:
這是一個示例,提示用戶設置矩形的寬度和高度以及行和列的數量以及它們之間的邊距。當用戶設置所有這些并單擊按鈕時,陣列將被淹沒,用戶可以根據需要放置并旋轉它。
function array(){ var rectwidth = Number(document.getElementById('width').value); var rectheight = Number(document.getElementById('height').value); var nrows = Number(document.getElementById('rows').value); var ncolums = Number(document.getElementById('colums').value); //set the action line color alha to 0 in order to ruber line to be invisible durring move and rotation var oldcolor = vdcanvas.SetActionLineColor([0, 0, 0, 0]); //empty the existing selection of scriptCommand vdcanvas.scriptCommand.clearSelection(); //begin an undo group to enclose all next commands vdcanvas.scriptCommand.undogroup('begin'); //initially set the origin of the drawing into a big value outside the screen in order the first created items to be invisible and display only the moved objects var origin = [1000000, 1000000, 0]; //additional space between items in array var marginPercent = 0.1; //calculate the column and row distances var colomndist = rectwidth * (1 + marginPercent); var rowdist = rectheight * (1 + marginPercent); //create the objects array in the initial origin for (var r = 0; r < nrows; r++) { for (var c = 0; c < ncolums; c++) { vdcanvas.scriptCommand.rect([[origin[0] + c * colomndist, origin[1] + r * rowdist, 0], rectwidth, rectheight, 0], actionentityadded); } } //add each created item to the scriptCommand selection function actionentityadded(vdraw, entity) { vdcanvas.scriptCommand.parseCommands(['select h_' + entity.HandleId.toString()]); setTimeout(vdcanvas.redraw); } //begin a user move command vdcanvas.scriptCommand.move(origin, null, _rotateCallback); //callback of the move finish that begins a rotate command function _rotateCallback() { if (!vdcanvas.ActiveAction().IsCanceled()) vdcanvas.scriptCommand.rotate(vdcanvas.ActiveAction().ResValue[1], null, _finishCallback); else _finishCallback(); } //finished callback function _finishCallback() { vdcanvas.SetActionLineColor(oldcolor);//restore the action line color vdcanvas.scriptCommand.undogroup('close');//close the undo group if (vdcanvas.ActiveAction().IsCanceled()) {//implement the user cancel (right-click or esc) vdcanvas.scriptCommand.undo();//undo all actions from the group begin setTimeout(vdcanvas.redraw);//post a redraw to refresh clear the screen from created items }//else not need to do anything }
對于以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回復。此系列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。
熱門文章推薦:
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: