Как я могу ущипнуть/сжать некоторую область изображения на холсте?
Некоторое время назад я сделал анимацию солнечной системы и начал ее переписывать. Теперь я хочу добавить гравитационный эффект к массам. Чтобы сделать эффект видимым, я превратил фон в сетку и буду его изменять.
Желаемый эффект примерно такой (сделано в 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);
Обновление: я погуглил и нашел некоторые ресурсы, но, поскольку я никогда раньше не занимался манипуляциями с пикселями, я не могу собрать их воедино.
Пиксельные искажения с билинейной фильтрацией в HTML5 Холст | Splashnology.com (только функции)
glfx.js (библиотека WebGL с демонстрациями)
JSFiddle (примеры сферизации, масштабирования, вращения)
Я думаю, эффект сферизации в перевернутой форме был бы хорош для этой работы.