I have two images, one is a static image and another is dynamic which can be rotated and transform. I want to know if the dynamic image has covered the static image or not. I was able to know if the dynamic image covered the static image or not by using this code.
const cardBox = document.getElementById("cardBg");
const cardPosition = cardBox.getBoundingClientRect();
const imgBox = document.getElementById("img");
const imagePosition = imgBox.getBoundingClientRect();
const isInside =
imagePosition.top <= cardPosition.top &&
cardPosition.top <= imagePosition.bottom &&
imagePosition.top <= cardPosition.bottom &&
cardPosition.bottom <= imagePosition.bottom &&
imagePosition.left <= cardPosition.left &&
cardPosition.left <= imagePosition.right &&
imagePosition.left <= cardPosition.right &&
cardPosition.right <= imagePosition.right;
But when I rotate the dynamic image this logic does not work. Any solution for this ?