在Mathematica中使用Manipulate移动对象
问题描述:
我想创建一个小游戏,用户只需用鼠标移动一些图像即可创建一些形状。在Mathematica中使用Manipulate移动对象
我在Karl Scherer的Nutts Puzzle演示中发现了这种可能性。
但是看看源代码,我无法弄清楚哪个部分可以用鼠标操纵形状。
答
的最后一个控制语句在操纵是
{{pts, {{2, 1.5}, ..., {16.1, 16.1}}}, Locator, Appearance -> None},
这使得一种无形Locator在每个多边形的中心。 这些被拾取和移动的鼠标。
上述控件创建2个弹出式菜单和19个旋转滑块。
编辑:为了解决这个评论,使用Inset
一个例子:
g[1]=ExampleData[{"TestImage","Girl"}];
g[2]=ExampleData[{"TestImage","Girl2"}];
g[3]=ExampleData[{"TestImage","Girl3"}];
Manipulate[Plot[Cos[x^n],{x,0,4Pi},
Epilog->Table[Inset[g[i],pos[[i]],{0,0},ImageScaled[{.2,.2}]],{i,3}]],
{{n, 1}, 0, 4},
{{pos,{{0,0},{Pi,0},{2Pi,0}}},Locator,Appearance->None}]
加分点:名称中的 “TestImage” 案例数据 “女孩” S。 ...
答
例如,这个
Manipulate[Graphics[Disk[p, .2], PlotRange \[Rule] {{0, 10}, {0, 10}}],
{{p, {.2, 1.5}}, Locator, Appearance \[Rule] None}]
显示一个圆圈;当你点击某处时,圆圈跳到那里。这是否回答这个问题?
非常感谢您的解释,现在它是有道理的。你知道我是否可以使用定位器与图像。图像不是图形原始图像? – 500 2011-06-10 13:23:54
@ 500:您必须使用['Inset'](http://reference.wolfram.com/mathematica/ref/Inset.html)将图像放置在'Graphics'中。 “Inset”的位置可以像任何其他图形对象一样附加到“Locator”。 – Simon 2011-06-10 13:30:53
我放弃了我需要工作,但我相信解决方案在某处:http://www.hecklerspray.com/the-26-hottest-star-trek-babes/200816466.php或在这里http:// allyourtrekarebelongto.us/toswomen.htm;) – 500 2011-06-10 14:21:57