| 3387 | } |
| 3388 | |
| 3389 | function dent(img, dx, dy, radius, zoom) { |
| 3390 | /* Returns the image with a dent distortion applied to it. |
| 3391 | * - dx: horizontal offset (in pixels) of the effect. |
| 3392 | * - dy: vertical offset (in pixels) of the effect. |
| 3393 | * - radius: the radius of the effect in pixels. |
| 3394 | * - zoom: the amount of pinch (0.0-1.0). |
| 3395 | */ |
| 3396 | var m1 = radius || 0; |
| 3397 | var m2 = Math.clamp(zoom || 0, 0, 1); |
| 3398 | return polar(img, dx, dy, function(d, a) { |
| 3399 | return [2 * d - d * geometry.smoothstep(0, m2, d/m1), a]; |
| 3400 | }); |
| 3401 | } |
| 3402 | |
| 3403 | function pinch(img, dx, dy, zoom) { |
| 3404 | /* Returns the image with a pinch distortion applied to it. |