I have a collection of 10 shapes that together form an intricate square image, depicted in the diagram below. My goal is to animate each shape by utilizing the output of a periodic function such as sine, which would dynamically respond to the user's mouse position. Each shape should move in a unique pattern influenced by different frequencies and periods, resulting in a captivating visual effect where the shapes constantly shift relative to one another as the user hovers over them.
https://i.sstatic.net/TMghS.png
Currently, I have succeeded in animating a single shape with the following code:
$(document).mousemove(function(e){
var track = function(ampl, freq) {
return {
x : ampl * Math.sin(freq*e.pageX),
y : ampl*1.6 * Math.sin(freq*e.pageY)
};
}
var current = track(10, 0.05);
$("#image").css({left:current.x, top:current.y});
});
My challenge now lies in extending this functionality to apply to the other 9 shapes showcased in this jsfiddle. How can I achieve this integration?