文档彩票走势图>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(三十九):如何提示用户插入和旋转实体数组?
VDF常见问题整理(三十九):如何提示用户插入和旋转实体数组?
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微信公众号 ???,了解产品的最新动态及最新资讯。