| 3401 | } |
| 3402 | |
| 3403 | function pinch(img, dx, dy, zoom) { |
| 3404 | /* Returns the image with a pinch distortion applied to it. |
| 3405 | * - dx: horizontal offset (in pixels) of the effect. |
| 3406 | * - dy: vertical offset (in pixels) of the effect. |
| 3407 | * - zoom: the amount of bulge or pinch (-1.0-1.0): |
| 3408 | */ |
| 3409 | var m1 = geometry.distance(0, 0, img.width, img.height); |
| 3410 | var m2 = Math.clamp(zoom || 0 * 0.75, -0.75, 0.75); |
| 3411 | return polar(img, dx, dy, function(d, a) { |
| 3412 | return [d * Math.pow(m1/d, m2) * (1-m2), a]; |
| 3413 | }); |
| 3414 | } |
| 3415 | |
| 3416 | function splash(img, dx, dy, radius) { |
| 3417 | /* Returns the image with a light-tunnel distortion applied to it. |