Tag Info

Hot answers tagged

4

shape1 := Graphics[{#, Circle[{0, 0}, 1.5], Disk[]}, ImageSize -> 10] &; shape2 := Graphics[{Lighter@#, Disk[]}, ImageSize -> 10] &; ClearAll[lOF]; lOF[nOfOverlays_, colors_List, opts : OptionsPattern[]] := DynamicModule[{layer = 1, pts = ConstantArray[{{100, 100}, {700, 700}}, nOfOverlays], col = ...


3

When a Symbol is "tracked" it means that when its value changes the Dynamic expression is refreshed, therefore your input updates as fast as possible because every refresh changes the value of t which causes a refresh which... you get the picture. Compare: Clear[t]; t = 1; Dynamic[Refresh[t++, UpdateInterval -> 1, TrackedSymbols -> {}]]


3

The x and y of the ContourPlot are interfering with the x and y inside of Dynamic. If you use for example ContourPlot[Total[Log[Clip[b-a.{x2,y2},{10^-10,\[Infinity]}]]],{x2,-2,2},{y2,-2,2},PlotRange->{-10,0}] it'll not crash. I guess this shouldn't be necessary.


2

simple version With a single codeline, ColorData["Atoms", "Panel"], can be transformed in a click panel for ElementData[]. {ColorData["Atoms", "Panel"] // ReplaceAll[#, RuleDelayed[ "MouseClicked", $_] :> (RuleDelayed["MouseClicked", atomClicked = Part[RuleDelayed["MouseClicked", $], 2, 2, 2, 1, 1, 1]])] &, Dynamic[atomClicked, Initialization :> ...


1

Edit: I got it to crash. :) or :( ? Here's further evidence of a race condition: Putting Pause[1] before the ContourPlot usually seems to fix the problem. Well, it rarely crashes, and I've run it several times, sometimes with a fresh kernel, fresh notebook, sometimes not. I can get it to crash with an absolutely fresh Mathematica session. Increasing the ...


1

From tutorial/InteractiveGraphicsPalette you can see that quite a few of the lowercase keys are used by DrawingTools which becomes active once the cursor focus is on the graphics. So, the easiest work-around is to use uppercase letters in your EventHandler as suggested by pjc42. When the first argument of EventHandler does not contain a graphics object, ...


1

another idea but not an answer... DynamicModule[{keyList = {}, pts = {}, input = Null}, EventHandler[ {LocatorPane[Dynamic[pts], Graphics[Circle[], ImageSize -> 500], LocatorAutoCreate -> True, Appearance -> {Graphics[{Red, Disk[]}, ImageSize -> 10], Graphics[{Blue, Disk[]}, ImageSize -> 10]} (*LocatorPane**)], ...


1

This is only a partial answer but may help. See here for related case, it is probable that KeyDown "a" is reserved like "c". This does not work: DynamicModule[{someList = {}}, EventHandler[Graphics[{Blue, Disk[]}, ImageSize -> 100], {{"KeyDown", "a"} :> (AppendTo[someList, 1]; Print[someList])}]] (** doesn't work **) But changing "a" to ...


1

Refresh only sets a limit on how long expression can go without being updated. To keep t form being updated more often add a pause. t = 1; Dynamic[Refresh[Pause[1]; t++, UpdateInterval -> 1, TrackedSymbols :> {t}]] or do what Mr.Wizard indicated, which is better. But this sort of thing is best done by higher level constructs such as Clock or ...


1

I believe the jump in value of asd happens because you're dragging the indicator with the mouse when the range is reset. Here is a way that does what you want, I think. It interrupts the mouse-dragging by creating a new Slider when the boundary is reached. {Dynamic@asd, Dynamic@Slider[Dynamic[asd], Which[asd < 10, {1, 10}, asd >= 10, {9, 50, ...



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