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