(points, i)
| 226 | } |
| 227 | |
| 228 | function createCurveControlPoints(points, i) { |
| 229 | |
| 230 | function isNotMiddlePoint(points, i) { |
| 231 | if (points[i - 1] && points[i + 1]) { |
| 232 | return points[i].y >= Math.max(points[i - 1].y, points[i + 1].y) || points[i].y <= Math.min(points[i - 1].y, |
| 233 | points[ |
| 234 | i + 1].y); |
| 235 | } else { |
| 236 | return false; |
| 237 | } |
| 238 | } |
| 239 | var a = 0.2; |
| 240 | var b = 0.2; |
| 241 | var pAx = null; |
| 242 | var pAy = null; |
| 243 | var pBx = null; |
| 244 | var pBy = null; |
| 245 | if (i < 1) { |
| 246 | pAx = points[0].x + (points[1].x - points[0].x) * a; |
| 247 | pAy = points[0].y + (points[1].y - points[0].y) * a; |
| 248 | } else { |
| 249 | pAx = points[i].x + (points[i + 1].x - points[i - 1].x) * a; |
| 250 | pAy = points[i].y + (points[i + 1].y - points[i - 1].y) * a; |
| 251 | } |
| 252 | |
| 253 | if (i > points.length - 3) { |
| 254 | var last = points.length - 1; |
| 255 | pBx = points[last].x - (points[last].x - points[last - 1].x) * b; |
| 256 | pBy = points[last].y - (points[last].y - points[last - 1].y) * b; |
| 257 | } else { |
| 258 | pBx = points[i + 1].x - (points[i + 2].x - points[i].x) * b; |
| 259 | pBy = points[i + 1].y - (points[i + 2].y - points[i].y) * b; |
| 260 | } |
| 261 | if (isNotMiddlePoint(points, i + 1)) { |
| 262 | pBy = points[i + 1].y; |
| 263 | } |
| 264 | if (isNotMiddlePoint(points, i)) { |
| 265 | pAy = points[i].y; |
| 266 | } |
| 267 | return { |
| 268 | ctrA: { |
| 269 | x: pAx, |
| 270 | y: pAy |
| 271 | }, |
| 272 | ctrB: { |
| 273 | x: pBx, |
| 274 | y: pBy |
| 275 | } |
| 276 | }; |
| 277 | } |
| 278 | |
| 279 | function convertCoordinateOrigin(x, y, center) { |
| 280 | return { |
no test coverage detected