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