josklaps1
(Jos Klaps)
June 24, 2014, 7:50pm
1
Dear All
In a number of Wolfram video’s the function MinuteTimer[ ] are used. Why can’t find this in my Mathematica version 9.0.1.0.?
This function is very usefull for time limited presentation.
See video: ‘Build an App in 60 seconds’ (started after 38 sec.)
http://www.wolfram.com/broadcast/search.php?Search=app%20in%2060%20seconds&x=0&y=0&video=827
Thanks.
JosK
mthiel
(Marco Thiel)
June 24, 2014, 9:32pm
2
Dear Josk,
I don’t think that MinuteTimer is a built in function. But perhaps this function might help:
MinuteTimer[] :=
Module[{}, d = 0; t = 0; t = AbsoluteTime[]; RunScheduledTask[d = AbsoluteTime[], {0.1, 600}];
Dynamic[If[(d - t) < 60, PieChart[{60 - (d - t), d - t}, SectorOrigin -> Pi/2., ChartStyle -> {White, Green}],
PieChart[{1, 0}, ChartStyle -> {Red, White}]]]]
You can call it with
MinuteTimer[]
It is quite obvious how to change it to any other time. This is a generalised Timer function:
Timer[seconds_Integer] := Module[{}, d = 0; t = 0; t = AbsoluteTime[];
RunScheduledTask[d = AbsoluteTime[], {0.1, 10*seconds}]; Dynamic[If[(d - t) < seconds,
PieChart[{seconds - (d - t), d - t}, SectorOrigin -> Pi/2., ChartStyle -> {White, Green}],
PieChart[{1, 0}, ChartStyle -> {Red, White}]]]]
You can call it with any number of seconds (needs to be integers!):
Timer[8]
Cheers,
M.
mthiel
(Marco Thiel)
June 24, 2014, 10:09pm
3
Sorry, I just wanted to add that in the video they probably did not use the PieChart function but the common Disk function. In that case the function looks like this (I also deleted the initialisations for t and d):
Timer[seconds_Integer] := Module[{}, t = AbsoluteTime[]; RunScheduledTask[d = AbsoluteTime[], {0.1, 10*seconds}];
Dynamic[If[(d - t) < seconds, Graphics[{Green, Disk[{0, 0}, 1, {Pi/2., Pi/2. - 2. Pi*(d - t)/(seconds)}]}, PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}],
Graphics[{Red, Disk[{0, 0}, 1]}, PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}]]]]
The general idea is the same as before. The animation looks a bit different because it has the black border lines removed.
Cheers,
Marco
josklaps1
(Jos Klaps)
June 25, 2014, 8:40am
4
Hi Marco,
Many thanks for your help. This is what I 'm looking for.
JosK