在Mathematica中使用Manipulate移动对象

问题描述:

我想创建一个小游戏,用户只需用鼠标移动一些图像即可创建一些形状。在Mathematica中使用Manipulate移动对象

我在Karl Scherer的Nutts Puzzle演示中发现了这种可能性。

但是看看源代码,我无法弄清楚哪个部分可以用鼠标操纵形状。

enter image description here

的最后一个控制语句在操纵是

{{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}] 

Girls on Cos

加分点:名称中的 “TestImage” 案例数据 “女孩” S。 ...

+0

非常感谢您的解释,现在它是有道理的。你知道我是否可以使用定位器与图像。图像不是图形原始图像? – 500 2011-06-10 13:23:54

+0

@ 500:您必须使用['Inset'](http://reference.wolfram.com/mathematica/ref/Inset.html)将图像放置在'Graphics'中。 “Inset”的位置可以像任何其他图形对象一样附加到“Locator”。 – Simon 2011-06-10 13:30:53

+0

我放弃了我需要工作,但我相信解决方案在某处:http://www.hecklerspra​​y.com/the-26-hottest-star-trek-babes/200816466.php或在这里http:// allyourtrekarebelongto.us/toswomen.htm;) – 500 2011-06-10 14:21:57

例如,这个

Manipulate[Graphics[Disk[p, .2], PlotRange \[Rule] {{0, 10}, {0, 10}}], 
    {{p, {.2, 1.5}}, Locator, Appearance \[Rule] None}] 

显示一个圆圈;当你点击某处时,圆圈跳到那里。这是否回答这个问题?

+0

谢谢!有没有一种方法来操纵图像没有图形?图像看起来不是图形原始的...... – 500 2011-06-10 13:22:35

+0

@ 500是的,西蒙描述的方式。也许发布你的问题的玩具版本? – acl 2011-06-10 13:43:33

+0

是的,我会尽快发布web.mathematica或通过示范项目尽快因为我有一些像样的东西很快有希望显示! – 500 2011-06-10 13:49:17