How can I pinch/pucker some area of an image in canvas?
I've made a solar system animation some time ago, and I started rewriting it. Now, I want to add gravity effect to masses. To make the effect visible, I turned the background into a grid and I'll be modifying it.
Desired effect is something like this (made in PS)
context.background("rgb(120,130,145)");
context.grid(25, "rgba(255,255,255,.1)");
var sun = {
fill : "rgb(220,210,120)",
radius : 30,
boundingBox : 30*2 + 3*2,
position : {
x : 200,
y : 200,
},
};
sun.img = saveToImage(sun);
context.drawImage(sun.img, sun.position.x - sun.boundingBox/2, sun.position.y - sun.boundingBox/2);
Update: I've done some googling and found some resources, but since I've never done pixel manipulation before, I can't put these together.
Pixel Distortions with Bilinear Filtration in HTML5 Canvas | Splashnology.com (functions only)
glfx.js (WebGL library with demos)
JSFiddle (spherize, zoom, twirl examples)
The spherize effect in inverted form would be good for the job, I guess.