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


29

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


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


24

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


21

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


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

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


17

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


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

You do not need to export an applet to be able to share things with non-Mathematica users. If you save your stuff as a CDF then other non-Mathematica people will be able to use it both on their desktops or view it in webpages (if you choose to embed your CDFs in a webpage). You can do this via File > Deploy See also ref/format/CDF in the documentation ...


15

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


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

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


14

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


14

I wouldn't call it a bug, and is in fact, the expected behaviour (at least, I expect it). Look at it this way — when you input a String or a Number, Mathematica doesn't need to interpret it/evaluate it and can readily display the value dynamically. On the other hand, with an Expression, it needs to know that you have finished entering the expression and it ...


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

What you want to do (make this piece of GUI resistant to kernel quits) can be achieved simply like this: DynamicModule[ {x = True, tag = Unique[StringJoin["g", ToString[ $SessionID]]]}, CreateDocument[{"hello"}, TaggingRules -> tag, Visible -> True]; Checkbox[Dynamic[x, (x = #1; TrueQ[Select[Notebooks[], ...


13

If you control the launch of the main evaluation process, then a very simple way is to wrap your code in a dynamic environment (Block), which would set some flag: mainEvaluationOngoingQ[] := TrueQ@mainEvaluationQ Block[{mainEvaluationQ = True}, Do[i^2, {i, 1, 10^8}]] You can automate this by creating an environment: SetAttributes[withMainEvaluation, ...


13

If you want the user to have absolute control over updates...say, by having an explicit Update button, then you can do so by adding an independent variable to control the updating and changing your Dynamic so that it only tracks that variable. Here, I introduce a variable update, which is an integer. Its value and type don't matter...what matter is that the ...


13

This is basically the same as what b.gatessucks is doing. The main addition is that I've put all the locators in one list. To add vertices to the polygon you just click somewhere on the graph. I've also added a reset button and a button that prints the indices of the points inside the polygon which makes it easier to copy. points = RandomSample[ ...



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