| 3426 | } |
| 3427 | |
| 3428 | function twirl(img, dx, dy, radius, angle) { |
| 3429 | /* Returns the image with a twirl distortion applied to it. |
| 3430 | * - dx: horizontal offset (in pixels) of the effect. |
| 3431 | * - dy: vertical offset (in pixels) of the effect. |
| 3432 | * - radius: the radius of the effect in pixels. |
| 3433 | * - angle: the amount of rotation in degrees. |
| 3434 | */ |
| 3435 | var m1 = Math.radians(angle || 0); |
| 3436 | var m2 = radius || 0; |
| 3437 | return polar(img, dx, dy, function(d, a) { |
| 3438 | return [d, a + (1 - geometry.smoothstep(-m2, m2, d)) * m1]; |
| 3439 | }); |
| 3440 | } |
| 3441 | |
| 3442 | var BUMP = "bump"; |
| 3443 | var DENT = "dent"; |