OLD | NEW |
| (Empty) |
1 var math; | |
2 (function(exports) { | |
3 'use strict'; | |
4 class _JenkinsSmiHash extends core.Object { | |
5 static combine(hash, value) { | |
6 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); | |
7 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) <<
10); | |
8 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; | |
9 } | |
10 static finish(hash) { | |
11 hash = 536870911 & dart.notNull(hash) + ((67108863 & dart.notNull(hash)) <
< 3); | |
12 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 11; | |
13 return 536870911 & dart.notNull(hash) + ((16383 & dart.notNull(hash)) << 1
5); | |
14 } | |
15 static hash2(a, b) { | |
16 return finish(combine(combine(0, dart.as(a, core.int)), dart.as(b, core.in
t))); | |
17 } | |
18 static hash4(a, b, c, d) { | |
19 return finish(combine(combine(combine(combine(0, dart.as(a, core.int)), da
rt.as(b, core.int)), dart.as(c, core.int)), dart.as(d, core.int))); | |
20 } | |
21 } | |
22 let Point$ = dart.generic(function(T) { | |
23 class Point extends core.Object { | |
24 Point(x, y) { | |
25 this.x = x; | |
26 this.y = y; | |
27 } | |
28 toString() { | |
29 return `Point(${this.x}, ${this.y})`; | |
30 } | |
31 ['=='](other) { | |
32 if (!dart.is(other, Point)) | |
33 return false; | |
34 return dart.notNull(dart.equals(this.x, dart.dload(other, 'x'))) && dart
.notNull(dart.equals(this.y, dart.dload(other, 'y'))); | |
35 } | |
36 get hashCode() { | |
37 return _JenkinsSmiHash.hash2(this.x.hashCode, this.y.hashCode); | |
38 } | |
39 ['+'](other) { | |
40 return new Point(dart.as(this.x['+'](other.x), T), dart.as(this.y['+'](o
ther.y), T)); | |
41 } | |
42 ['-'](other) { | |
43 return new Point(dart.as(this.x['-'](other.x), T), dart.as(this.y['-'](o
ther.y), T)); | |
44 } | |
45 ['*'](factor) { | |
46 return new Point(dart.as(this.x['*'](factor), T), dart.as(this.y['*'](fa
ctor), T)); | |
47 } | |
48 get magnitude() { | |
49 return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*']
(this.y))); | |
50 } | |
51 distanceTo(other) { | |
52 let dx = this.x['-'](other.x); | |
53 let dy = this.y['-'](other.y); | |
54 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar
t.notNull(dy)); | |
55 } | |
56 squaredDistanceTo(other) { | |
57 let dx = this.x['-'](other.x); | |
58 let dy = this.y['-'](other.y); | |
59 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) *
dart.notNull(dy), T); | |
60 } | |
61 } | |
62 return Point; | |
63 }); | |
64 let Point = Point$(dart.dynamic); | |
65 class Random extends core.Object { | |
66 Random(seed) { | |
67 if (seed === void 0) | |
68 seed = null; | |
69 return seed === null ? new _JSRandom() : new _Random(seed); | |
70 } | |
71 } | |
72 let _RectangleBase$ = dart.generic(function(T) { | |
73 class _RectangleBase extends core.Object { | |
74 _RectangleBase() { | |
75 } | |
76 get right() { | |
77 return dart.as(this.left['+'](this.width), T); | |
78 } | |
79 get bottom() { | |
80 return dart.as(this.top['+'](this.height), T); | |
81 } | |
82 toString() { | |
83 return `Rectangle (${this.left}, ${this.top}) ${this.width} x ${this.hei
ght}`; | |
84 } | |
85 ['=='](other) { | |
86 if (!dart.is(other, Rectangle)) | |
87 return false; | |
88 return dart.notNull(dart.equals(this.left, dart.dload(other, 'left'))) &
& dart.notNull(dart.equals(this.top, dart.dload(other, 'top'))) && dart.notNull(
dart.equals(this.right, dart.dload(other, 'right'))) && dart.notNull(dart.equals
(this.bottom, dart.dload(other, 'bottom'))); | |
89 } | |
90 get hashCode() { | |
91 return _JenkinsSmiHash.hash4(this.left.hashCode, this.top.hashCode, this
.right.hashCode, this.bottom.hashCode); | |
92 } | |
93 intersection(other) { | |
94 let x0 = max(this.left, other.left); | |
95 let x1 = min(this.left['+'](this.width), other.left['+'](other.width)); | |
96 if (dart.notNull(x0) <= dart.notNull(x1)) { | |
97 let y0 = max(this.top, other.top); | |
98 let y1 = min(this.top['+'](this.height), other.top['+'](other.height))
; | |
99 if (dart.notNull(y0) <= dart.notNull(y1)) { | |
100 return new Rectangle(dart.as(x0, T), dart.as(y0, T), dart.as(dart.no
tNull(x1) - dart.notNull(x0), T), dart.as(dart.notNull(y1) - dart.notNull(y0), T
)); | |
101 } | |
102 } | |
103 return null; | |
104 } | |
105 intersects(other) { | |
106 return dart.notNull(this.left['<='](dart.notNull(other.left) + dart.notN
ull(other.width))) && dart.notNull(other.left) <= dart.notNull(this.left['+'](th
is.width)) && dart.notNull(this.top['<='](dart.notNull(other.top) + dart.notNull
(other.height))) && dart.notNull(other.top) <= dart.notNull(this.top['+'](this.h
eight)); | |
107 } | |
108 boundingBox(other) { | |
109 let right = max(this.left['+'](this.width), other.left['+'](other.width)
); | |
110 let bottom = max(this.top['+'](this.height), other.top['+'](other.height
)); | |
111 let left = min(this.left, other.left); | |
112 let top = min(this.top, other.top); | |
113 return new Rectangle(dart.as(left, T), dart.as(top, T), dart.as(dart.not
Null(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.notNul
l(top), T)); | |
114 } | |
115 containsRectangle(another) { | |
116 return dart.notNull(this.left['<='](another.left)) && dart.notNull(this.
left['+'](this.width)) >= dart.notNull(another.left) + dart.notNull(another.widt
h) && dart.notNull(this.top['<='](another.top)) && dart.notNull(this.top['+'](th
is.height)) >= dart.notNull(another.top) + dart.notNull(another.height); | |
117 } | |
118 containsPoint(another) { | |
119 return core.num['>='](another.x, this.left) && dart.notNull(another.x) <
= dart.notNull(this.left['+'](this.width)) && core.num['>='](another.y, this.top
) && dart.notNull(another.y) <= dart.notNull(this.top['+'](this.height)); | |
120 } | |
121 get topLeft() { | |
122 return new Point(this.left, this.top); | |
123 } | |
124 get topRight() { | |
125 return new Point(dart.as(this.left['+'](this.width), T), this.top); | |
126 } | |
127 get bottomRight() { | |
128 return new Point(dart.as(this.left['+'](this.width), T), dart.as(this.to
p['+'](this.height), T)); | |
129 } | |
130 get bottomLeft() { | |
131 return new Point(this.left, dart.as(this.top['+'](this.height), T)); | |
132 } | |
133 } | |
134 return _RectangleBase; | |
135 }); | |
136 let _RectangleBase = _RectangleBase$(dart.dynamic); | |
137 let Rectangle$ = dart.generic(function(T) { | |
138 class Rectangle extends _RectangleBase$(T) { | |
139 Rectangle(left, top, width, height) { | |
140 this.left = left; | |
141 this.top = top; | |
142 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0
: width, T); | |
143 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']())
* 0 : height, T); | |
144 super._RectangleBase(); | |
145 } | |
146 Rectangle$fromPoints(a, b) { | |
147 let left = dart.as(min(a.x, b.x), T); | |
148 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); | |
149 let top = dart.as(min(a.y, b.y), T); | |
150 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); | |
151 return new Rectangle(left, top, width, height); | |
152 } | |
153 } | |
154 dart.defineNamedConstructor(Rectangle, 'fromPoints'); | |
155 return Rectangle; | |
156 }); | |
157 let Rectangle = Rectangle$(dart.dynamic); | |
158 let _width = Symbol('_width'); | |
159 let _height = Symbol('_height'); | |
160 let MutableRectangle$ = dart.generic(function(T) { | |
161 class MutableRectangle extends _RectangleBase$(T) { | |
162 MutableRectangle(left, top, width, height) { | |
163 this.left = left; | |
164 this.top = top; | |
165 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); | |
166 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height,
T); | |
167 super._RectangleBase(); | |
168 } | |
169 MutableRectangle$fromPoints(a, b) { | |
170 let left = dart.as(min(a.x, b.x), T); | |
171 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); | |
172 let top = dart.as(min(a.y, b.y), T); | |
173 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); | |
174 return new MutableRectangle(left, top, width, height); | |
175 } | |
176 get width() { | |
177 return this[_width]; | |
178 } | |
179 set width(width) { | |
180 if (width['<'](0)) | |
181 width = dart.as(_clampToZero(width), T); | |
182 this[_width] = width; | |
183 } | |
184 get height() { | |
185 return this[_height]; | |
186 } | |
187 set height(height) { | |
188 if (height['<'](0)) | |
189 height = dart.as(_clampToZero(height), T); | |
190 this[_height] = height; | |
191 } | |
192 } | |
193 dart.defineNamedConstructor(MutableRectangle, 'fromPoints'); | |
194 return MutableRectangle; | |
195 }); | |
196 let MutableRectangle = MutableRectangle$(dart.dynamic); | |
197 // Function _clampToZero: (num) → num | |
198 function _clampToZero(value) { | |
199 dart.assert(dart.notNull(value) < 0); | |
200 return -dart.notNull(value) * 0; | |
201 } | |
202 let E = 2.718281828459045; | |
203 let LN10 = 2.302585092994046; | |
204 let LN2 = 0.6931471805599453; | |
205 let LOG2E = 1.4426950408889634; | |
206 let LOG10E = 0.4342944819032518; | |
207 let PI = 3.141592653589793; | |
208 let SQRT1_2 = 0.7071067811865476; | |
209 let SQRT2 = 1.4142135623730951; | |
210 // Function min: (num, num) → num | |
211 function min(a, b) { | |
212 if (!dart.is(a, core.num)) | |
213 throw new core.ArgumentError(a); | |
214 if (!dart.is(b, core.num)) | |
215 throw new core.ArgumentError(b); | |
216 if (dart.notNull(a) > dart.notNull(b)) | |
217 return b; | |
218 if (dart.notNull(a) < dart.notNull(b)) | |
219 return a; | |
220 if (typeof b == number) { | |
221 if (typeof a == number) { | |
222 if (a === 0.0) { | |
223 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no
tNull(b); | |
224 } | |
225 } | |
226 if (a === 0 && dart.notNull(b.isNegative) || dart.notNull(b.isNaN)) | |
227 return b; | |
228 return a; | |
229 } | |
230 return a; | |
231 } | |
232 // Function max: (num, num) → num | |
233 function max(a, b) { | |
234 if (!dart.is(a, core.num)) | |
235 throw new core.ArgumentError(a); | |
236 if (!dart.is(b, core.num)) | |
237 throw new core.ArgumentError(b); | |
238 if (dart.notNull(a) > dart.notNull(b)) | |
239 return a; | |
240 if (dart.notNull(a) < dart.notNull(b)) | |
241 return b; | |
242 if (typeof b == number) { | |
243 if (typeof a == number) { | |
244 if (a === 0.0) { | |
245 return dart.notNull(a) + dart.notNull(b); | |
246 } | |
247 } | |
248 if (b.isNaN) | |
249 return b; | |
250 return a; | |
251 } | |
252 if (b === 0 && dart.notNull(a.isNegative)) | |
253 return b; | |
254 return a; | |
255 } | |
256 // Function atan2: (num, num) → double | |
257 function atan2(a, b) { | |
258 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b)); | |
259 } | |
260 // Function pow: (num, num) → num | |
261 function pow(x, exponent) { | |
262 _js_helper.checkNum(x); | |
263 _js_helper.checkNum(exponent); | |
264 return Math.pow(x, exponent); | |
265 } | |
266 // Function sin: (num) → double | |
267 function sin(x) { | |
268 return Math.sin(_js_helper.checkNum(x)); | |
269 } | |
270 // Function cos: (num) → double | |
271 function cos(x) { | |
272 return Math.cos(_js_helper.checkNum(x)); | |
273 } | |
274 // Function tan: (num) → double | |
275 function tan(x) { | |
276 return Math.tan(_js_helper.checkNum(x)); | |
277 } | |
278 // Function acos: (num) → double | |
279 function acos(x) { | |
280 return Math.acos(_js_helper.checkNum(x)); | |
281 } | |
282 // Function asin: (num) → double | |
283 function asin(x) { | |
284 return Math.asin(_js_helper.checkNum(x)); | |
285 } | |
286 // Function atan: (num) → double | |
287 function atan(x) { | |
288 return Math.atan(_js_helper.checkNum(x)); | |
289 } | |
290 // Function sqrt: (num) → double | |
291 function sqrt(x) { | |
292 return Math.sqrt(_js_helper.checkNum(x)); | |
293 } | |
294 // Function exp: (num) → double | |
295 function exp(x) { | |
296 return Math.exp(_js_helper.checkNum(x)); | |
297 } | |
298 // Function log: (num) → double | |
299 function log(x) { | |
300 return Math.log(_js_helper.checkNum(x)); | |
301 } | |
302 let _POW2_32 = 4294967296; | |
303 class _JSRandom extends core.Object { | |
304 _JSRandom() { | |
305 } | |
306 nextInt(max) { | |
307 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32))
{ | |
308 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma
x}`); | |
309 } | |
310 return Math.random() * max >>> 0; | |
311 } | |
312 nextDouble() { | |
313 return Math.random(); | |
314 } | |
315 nextBool() { | |
316 return Math.random() < 0.5; | |
317 } | |
318 } | |
319 let _lo = Symbol('_lo'); | |
320 let _hi = Symbol('_hi'); | |
321 let _nextState = Symbol('_nextState'); | |
322 class _Random extends core.Object { | |
323 _Random(seed) { | |
324 this[_lo] = 0; | |
325 this[_hi] = 0; | |
326 let empty_seed = 0; | |
327 if (dart.notNull(seed) < 0) { | |
328 empty_seed = -1; | |
329 } | |
330 do { | |
331 let low = dart.notNull(seed) & dart.notNull(_Random._MASK32); | |
332 seed = ((dart.notNull(seed) - dart.notNull(low)) / dart.notNull(_POW2_32
)).truncate(); | |
333 let high = dart.notNull(seed) & dart.notNull(_Random._MASK32); | |
334 seed = ((dart.notNull(seed) - dart.notNull(high)) / dart.notNull(_POW2_3
2)).truncate(); | |
335 let tmplow = dart.notNull(low) << 21; | |
336 let tmphigh = dart.notNull(high) << 21 | dart.notNull(low) >> 11; | |
337 tmplow = (~dart.notNull(low) & dart.notNull(_Random._MASK32)) + dart.not
Null(tmplow); | |
338 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
339 high = ~dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmpl
ow) - dart.notNull(low)) / 4294967296).truncate() & dart.notNull(_Random._MASK32
); | |
340 tmphigh = dart.notNull(high) >> 24; | |
341 tmplow = dart.notNull(low) >> 24 | dart.notNull(high) << 8; | |
342 low = tmplow; | |
343 high = tmphigh; | |
344 tmplow = dart.notNull(low) * 265; | |
345 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
346 high = dart.notNull(high) * 265 + ((dart.notNull(tmplow) - dart.notNull(
low)) / 4294967296).truncate() & dart.notNull(_Random._MASK32); | |
347 tmphigh = dart.notNull(high) >> 14; | |
348 tmplow = dart.notNull(low) >> 14 | dart.notNull(high) << 18; | |
349 low = tmplow; | |
350 high = tmphigh; | |
351 tmplow = dart.notNull(low) * 21; | |
352 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
353 high = dart.notNull(high) * 21 + ((dart.notNull(tmplow) - dart.notNull(l
ow)) / 4294967296).truncate() & dart.notNull(_Random._MASK32); | |
354 tmphigh = dart.notNull(high) >> 28; | |
355 tmplow = dart.notNull(low) >> 28 | dart.notNull(high) << 4; | |
356 low = tmplow; | |
357 high = tmphigh; | |
358 tmplow = dart.notNull(low) << 31; | |
359 tmphigh = dart.notNull(high) << 31 | dart.notNull(low) >> 1; | |
360 tmplow = low; | |
361 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
362 high = dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmplo
w) - dart.notNull(low)) / 4294967296).truncate() & dart.notNull(_Random._MASK32)
; | |
363 tmplow = dart.notNull(this[_lo]) * 1037; | |
364 this[_lo] = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
365 this[_hi] = dart.notNull(this[_hi]) * 1037 + ((dart.notNull(tmplow) - da
rt.notNull(this[_lo])) / 4294967296).truncate() & dart.notNull(_Random._MASK32); | |
366 this[_lo] = low; | |
367 this[_hi] = high; | |
368 } while (seed !== empty_seed); | |
369 if (this[_hi] === 0 && this[_lo] === 0) { | |
370 this[_lo] = 23063; | |
371 } | |
372 this[_nextState](); | |
373 this[_nextState](); | |
374 this[_nextState](); | |
375 this[_nextState](); | |
376 } | |
377 [_nextState]() { | |
378 let tmpHi = 4294901760 * dart.notNull(this[_lo]); | |
379 let tmpHiLo = dart.notNull(tmpHi) & dart.notNull(_Random._MASK32); | |
380 let tmpHiHi = dart.notNull(tmpHi) - dart.notNull(tmpHiLo); | |
381 let tmpLo = 55905 * dart.notNull(this[_lo]); | |
382 let tmpLoLo = dart.notNull(tmpLo) & dart.notNull(_Random._MASK32); | |
383 let tmpLoHi = dart.notNull(tmpLo) - dart.notNull(tmpLoLo); | |
384 let newLo = dart.notNull(tmpLoLo) + dart.notNull(tmpHiLo) + dart.notNull(t
his[_hi]); | |
385 this[_lo] = dart.notNull(newLo) & dart.notNull(_Random._MASK32); | |
386 let newLoHi = dart.notNull(newLo) - dart.notNull(this[_lo]); | |
387 this[_hi] = ((dart.notNull(tmpLoHi) + dart.notNull(tmpHiHi) + dart.notNull
(newLoHi)) / dart.notNull(_POW2_32)).truncate() & dart.notNull(_Random._MASK32); | |
388 dart.assert(dart.notNull(this[_lo]) < dart.notNull(_POW2_32)); | |
389 dart.assert(dart.notNull(this[_hi]) < dart.notNull(_POW2_32)); | |
390 } | |
391 nextInt(max) { | |
392 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32))
{ | |
393 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma
x}`); | |
394 } | |
395 if ((dart.notNull(max) & dart.notNull(max) - 1) === 0) { | |
396 this[_nextState](); | |
397 return dart.notNull(this[_lo]) & dart.notNull(max) - 1; | |
398 } | |
399 let rnd32 = null; | |
400 let result = null; | |
401 do { | |
402 this[_nextState](); | |
403 rnd32 = this[_lo]; | |
404 result = rnd32.remainder(max); | |
405 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >=
dart.notNull(_POW2_32)); | |
406 return result; | |
407 } | |
408 nextDouble() { | |
409 this[_nextState](); | |
410 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1; | |
411 this[_nextState](); | |
412 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; | |
413 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not
Null(bits27)) / dart.notNull(_Random._POW2_53_D); | |
414 } | |
415 nextBool() { | |
416 this[_nextState](); | |
417 return (dart.notNull(this[_lo]) & 1) === 0; | |
418 } | |
419 } | |
420 _Random._POW2_53_D = 1.0 * 9007199254740992; | |
421 _Random._POW2_27_D = 1.0 * (1 << 27); | |
422 _Random._MASK32 = 4294967295; | |
423 // Exports: | |
424 exports.Point = Point; | |
425 exports.Point$ = Point$; | |
426 exports.Random = Random; | |
427 exports.Rectangle = Rectangle; | |
428 exports.Rectangle$ = Rectangle$; | |
429 exports.MutableRectangle = MutableRectangle; | |
430 exports.MutableRectangle$ = MutableRectangle$; | |
431 exports.E = E; | |
432 exports.LN10 = LN10; | |
433 exports.LN2 = LN2; | |
434 exports.LOG2E = LOG2E; | |
435 exports.LOG10E = LOG10E; | |
436 exports.PI = PI; | |
437 exports.SQRT1_2 = SQRT1_2; | |
438 exports.SQRT2 = SQRT2; | |
439 exports.min = min; | |
440 exports.max = max; | |
441 exports.atan2 = atan2; | |
442 exports.pow = pow; | |
443 exports.sin = sin; | |
444 exports.cos = cos; | |
445 exports.tan = tan; | |
446 exports.acos = acos; | |
447 exports.asin = asin; | |
448 exports.atan = atan; | |
449 exports.sqrt = sqrt; | |
450 exports.exp = exp; | |
451 exports.log = log; | |
452 })(math || (math = {})); | |
OLD | NEW |