Tag Info

Hot answers tagged

155

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 ...


73

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); ...


37

I'd build something using Monitor and ProgressIndicator. For example: Monitor[ Table[Pause[0.1]; Prime[i], {i, 100}], Row[{ProgressIndicator[i, {1, 100}], i}, " "] ] This shows a progress indicator while the calculation is underway and then it disappears once the calculation has finished If you look at Jeremy's file progress.m you linked to, ...


34

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 := ...


31

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 ...


28

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 ...


26

Start from {Slider[Dynamic[x], {1, 5, 1}], Dynamic[x]} Next localize control variable: DynamicModule[{x}, {Slider[Dynamic[x], {1, 5, 1}], Dynamic[x]}] And add some interface elements: Panel@DynamicModule[{x}, Column[{Slider[Dynamic[x], {1, 5, 1}], Panel[Dynamic[x], ImageSize -> 200]}]] Add even more Panel@DynamicModule[{x}, ...


25

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 ...


24

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, ...


23

One of the excellent places to look is the Wolfram Demonstration Project. There are many cases with custom controls there. You can test out controls immediately and download the source code. Because I know that site pretty well I will keep the list here. Relief-Shaded Elevation Map 3D Waves Potter's Wheel Motion Blur Contours of Algebraic ...


21

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 ...


21

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}]; ...


19

All palette state (i.e., variables which affect the palette and should be remembered between sessions) should be vectored through the palette's TaggingRules option, and its initialization should be done in the palette's NotebookDynamicExpression option. That, plus context isolation of any kernel functions you need to define should solve all of the points ...


19

Short answer: yes, it is possible. The problem is that parsing is done line-by-line only for the top-level code. For code inside some head(s), it is first parsed as a whole. Therefore, your f is parsed to Global`f, and this is why that symbol is used. Here is what you can do, schematically: DynamicModule[{x = 5}, With[{def = MakeBoxes[f[y_] := y^2 + 1;], ...


19

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 @@ #], #] ...


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]), ...


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

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... ...


17

Maybe you could do something like this SetAttributes[redoButton, HoldRest] redoButton[str_, fun_] := DynamicModule[{result = Null}, Column[{Button[str, result = fun], Dynamic[result]}]] redoButton["press", RandomInteger[20]]


17

Yes, I did something like that and it runs very very nicely. What I implemented is a dynamic Newton fractale visualizer where you can manipulate the number and position of the complex roots, the colours and the gamma correction settings from the Mathematica side. These values are sent to a parallel C++ implementation which calculates the fractale into a ...


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

Use Appearance->SomeGraphicsObject: l = Graphics[{Red, Disk[{0, 0}, .1]}, ImageSize -> 10]; Manipulate[Graphics[{Line[{{0,0},pt}]},PlotRange->2], {{pt,{0,0}},{-2,-2},{2,2},Locator,Appearance->l}] You can use any Graphics or Graphics3D object for this, i.e.: l = Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]}, ImageSize -> 20]; ...


16

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


16

A reliable composition of elements Perhaps something like this? (Edit: Fixed to work with Autorun.) Note that the InputField label is editable, similar to a normal Manipulator. One can also add an additional InputField[Dynamic @ x] if a regular InputField is desired. Manipulate[ x, {{x, 1.}, 1., 100., Row[{Slider[Dynamic[Log10[#], (x = 10^#) &], ...


15

You could do create a simple graph editing tool to create a graph from scratch by doing something like this. To add edges you just click and drag. DynamicModule[{pt1, pt2, ind1, ind2, pts = {}, edges = {}, cedge = {}}, Manipulate[ EventHandler[ Dynamic@Graphics[ {Line[pts[[#]] & /@ edges], cedge, {Red, PointSize[Medium], Point[pts]}}, ...


15

I haven't looked deeper into this but have you tried all the events which you can find in the documentation of GUIKit? Especially here: GUIKit/ref/GUIInformation The list at the bottom contains at least all events you have mentioned: {"Action", "ActionPerformed", "Ancestor", "AncestorAdded", "AncestorMoved", "AncestorRemoved", "AncestorResized", ...


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

I believe the easiest way to accomplish this is with Manipulate. Manipulate[ InteractiveTradingChart[ FinancialData[ticker, "OHLCV", {{2008, 7, 3}, {2008, 9, 30}}]], {ticker, instruments}]


15

Some you can find in the Documentation Center, like the angular slider in Dynamic's documentation (under Applications), or the ValueThumbSlider in the Advanced Manipulate Functionality section (under Custom Control Appearances). Some you can find in developer packages like the angular slider in the "Experimental`" package: Needs@"Experimental`"; ...


15

This isn't exactly what you asked for, but it might do the trick. This solution allows you to create a number of different shapes (circle, polygon, line, Bezier curve, etc.). To add a shape, press the "New object" button. You can add points to an existing shape by clicking anywhere in the plane. Note that I'm using LocatorAutoCreate -> All instead of ...



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