OLD | NEW |
1 var math = dart.defineLibrary(math, {}); | 1 var math = dart.defineLibrary(math, {}); |
2 var core = dart.import(core); | 2 var core = dart.import(core); |
3 var _js_helper = dart.lazyImport(_js_helper); | 3 var _js_helper = dart.lazyImport(_js_helper); |
4 (function(exports, core, _js_helper) { | 4 (function(exports, core, _js_helper) { |
5 'use strict'; | 5 'use strict'; |
6 class _JenkinsSmiHash extends core.Object { | 6 class _JenkinsSmiHash extends core.Object { |
7 static combine(hash, value) { | 7 static combine(hash, value) { |
8 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); | 8 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); |
9 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) <<
10); | 9 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) <<
10); |
10 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; | 10 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 let right = max(this.left['+'](this.width), other.left['+'](other.width)
); | 139 let right = max(this.left['+'](this.width), other.left['+'](other.width)
); |
140 let bottom = max(this.top['+'](this.height), other.top['+'](other.height
)); | 140 let bottom = max(this.top['+'](this.height), other.top['+'](other.height
)); |
141 let left = min(this.left, other.left); | 141 let left = min(this.left, other.left); |
142 let top = min(this.top, other.top); | 142 let top = min(this.top, other.top); |
143 return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(da
rt.notNull(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.
notNull(top), T)); | 143 return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(da
rt.notNull(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.
notNull(top), T)); |
144 } | 144 } |
145 containsRectangle(another) { | 145 containsRectangle(another) { |
146 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); | 146 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); |
147 } | 147 } |
148 containsPoint(another) { | 148 containsPoint(another) { |
149 return another.x['>='](this.left) && dart.notNull(another.x) <= dart.not
Null(this.left['+'](this.width)) && another.y['>='](this.top) && dart.notNull(an
other.y) <= dart.notNull(this.top['+'](this.height)); | 149 return another.x[dartx['>=']](this.left) && dart.notNull(another.x) <= d
art.notNull(this.left['+'](this.width)) && another.y[dartx['>=']](this.top) && d
art.notNull(another.y) <= dart.notNull(this.top['+'](this.height)); |
150 } | 150 } |
151 get topLeft() { | 151 get topLeft() { |
152 return new (Point$(T))(this.left, this.top); | 152 return new (Point$(T))(this.left, this.top); |
153 } | 153 } |
154 get topRight() { | 154 get topRight() { |
155 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top)
; | 155 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top)
; |
156 } | 156 } |
157 get bottomRight() { | 157 get bottomRight() { |
158 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t
his.top['+'](this.height), T)); | 158 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t
his.top['+'](this.height), T)); |
159 } | 159 } |
(...skipping 18 matching lines...) Expand all Loading... |
178 class Rectangle extends _RectangleBase$(T) { | 178 class Rectangle extends _RectangleBase$(T) { |
179 Rectangle(left, top, width, height) { | 179 Rectangle(left, top, width, height) { |
180 this.left = left; | 180 this.left = left; |
181 this.top = top; | 181 this.top = top; |
182 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0
: width, T); | 182 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0
: width, T); |
183 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']())
* 0 : height, T); | 183 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']())
* 0 : height, T); |
184 super._RectangleBase(); | 184 super._RectangleBase(); |
185 } | 185 } |
186 static fromPoints(a, b) { | 186 static fromPoints(a, b) { |
187 let left = dart.as(min(a.x, b.x), T); | 187 let left = dart.as(min(a.x, b.x), T); |
188 let width = dart.as(max(a.x, b.x)['-'](left), T); | 188 let width = dart.as(max(a.x, b.x)[dartx['-']](left), T); |
189 let top = dart.as(min(a.y, b.y), T); | 189 let top = dart.as(min(a.y, b.y), T); |
190 let height = dart.as(max(a.y, b.y)['-'](top), T); | 190 let height = dart.as(max(a.y, b.y)[dartx['-']](top), T); |
191 return new (Rectangle$(T))(left, top, width, height); | 191 return new (Rectangle$(T))(left, top, width, height); |
192 } | 192 } |
193 } | 193 } |
194 dart.setSignature(Rectangle, { | 194 dart.setSignature(Rectangle, { |
195 constructors: () => ({ | 195 constructors: () => ({ |
196 Rectangle: [Rectangle$(T), [T, T, T, T]], | 196 Rectangle: [Rectangle$(T), [T, T, T, T]], |
197 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]] | 197 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]] |
198 }) | 198 }) |
199 }); | 199 }); |
200 return Rectangle; | 200 return Rectangle; |
201 }); | 201 }); |
202 let Rectangle = Rectangle$(); | 202 let Rectangle = Rectangle$(); |
203 let _width = Symbol('_width'); | 203 let _width = Symbol('_width'); |
204 let _height = Symbol('_height'); | 204 let _height = Symbol('_height'); |
205 let MutableRectangle$ = dart.generic(function(T) { | 205 let MutableRectangle$ = dart.generic(function(T) { |
206 class MutableRectangle extends _RectangleBase$(T) { | 206 class MutableRectangle extends _RectangleBase$(T) { |
207 MutableRectangle(left, top, width, height) { | 207 MutableRectangle(left, top, width, height) { |
208 this.left = left; | 208 this.left = left; |
209 this.top = top; | 209 this.top = top; |
210 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); | 210 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); |
211 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height,
T); | 211 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height,
T); |
212 super._RectangleBase(); | 212 super._RectangleBase(); |
213 } | 213 } |
214 static fromPoints(a, b) { | 214 static fromPoints(a, b) { |
215 let left = dart.as(min(a.x, b.x), T); | 215 let left = dart.as(min(a.x, b.x), T); |
216 let width = dart.as(max(a.x, b.x)['-'](left), T); | 216 let width = dart.as(max(a.x, b.x)[dartx['-']](left), T); |
217 let top = dart.as(min(a.y, b.y), T); | 217 let top = dart.as(min(a.y, b.y), T); |
218 let height = dart.as(max(a.y, b.y)['-'](top), T); | 218 let height = dart.as(max(a.y, b.y)[dartx['-']](top), T); |
219 return new (MutableRectangle$(T))(left, top, width, height); | 219 return new (MutableRectangle$(T))(left, top, width, height); |
220 } | 220 } |
221 get width() { | 221 get width() { |
222 return this[_width]; | 222 return this[_width]; |
223 } | 223 } |
224 set width(width) { | 224 set width(width) { |
225 dart.as(width, T); | 225 dart.as(width, T); |
226 if (width['<'](0)) | 226 if (width['<'](0)) |
227 width = dart.as(_clampToZero(width), T); | 227 width = dart.as(_clampToZero(width), T); |
228 this[_width] = width; | 228 this[_width] = width; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (dart.notNull(a) > dart.notNull(b)) | 268 if (dart.notNull(a) > dart.notNull(b)) |
269 return b; | 269 return b; |
270 if (dart.notNull(a) < dart.notNull(b)) | 270 if (dart.notNull(a) < dart.notNull(b)) |
271 return a; | 271 return a; |
272 if (typeof b == 'number') { | 272 if (typeof b == 'number') { |
273 if (typeof a == 'number') { | 273 if (typeof a == 'number') { |
274 if (a == 0.0) { | 274 if (a == 0.0) { |
275 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no
tNull(b); | 275 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no
tNull(b); |
276 } | 276 } |
277 } | 277 } |
278 if (a == 0 && dart.notNull(b.isNegative) || dart.notNull(b.isNaN)) | 278 if (a == 0 && dart.notNull(b[dartx.isNegative]) || dart.notNull(b[dartx.is
NaN])) |
279 return b; | 279 return b; |
280 return a; | 280 return a; |
281 } | 281 } |
282 return a; | 282 return a; |
283 } | 283 } |
284 dart.fn(min, core.num, [core.num, core.num]); | 284 dart.fn(min, core.num, [core.num, core.num]); |
285 function max(a, b) { | 285 function max(a, b) { |
286 if (!dart.is(a, core.num)) | 286 if (!dart.is(a, core.num)) |
287 throw new core.ArgumentError(a); | 287 throw new core.ArgumentError(a); |
288 if (!dart.is(b, core.num)) | 288 if (!dart.is(b, core.num)) |
289 throw new core.ArgumentError(b); | 289 throw new core.ArgumentError(b); |
290 if (dart.notNull(a) > dart.notNull(b)) | 290 if (dart.notNull(a) > dart.notNull(b)) |
291 return a; | 291 return a; |
292 if (dart.notNull(a) < dart.notNull(b)) | 292 if (dart.notNull(a) < dart.notNull(b)) |
293 return b; | 293 return b; |
294 if (typeof b == 'number') { | 294 if (typeof b == 'number') { |
295 if (typeof a == 'number') { | 295 if (typeof a == 'number') { |
296 if (a == 0.0) { | 296 if (a == 0.0) { |
297 return dart.notNull(a) + dart.notNull(b); | 297 return dart.notNull(a) + dart.notNull(b); |
298 } | 298 } |
299 } | 299 } |
300 if (b.isNaN) | 300 if (b[dartx.isNaN]) |
301 return b; | 301 return b; |
302 return a; | 302 return a; |
303 } | 303 } |
304 if (b == 0 && dart.notNull(a.isNegative)) | 304 if (b == 0 && dart.notNull(a[dartx.isNegative])) |
305 return b; | 305 return b; |
306 return a; | 306 return a; |
307 } | 307 } |
308 dart.fn(max, core.num, [core.num, core.num]); | 308 dart.fn(max, core.num, [core.num, core.num]); |
309 function atan2(a, b) { | 309 function atan2(a, b) { |
310 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b)); | 310 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b)); |
311 } | 311 } |
312 dart.fn(atan2, core.double, [core.num, core.num]); | 312 dart.fn(atan2, core.double, [core.num, core.num]); |
313 function pow(x, exponent) { | 313 function pow(x, exponent) { |
314 _js_helper.checkNum(x); | 314 _js_helper.checkNum(x); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 456 } |
457 if ((dart.notNull(max) & dart.notNull(max) - 1) == 0) { | 457 if ((dart.notNull(max) & dart.notNull(max) - 1) == 0) { |
458 this[_nextState](); | 458 this[_nextState](); |
459 return dart.notNull(this[_lo]) & dart.notNull(max) - 1; | 459 return dart.notNull(this[_lo]) & dart.notNull(max) - 1; |
460 } | 460 } |
461 let rnd32 = null; | 461 let rnd32 = null; |
462 let result = null; | 462 let result = null; |
463 do { | 463 do { |
464 this[_nextState](); | 464 this[_nextState](); |
465 rnd32 = this[_lo]; | 465 rnd32 = this[_lo]; |
466 result = rnd32.remainder(max); | 466 result = rnd32[dartx.remainder](max); |
467 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >=
dart.notNull(_POW2_32)); | 467 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >=
dart.notNull(_POW2_32)); |
468 return result; | 468 return result; |
469 } | 469 } |
470 nextDouble() { | 470 nextDouble() { |
471 this[_nextState](); | 471 this[_nextState](); |
472 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1; | 472 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1; |
473 this[_nextState](); | 473 this[_nextState](); |
474 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; | 474 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; |
475 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not
Null(bits27)) / dart.notNull(_Random._POW2_53_D); | 475 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not
Null(bits27)) / dart.notNull(_Random._POW2_53_D); |
476 } | 476 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 exports.sin = sin; | 515 exports.sin = sin; |
516 exports.cos = cos; | 516 exports.cos = cos; |
517 exports.tan = tan; | 517 exports.tan = tan; |
518 exports.acos = acos; | 518 exports.acos = acos; |
519 exports.asin = asin; | 519 exports.asin = asin; |
520 exports.atan = atan; | 520 exports.atan = atan; |
521 exports.sqrt = sqrt; | 521 exports.sqrt = sqrt; |
522 exports.exp = exp; | 522 exports.exp = exp; |
523 exports.log = log; | 523 exports.log = log; |
524 })(math, core, _js_helper); | 524 })(math, core, _js_helper); |
OLD | NEW |