June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,41 @@
property _sum
property _func
property _timeLast
property _valueLast
property _ms0
property _updateTimer
on new (me, func)
if voidP(func) then func = "0.0"
me._sum = 0.0
-- update frequency: 100/sec (arbitrary)
me._updateTimer = timeout().new("update", 10, #_update, me)
me.input(func)
return me
end
on stop (me)
me._updateTimer.period = 0 -- deactivates timer
end
-- func is a term (as string) that might contain "t" and is evaluated at runtime
on input (me, func)
me._func = func
me._ms0 = _system.milliseconds
me._timeLast = 0.0
t = 0.0
me._valueLast = value(me._func)
end
on output (me)
return me._sum
end
on _update (me)
now = _system.milliseconds - me._ms0
t = now/1000.0
val = value(me._func)
me._sum = me._sum + (me._valueLast+val)*(t - me._timeLast)/2
me._timeLast = t
me._valueLast = val
end

View file

@ -0,0 +1,19 @@
global gIntegrator
-- entry point
on startMovie
gIntegrator = script("Integrator").new("sin(PI * t)")
timeout().new("timer", 2000, #step1)
end
on step1 (_, timer)
gIntegrator.input("0.0")
timer.timeoutHandler = #step2
timer.period = 500
end
on step2 (_, timer)
gIntegrator.stop()
put gIntegrator.output()
timer.forget()
end