agt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +7 -0
- data/README.md +5 -0
- data/app/assets/javascripts/agt/config.coffee +9 -0
- data/app/assets/javascripts/agt/dom.coffee +12 -0
- data/app/assets/javascripts/agt/function.coffee +317 -0
- data/app/assets/javascripts/agt/geom/circle.coffee +338 -0
- data/app/assets/javascripts/agt/geom/cubic_bezier.coffee +37 -0
- data/app/assets/javascripts/agt/geom/diamond.coffee +241 -0
- data/app/assets/javascripts/agt/geom/ellipsis.coffee +141 -0
- data/app/assets/javascripts/agt/geom/linear_spline.coffee +56 -0
- data/app/assets/javascripts/agt/geom/matrix.coffee +240 -0
- data/app/assets/javascripts/agt/geom/mixins/geometry.coffee +171 -0
- data/app/assets/javascripts/agt/geom/mixins/intersections.coffee +150 -0
- data/app/assets/javascripts/agt/geom/mixins/path.coffee +145 -0
- data/app/assets/javascripts/agt/geom/mixins/proxyable.coffee +9 -0
- data/app/assets/javascripts/agt/geom/mixins/spline.coffee +329 -0
- data/app/assets/javascripts/agt/geom/mixins/surface.coffee +55 -0
- data/app/assets/javascripts/agt/geom/mixins/triangulable.coffee +112 -0
- data/app/assets/javascripts/agt/geom/point.coffee +454 -0
- data/app/assets/javascripts/agt/geom/polygon.coffee +119 -0
- data/app/assets/javascripts/agt/geom/quad_bezier.coffee +43 -0
- data/app/assets/javascripts/agt/geom/quint_bezier.coffee +42 -0
- data/app/assets/javascripts/agt/geom/rectangle.coffee +599 -0
- data/app/assets/javascripts/agt/geom/spiral.coffee +90 -0
- data/app/assets/javascripts/agt/geom/transformation_proxy.coffee +43 -0
- data/app/assets/javascripts/agt/geom/triangle.coffee +442 -0
- data/app/assets/javascripts/agt/impulse.coffee +105 -0
- data/app/assets/javascripts/agt/index.coffee +56 -0
- data/app/assets/javascripts/agt/inflector/inflection.coffee +21 -0
- data/app/assets/javascripts/agt/inflector/inflections.coffee +75 -0
- data/app/assets/javascripts/agt/inflector/inflector.coffee +235 -0
- data/app/assets/javascripts/agt/inheritance.coffee +132 -0
- data/app/assets/javascripts/agt/math.coffee +45 -0
- data/app/assets/javascripts/agt/mixins/activable.coffee +31 -0
- data/app/assets/javascripts/agt/mixins/aliasable.coffee +25 -0
- data/app/assets/javascripts/agt/mixins/alternate_case.coffee +72 -0
- data/app/assets/javascripts/agt/mixins/cloneable.coffee +71 -0
- data/app/assets/javascripts/agt/mixins/delegation.coffee +90 -0
- data/app/assets/javascripts/agt/mixins/disposable.coffee +7 -0
- data/app/assets/javascripts/agt/mixins/equatable.coffee +37 -0
- data/app/assets/javascripts/agt/mixins/formattable.coffee +52 -0
- data/app/assets/javascripts/agt/mixins/globalizable.coffee +175 -0
- data/app/assets/javascripts/agt/mixins/has_ancestors.coffee +47 -0
- data/app/assets/javascripts/agt/mixins/has_collection.coffee +107 -0
- data/app/assets/javascripts/agt/mixins/has_nested_collection.coffee +51 -0
- data/app/assets/javascripts/agt/mixins/memoizable.coffee +64 -0
- data/app/assets/javascripts/agt/mixins/parameterizable.coffee +101 -0
- data/app/assets/javascripts/agt/mixins/poolable.coffee +62 -0
- data/app/assets/javascripts/agt/mixins/sourcable.coffee +45 -0
- data/app/assets/javascripts/agt/mixins/state_machine.coffee +47 -0
- data/app/assets/javascripts/agt/net/router.coffee +165 -0
- data/app/assets/javascripts/agt/object.coffee +9 -0
- data/app/assets/javascripts/agt/particles/actions/base_action.coffee +7 -0
- data/app/assets/javascripts/agt/particles/actions/die_on_surface.coffee +14 -0
- data/app/assets/javascripts/agt/particles/actions/force.coffee +11 -0
- data/app/assets/javascripts/agt/particles/actions/friction.coffee +14 -0
- data/app/assets/javascripts/agt/particles/actions/live.coffee +9 -0
- data/app/assets/javascripts/agt/particles/actions/macro_action.coffee +13 -0
- data/app/assets/javascripts/agt/particles/actions/move.coffee +11 -0
- data/app/assets/javascripts/agt/particles/actions/null_action.coffee +9 -0
- data/app/assets/javascripts/agt/particles/counters/by_rate.coffee +17 -0
- data/app/assets/javascripts/agt/particles/counters/fixed.coffee +9 -0
- data/app/assets/javascripts/agt/particles/counters/null_counter.coffee +9 -0
- data/app/assets/javascripts/agt/particles/emission.coffee +35 -0
- data/app/assets/javascripts/agt/particles/emitters/null_emitter.coffee +7 -0
- data/app/assets/javascripts/agt/particles/emitters/path.coffee +10 -0
- data/app/assets/javascripts/agt/particles/emitters/ponctual.coffee +9 -0
- data/app/assets/javascripts/agt/particles/emitters/surface.coffee +10 -0
- data/app/assets/javascripts/agt/particles/initializers/explosion.coffee +19 -0
- data/app/assets/javascripts/agt/particles/initializers/life.coffee +16 -0
- data/app/assets/javascripts/agt/particles/initializers/macro_initializer.coffee +10 -0
- data/app/assets/javascripts/agt/particles/initializers/null_initializer.coffee +7 -0
- data/app/assets/javascripts/agt/particles/initializers/particle_sub_system.coffee +12 -0
- data/app/assets/javascripts/agt/particles/initializers/stream.coffee +20 -0
- data/app/assets/javascripts/agt/particles/mixins/randomizable.coffee +10 -0
- data/app/assets/javascripts/agt/particles/particle.coffee +32 -0
- data/app/assets/javascripts/agt/particles/sub_system.coffee +11 -0
- data/app/assets/javascripts/agt/particles/system.coffee +103 -0
- data/app/assets/javascripts/agt/particles/timers/instant.coffee +11 -0
- data/app/assets/javascripts/agt/particles/timers/limited.coffee +19 -0
- data/app/assets/javascripts/agt/particles/timers/null_timer.coffee +11 -0
- data/app/assets/javascripts/agt/particles/timers/unlimited.coffee +9 -0
- data/app/assets/javascripts/agt/particles/timers/until_death.coffee +11 -0
- data/app/assets/javascripts/agt/promise.coffee +214 -0
- data/app/assets/javascripts/agt/random/random.coffee +100 -0
- data/app/assets/javascripts/agt/random/seeds/lagged_fibonnacci.coffee +53 -0
- data/app/assets/javascripts/agt/random/seeds/linear.coffee +16 -0
- data/app/assets/javascripts/agt/random/seeds/linear_congruential.coffee +23 -0
- data/app/assets/javascripts/agt/random/seeds/math_random.coffee +9 -0
- data/app/assets/javascripts/agt/random/seeds/mersenne_twister.coffee +42 -0
- data/app/assets/javascripts/agt/random/seeds/no_random.coffee +12 -0
- data/app/assets/javascripts/agt/random/seeds/paul_houle.coffee +19 -0
- data/app/assets/javascripts/agt/signal.coffee +272 -0
- data/app/assets/javascripts/agt/sprites/animation.coffee +13 -0
- data/app/assets/javascripts/agt/sprites/sprite.coffee +30 -0
- data/app/assets/javascripts/agt/widgets/hash.coffee +36 -0
- data/app/assets/javascripts/agt/widgets/widgets.coffee +194 -0
- data/app/assets/javascripts/agt/widgets/widgets/checked_input.coffee +7 -0
- data/app/assets/javascripts/agt/widgets/widgets/focus_bubbling.coffee +15 -0
- data/lib/agt.rb +8 -0
- data/lib/agt/version.rb +5 -0
- metadata +173 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
namespace('agt.particles.timers')
|
2
|
+
# Public:
|
3
|
+
class agt.particles.timers.Limited
|
4
|
+
|
5
|
+
### Public ###
|
6
|
+
|
7
|
+
constructor: (@duration=1000, @since=0) ->
|
8
|
+
@time = 0
|
9
|
+
@nextTime = 0
|
10
|
+
|
11
|
+
prepare: (bias, biasInSeconds, time) ->
|
12
|
+
unless @firstTime
|
13
|
+
@nextTime = @since + bias
|
14
|
+
@firstTime = true
|
15
|
+
else
|
16
|
+
@nextTime = bias
|
17
|
+
@time += bias
|
18
|
+
|
19
|
+
finished: -> @time >= @duration
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# Public: A lightweight implementation of promises.
|
2
|
+
class agt.Promise
|
3
|
+
|
4
|
+
### Public ###
|
5
|
+
|
6
|
+
# Returns an already fulfilled promise with the passed-in `value`.
|
7
|
+
#
|
8
|
+
# value - The promise's value.
|
9
|
+
#
|
10
|
+
# Returns a [Promise]{agt.Promise}.
|
11
|
+
@unit: (value=0) ->
|
12
|
+
new agt.Promise -> value
|
13
|
+
|
14
|
+
# Returns a promise that is fulfilled when all the passed-in have been
|
15
|
+
# fulfilled. The value of all the promised are provided in the returned
|
16
|
+
# promise value.
|
17
|
+
# If one of the promises fails, the returned promise is rejected.
|
18
|
+
#
|
19
|
+
# promises - An {Array} of promises
|
20
|
+
#
|
21
|
+
# Returns a [Promise]{agt.Promise}.
|
22
|
+
@all: (promises) ->
|
23
|
+
promise = new agt.Promise
|
24
|
+
solved = 0
|
25
|
+
results = []
|
26
|
+
|
27
|
+
promises.forEach (p ,i) ->
|
28
|
+
p
|
29
|
+
.then (value) ->
|
30
|
+
solved++
|
31
|
+
results[i] = value
|
32
|
+
promise.resolve results if solved is promises.length
|
33
|
+
|
34
|
+
.fail (reason) ->
|
35
|
+
promise.reject reason
|
36
|
+
|
37
|
+
promise
|
38
|
+
|
39
|
+
# Creates a new Promise.
|
40
|
+
#
|
41
|
+
# factory - The {Function} to call to resolve the created promise.
|
42
|
+
constructor: (@factory) ->
|
43
|
+
@pending = true
|
44
|
+
@started = false
|
45
|
+
@fulfilled = null
|
46
|
+
@value = undefined
|
47
|
+
@timeout = 60000
|
48
|
+
@message = 'Timed out'
|
49
|
+
|
50
|
+
@fulfilledHandlers = []
|
51
|
+
@errorHandlers = []
|
52
|
+
@progressHandlers = []
|
53
|
+
|
54
|
+
# Returns `true` if the promise has not been resolved.
|
55
|
+
#
|
56
|
+
# Returns a {Boolean}.
|
57
|
+
isPending: -> @pending
|
58
|
+
|
59
|
+
# Returns `true` if the promise has been resolved.
|
60
|
+
#
|
61
|
+
# Returns a {Boolean}.
|
62
|
+
isResolved: -> not @pending
|
63
|
+
|
64
|
+
# Returns `true` if the promise has been resolved successfully.
|
65
|
+
#
|
66
|
+
# Returns a {Boolean}.
|
67
|
+
isFulfilled: -> not @pending and @fulfilled
|
68
|
+
|
69
|
+
# Returns `true` if the promise has been resolved by a rejection.
|
70
|
+
#
|
71
|
+
# Returns a {Boolean}.
|
72
|
+
isRejected: -> not @pending and not @fulfilled
|
73
|
+
|
74
|
+
# Registers callbacks to the promise and returns a new Promise that will
|
75
|
+
# be resolved after the `fulfilledHandler` has been called.
|
76
|
+
#
|
77
|
+
# fulfilledHandler - The {Function} to call when the current promise
|
78
|
+
# is fulfilled.
|
79
|
+
# errorHandler - The {Function} to call when the current promise has been
|
80
|
+
# rejected.
|
81
|
+
# progressHandler - The {Function} to call during the promise progress.
|
82
|
+
# Note that not all the promise provides informations
|
83
|
+
# about their progress.
|
84
|
+
#
|
85
|
+
# Returns a [Promise]{agt.Promise}
|
86
|
+
then: (fulfilledHandler, errorHandler, progressHandler) ->
|
87
|
+
@start() unless @started
|
88
|
+
promise = new agt.Promise
|
89
|
+
f = (value)->
|
90
|
+
try
|
91
|
+
res = fulfilledHandler? value
|
92
|
+
catch err
|
93
|
+
promise.reject err
|
94
|
+
return
|
95
|
+
|
96
|
+
if res?.then?
|
97
|
+
res
|
98
|
+
.then (value) ->
|
99
|
+
promise.resolve value
|
100
|
+
.fail (reason) ->
|
101
|
+
promise.reject reason
|
102
|
+
else
|
103
|
+
promise.resolve res
|
104
|
+
|
105
|
+
e = (reason) ->
|
106
|
+
errorHandler? reason
|
107
|
+
promise.reject reason
|
108
|
+
|
109
|
+
if @pending
|
110
|
+
@fulfilledHandlers.push f
|
111
|
+
@errorHandlers.push e
|
112
|
+
@progressHandlers.push progressHandler if progressHandler?
|
113
|
+
else
|
114
|
+
if @fulfilled
|
115
|
+
f @value
|
116
|
+
else
|
117
|
+
e @reason
|
118
|
+
|
119
|
+
promise
|
120
|
+
|
121
|
+
# Registers a callback for the rejection of the promise.
|
122
|
+
# It's just an alias of:
|
123
|
+
#
|
124
|
+
# ```coffee
|
125
|
+
# promise.then((->), errorHandler)
|
126
|
+
# ```
|
127
|
+
#
|
128
|
+
# errorHandler - The {Function} to call when the current promise has been
|
129
|
+
# rejected.
|
130
|
+
#
|
131
|
+
# Returns a [Promise]{agt.Promise}.
|
132
|
+
fail: (errorHandler) -> @then (->), errorHandler
|
133
|
+
|
134
|
+
# Binds the passed-in promise to this one so that the promise
|
135
|
+
# is resolved when this promise resolved and hold the same value
|
136
|
+
# or reason of the rejection.
|
137
|
+
#
|
138
|
+
# promise - The [Promise]{agt.Promise} to bind to this promise resolution.
|
139
|
+
#
|
140
|
+
# Returns a [Promise]{agt.Promise}.
|
141
|
+
bind: (promise) ->
|
142
|
+
@then ((res) -> promise.resolve(res)), ((reason) -> promise.reject(reason))
|
143
|
+
|
144
|
+
# Resolves the current promise as fulfilled with the given `value`.
|
145
|
+
#
|
146
|
+
# value - The value to fulfill the promise with.
|
147
|
+
resolve: (@value) ->
|
148
|
+
return unless @pending
|
149
|
+
|
150
|
+
@fulfilled = true
|
151
|
+
@notifyHandlers()
|
152
|
+
@pending = false
|
153
|
+
|
154
|
+
# Resolves the current promise with a rejection.
|
155
|
+
#
|
156
|
+
# reason - The reason for the rejection.
|
157
|
+
reject: (reason) ->
|
158
|
+
return unless @pending
|
159
|
+
|
160
|
+
@reason = reason
|
161
|
+
@fulfilled = false
|
162
|
+
@pending = false
|
163
|
+
@notifyHandlers()
|
164
|
+
|
165
|
+
# Starts the promise by calling its factory function if one was provided.
|
166
|
+
start: ->
|
167
|
+
return if @started
|
168
|
+
|
169
|
+
if @factory?
|
170
|
+
try
|
171
|
+
if @signature(@factory).length is 0
|
172
|
+
@resolve(@factory.call this)
|
173
|
+
else
|
174
|
+
lastTime = new Date()
|
175
|
+
|
176
|
+
f = =>
|
177
|
+
@reject new Error @message if new Date() - lastTime >= @timeout
|
178
|
+
setTimeout f, 10 if @pending
|
179
|
+
|
180
|
+
@factory.call(this, this)
|
181
|
+
f()
|
182
|
+
catch e
|
183
|
+
@reject e
|
184
|
+
|
185
|
+
@started = true
|
186
|
+
|
187
|
+
# Setup a hook to reject the promise automatically after a given duration.
|
188
|
+
#
|
189
|
+
# timeout - The {Number} of milliseconds before the promise is rejected.
|
190
|
+
# message - The message {String} to use for the rejection.
|
191
|
+
rejectAfter: (@timeout, @message) ->
|
192
|
+
|
193
|
+
### Internal ###
|
194
|
+
|
195
|
+
# Notifies the different callbacks registered on this promise according
|
196
|
+
# to the promise state.
|
197
|
+
notifyHandlers: ->
|
198
|
+
if @fulfilled
|
199
|
+
handler @value for handler in @fulfilledHandlers
|
200
|
+
else
|
201
|
+
handler @reason for handler in @errorHandlers
|
202
|
+
|
203
|
+
# Returns the signature of the passed-in function.
|
204
|
+
#
|
205
|
+
# func - The {Function} for which return the signature.
|
206
|
+
#
|
207
|
+
# Returns an {Array} of the function arguments.
|
208
|
+
signature: (func) ->
|
209
|
+
re = ///
|
210
|
+
^function
|
211
|
+
(\s+[a-zA-Z_][a-zA-Z0-9_]*)*
|
212
|
+
\s*\(([^\)]+)\)
|
213
|
+
///
|
214
|
+
re.exec(func.toString())?[2].split(/\s*,\s*/) or []
|
@@ -0,0 +1,100 @@
|
|
1
|
+
namespace('agt.random')
|
2
|
+
{floor, round} = Math
|
3
|
+
|
4
|
+
# Public: Create a `Random` object whenever you need randomized values
|
5
|
+
# of various kind. The `Random` class doesn't provides the random generation
|
6
|
+
# itself, it relies on `Seeder` objects, but will use the generated values
|
7
|
+
# to produce a wide range of values.
|
8
|
+
#
|
9
|
+
# ```coffeescript
|
10
|
+
# random = new agt.random.Random(new agt.random.MathRandom)
|
11
|
+
# ```
|
12
|
+
class agt.random.Random
|
13
|
+
@include agt.mixins.Cloneable('generator')
|
14
|
+
@include agt.mixins.Sourcable('agt.random.Random','generator')
|
15
|
+
@include agt.mixins.Formattable('Random','generator')
|
16
|
+
|
17
|
+
### Public ###
|
18
|
+
|
19
|
+
constructor: (@generator) ->
|
20
|
+
|
21
|
+
get: -> @generator.get()
|
22
|
+
|
23
|
+
boolean: (rate=0.5) -> rate = 0.5 unless 0 <= rate <= 1; @get() < rate
|
24
|
+
bit: (rate=0.5) -> if @boolean rate then 1 else 0
|
25
|
+
sign: (rate=0.5) -> if @boolean rate then 1 else -1
|
26
|
+
|
27
|
+
char: (arg, rangeEnd) ->
|
28
|
+
[arg, rangeEnd] = ['abcdefghijklmnopqrstuvwxyz', null] unless arg?
|
29
|
+
switch typeof arg
|
30
|
+
when 'string'
|
31
|
+
if typeof rangeEnd is 'string'
|
32
|
+
str = ''
|
33
|
+
for n in [arg.charCodeAt(0)..rangeEnd.charCodeAt(0)]
|
34
|
+
str += String.fromCharCode(n)
|
35
|
+
arg = str
|
36
|
+
|
37
|
+
arg.substr @intRandom(arg.length - 1), 1
|
38
|
+
|
39
|
+
when 'number'
|
40
|
+
if typeof rangeEnd is 'number'
|
41
|
+
n = String.fromCharCode floor @inRange arg, rangeEnd
|
42
|
+
else
|
43
|
+
String.fromCharCode @intRandom arg
|
44
|
+
|
45
|
+
inRange: (a, b, c) ->
|
46
|
+
res = a + @random b - a
|
47
|
+
if typeof c is 'number'
|
48
|
+
r = 1 / c
|
49
|
+
res -= res % c unless floor(res * r) is res * r
|
50
|
+
|
51
|
+
res = floor(res * 1000000000) / 1000000000
|
52
|
+
res
|
53
|
+
|
54
|
+
inArray: (array, ratios, summed) ->
|
55
|
+
if array?
|
56
|
+
if ratios?
|
57
|
+
if ratios.length isnt array.length
|
58
|
+
throw new Error 'array and ratios arrays must have the same length'
|
59
|
+
if summed
|
60
|
+
for b,i in ratios
|
61
|
+
if i > 0
|
62
|
+
a = ratios[i-1]
|
63
|
+
if a > b
|
64
|
+
throw new Error 'ratios must be ordered when summed is true'
|
65
|
+
|
66
|
+
if summed
|
67
|
+
last = ratios[ratios.length-1]
|
68
|
+
ratios = ratios.map (n) -> n / last
|
69
|
+
else
|
70
|
+
sum = ratios.reduce (a, b) -> a + b
|
71
|
+
ratios = ratios.map (n) -> n / sum
|
72
|
+
ratios[i] += ratios[i-1] for n,i in ratios when i > 0
|
73
|
+
|
74
|
+
rand = @get()
|
75
|
+
return array[i] for v,i in ratios when rand <= v
|
76
|
+
else
|
77
|
+
array[@intRandom array.length - 1]
|
78
|
+
else
|
79
|
+
null
|
80
|
+
|
81
|
+
in: (a, b, c) ->
|
82
|
+
if arguments.length > 3 then @inArray arguments
|
83
|
+
else
|
84
|
+
switch typeof a
|
85
|
+
when 'number' then @inRange a, b
|
86
|
+
when 'string' then @inArray a, b, c
|
87
|
+
when 'object'
|
88
|
+
if Object::toString.call(a) == '[object Array]'
|
89
|
+
@inArray a, b, c
|
90
|
+
else
|
91
|
+
if a.min? and a.max? then @inRange a.min, a.max, a.step
|
92
|
+
else null
|
93
|
+
|
94
|
+
sort: -> => @intPad 2
|
95
|
+
|
96
|
+
random: (amount) -> @get() * (amount or 1)
|
97
|
+
intRandom: (amount) -> round @random amount
|
98
|
+
|
99
|
+
pad: (amount) -> amount / 2 - @random amount
|
100
|
+
intPad: (amount) -> round @pad amount
|
@@ -0,0 +1,53 @@
|
|
1
|
+
namespace('agt.random')
|
2
|
+
# Public:
|
3
|
+
class agt.random.LaggedFibonnacci
|
4
|
+
@include agt.mixins.Cloneable('seed')
|
5
|
+
@include agt.mixins.Sourcable('chancejs.LaggedFibonnacci','seed')
|
6
|
+
@include agt.mixins.Formattable('LaggedFibonnacci','seed')
|
7
|
+
|
8
|
+
### Public ###
|
9
|
+
|
10
|
+
constructor: (seed=0) ->
|
11
|
+
@plantSeed seed
|
12
|
+
|
13
|
+
get: ->
|
14
|
+
uni = @u[@i97] - @u[@j97]
|
15
|
+
uni += 1.0 if uni < 0.0
|
16
|
+
|
17
|
+
@u[@i97] = uni
|
18
|
+
|
19
|
+
@i97 = 96 if --@i97 < 0
|
20
|
+
@j97 = 96 if --@j97 < 0
|
21
|
+
@c -= @cd
|
22
|
+
@c += @cm if @c < 0.0
|
23
|
+
uni -= @c
|
24
|
+
uni += 1.0 if uni < 0.0
|
25
|
+
uni
|
26
|
+
|
27
|
+
plantSeed:(seed=0) ->
|
28
|
+
@u = new Array 97
|
29
|
+
ij = seed / 30082
|
30
|
+
kl = seed - 30082 * ij
|
31
|
+
|
32
|
+
i = ((ij / 177) % 177) + 2
|
33
|
+
j = (ij % 177) + 2
|
34
|
+
k = ((kl / 169) % 178) + 1
|
35
|
+
l = kl % 169
|
36
|
+
|
37
|
+
for ii in [0..96]
|
38
|
+
[s,t] = [0.0, 0.5]
|
39
|
+
|
40
|
+
for jj in [0..23]
|
41
|
+
m = (((i * j) % 179) * k) % 179
|
42
|
+
[i,j,k] = [j,k,m]
|
43
|
+
l = (53 * l + 1) % 169
|
44
|
+
s += t if (l * m) % 64 >= 32
|
45
|
+
t *= 0.5
|
46
|
+
|
47
|
+
@u[ii] = s
|
48
|
+
|
49
|
+
@c = 362436.0 / 16777216.0
|
50
|
+
@cd = 7654321.0 / 16777216.0
|
51
|
+
@cm = 16777213.0 / 16777216.0
|
52
|
+
@i97 = 96
|
53
|
+
@j97 = 32
|
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace('agt.random')
|
2
|
+
# Public:
|
3
|
+
class agt.random.Linear
|
4
|
+
@include agt.mixins.Cloneable('step')
|
5
|
+
@include agt.mixins.Sourcable('chancejs.Linear','step')
|
6
|
+
@include agt.mixins.Formattable('Linear','step')
|
7
|
+
|
8
|
+
### Public ###
|
9
|
+
|
10
|
+
constructor: (@step=1000000000) ->
|
11
|
+
@iterator = 0
|
12
|
+
|
13
|
+
get: ->
|
14
|
+
res = @iterator++ / @step
|
15
|
+
@iterator = 0 if @iterator > @step
|
16
|
+
res
|