Tag Info

Hot answers tagged

110

Well, the answer seems to be YES :) Here is my implementation of Minecraft classic game in Mathematica. Let’s start with some screenshots which were taken during the construction of the final scene which will be displayed an the end of this post. Features Blocks are creatable and removable One texture per block Player automatically jumps to the ...


47

Since Mathematica does not have a built-in plot manipulating interface, here is a gui of a plot-manipulator. Updates are indicated with bold text. Functionality: Should work with any plot/graphics (ArrayPlot compatibility added); Drag anywhere in plot zooms in to selected rectangle; can be done repeatedly; Ctrl+drag zooms in/out (along vertical axis); ...


27

For this purpose, I wrote a small Symbol Information Palette. This palette let's you quickly look up usages, options and attributes of symbols and was tested on Mac OSX and Linux. Installation The source code is hosted on my GitHub site but to preview or install the palette you only have to evaluate this: Get["http://goo.gl/QPywk"] The link is just ...


27

My simple version using Image: size = 300; r = ListConvolve[DiskMatrix[#], RandomInteger[BernoulliDistribution[0.001], {5 size, size}], {1, 1}] & /@ {1.5, 2, 3}; Dynamic[Image[(r[[#]] = RotateRight[r[[#]], #]) & /@ {1, 2, 3}; Total[r[[All, ;; size]]]]] Update A slightly prettier version, same basic idea but now with flakes. flake := ...


20

Date-picker implementation in Mathematica The following is my implementation of a simple date-picker. The current date is highlighted in LightBlue and the weekends are highlighted in LightGreen. The selected date is always highlighted in LightRed (the default selection is the current date). You can tap into this calendar by using the Dynamic values for ...


20

I happened to create some snowflakes and snow fall a couple weeks back, and its nice to have some place to share with others! First, we create some algorithmically generated snowflakes with some randomness using a kind of iterated function system based off the 6-pointed "star" shown below. H = Table[{Cos[n*Pi/3], Sin[n*Pi/3]}, {n, 0, 5, 1}]; ...


18

I don't like to answer my own question, but to give an idea of what an answer might be here's my first stab at this (in the form of a toolbar), just try running UtilityDock[] and click "Branch" after saving it. (Note: I think the best answer wouldn't make use of a toolbar) UtilityDock := (c = Cell[BoxData[ ToBoxes[Grid[{{Item[ Row[{" ...


18

By specifying different values for time and frequencyInverse, the behavior of flashing can be finetuned. time = 100; frequencyInverse = 4; i = 0; Dynamic@Style["TESTESTEST", Bold, RGBColor[color, 0, 0]] RunScheduledTask[(i = i + 1; color = Rescale[Sin[i/frequencyInverse], {-1, 1}]; If[i == time, RemoveScheduledTask[ScheduledTasks[]]; color = 0]), ...


17

In addition to István's fine answer, there is also Experimental`Explore[] which provides almost all the functionalities in his PlotExplorer. I think it was Szabolcs who first told me of this function. If you call the above function with no arguments, you can choose to interactively work with either Plot, ParametricPlot, Manipulate or Graphics. Alternately, ...


16

Running Trace[Speak["Hello"]] and Names["*Speak*"] revealed the following possibility: MathLink`CallFrontEnd[CurrentlySpeakingPacket] Using this with a text that is split into a list of shorter strings allows you to interrupt the audio at well-defined points, phrase breaks, say. Here is one way to do it: Clear[interruptibleSpeak]; ...


16

Here's a simple way using buttons, for some reason AutoAction is not working so you have to click, anyone know why? nextPos[p_, r_] := {p + # r/2, r/2} & /@ Tuples[{1, -1}, 2] DynamicModule[{diskList = {{ {0, 0}, 1}}}, Graphics[Dynamic[ Button[{ColorData["Rainbow"][Last@#], Disk @@ #}, diskList = DeleteCases[Join[diskList, nextPos @@ #], #] ...


15

There are several things to understand here, but all of them center around a common theme. Exactly what is evaluating, and exactly when? It looks like you're just trying to guess what's going on, but guessing is bad... you really should understand the evaluation model. A: Problems with the code in the question The method in the question would not have ...


15

With an arbitrary locator dependency tree Updated Now the sub-blocks move as one piece (per @RM request). Lets first generate a dependency tree and calculate a few values for future use: (*A dependency graph template*) g[ns_, treeOrder_, data_] := KaryTree[ns, treeOrder, VertexLabels -> Table[i -> Placed[data[[i]] // TableForm, Before], {i, ...


15

My attempt adresses the second option. These are simple falling circles with random shift and color depending on the radius of the "snowflake". snow[n_, {w_, h_}] := DynamicModule[{flakes, cut, offset, drawflake, rmax, mgray = 0.85}, rmax = w/100; drawflake = {GrayLevel[mgray + (1 - mgray) #2], Disk[#1, #2 rmax]} &; offset = cut @@ (#1 + 14 ...


15

If you pass SynchronousUpdating->False to Dynamic, it will perform operations on the main link. Note that this only works where Dynamic is displayed as a typeset result (i.e., typeset as a DynamicBox). It does not presently work where Dynamic is used to give a value to a control (such as Slider) or an option. A quick survey of other constructs... ...


14

As a point of curiosity, I did a quick search in the source code used by Wolfram for various palettes, dialog boxes, and toolbars. About one in eight Dynamic constructs were accompanied by a With. The example you provide is certainly a good one. It illustrates the general principle nicely, but what it doesn't do is to illustrate how widely the general ...


13

I'll post a function based on the title of the question. You wrap your dynamic code in profileDynamics optionally passing the option "Print"->True (defaults to False). It should be noted that this can only profile the explicit Dynamics that are on the code. Nested dynamics that are generated at runtime are not profiled by this ClearAll[profileDynamics]; ...


13

Alternative DynamicModule[{visited = False}, Dynamic@EventHandler[ If[visited, Thread@Translate[#0@#, {1, -1}~Tuples~2]~Scale~ 0.5, {ColorData["Rainbow"]@Random[], #}], "MouseEntered" :> (visited = True)]] &[Disk[]] // Graphics Other version. Works "more or less" fine. Read comments SetAttributes[translateOnHover, ...


13

Start by making some similarity measure of sentences, here I use one that takes number of words in common divided by number of words in longest sentence. The measure is then used to connect sentences that are similar enough in a graph and extracts the connected components: strs = {"Barack Obama", "Barack H. Obama", "Barack Hussein Obama", "Obama ...


12

This solution relies on putting a TagBox with a custom tag around the part to be replaced, reading the cell and replacing the tag, then writing it back. Personally I've always felt that the need to read the entire cell and write it all again seems kind of clunky, but I don't know of a better way to do this. ...


12

I'm not sure if this comes close to what you had in mind, but I hope it helps. Moving a sphere will move the other spheres as well. The distance over which the spheres are moved depends on their strength, the strength of the sphere being moved and the distance between the two spheres. The size of the spheres indicates their strength. The function ...


12

This is not an answer but it's too long for a comment. Also please remember that all the following are just guesses. My first observation is that the simplified Slider[Dynamic[x, (x=#)&], {0, 1, 1/10}] can reproduce the problem. We know that some variables (in particular DynamicModule variables) are owned by the Front End, not the Kernel, and can ...


12

As Silvia notes in the comments, this behaviour is because of the predictive interface that is new in version 9. Mathematica tries to inspect the contents of the output to determine which contextual menu options to show in the suggestions bar depending on whether it is an array of integers/reals/mixed or if it is square/rectangular, etc. My guess is that ...


11

Ah, figured it out: Panel @ DynamicModule[{input = ""}, Column[{TextCell["Enter your text here:"], EventHandler[ InputField[Dynamic[input], String, ContinuousAction -> True, FieldSize -> {40, 7}], "ReturnKeyDown" :> FrontEndExecute[{NotebookWrite[InputNotebook[], "\n", After]}] ], Dynamic@InputForm[input]}]]


11

Does the following work as needed? CreateDialog[ TabView[ {"General" -> Column[{Row[{"Project Name:", InputField[Dynamic[project]]}], Row[{"Number Of Wells:", InputField[Dynamic[num]], Button["Set", DialogReturn[num]]}]}], "Row Selection" -> Dynamic@Column[ Table[Row[{"Well " <> ToString[i] <> ...


11

The problem is that inside the Manipulate, m1 and m2 are replaced with localized versions (as in Module) rather than assigned (as in Block). Since the m1 and m2 from bigA are outside the Manipulate, and bigA[t] is evaluated only after the replacement of m1 and m2 inside the Manipulate, they are not affected by the manipulation. The best solution is to give ...


11

This approach uses a voxel-based snowflake that actually looks quite realistic because of the way Image3D displays data. The set-up is similar to that of Simon, but everything is in 3D. So the calculations will be correspondingly more time-consuming. flakyData = ImageData[ Dilation[ RandomImage[BernoulliDistribution[0.0001], {150, 150, 150}], ...


11

While trying to debug this issue myself, I stumbled across Todd Gayley's name in the source of one of the documentation .m files and contacted him directly. Todd was super great to work with---and at the end of an hour of screensharing he provided an easy workaround. The workaround essentially short-circuits one tiny feature of a normal documentation ...


11

I think I have to explain how I look at Dynamic before I can speak about Refresh. Dynamic is the basic element of dynamic updating, and the only one as far as I can tell. Anything that behaves dynamically has Dynamic somewhere inside it, I believe. If you think of an expression as a tree, then Dynamic[code] marks out the branch representing code for ...


11

You are correct about the behavior of computations done from preemptive links. So-called "preemptive evaluations" have been around since version 6. They are a class of evaluations that all work through the same mechanism. When Mathematica checks to see if a user interrupt has been requested, which it does at a high rate most of the time, it also looks to see ...



Only top voted, non community-wiki answers of a minimum length are eligible