Currently, I am working on an Ionic 2 app where the user is required to select specific points on the screen. These coordinates will then be utilized on another screen with a different size. My initial attempt at using rule of three/cross multiplication provided an approximate value that was not precise enough for my requirements.
https://i.sstatic.net/SP86l.jpg
Here is an example of my current project, where I tried using values that seemed appropriate on one screen, and applied the same percentage on another screen with a varying size:
makePosition() {
let canvasRect = document.getElementById("shapeBoard").getBoundingClientRect();
let top = this.elementHead.nativeElement.style.top;
let left = this.elementHead.nativeElement.style.left;
this.elementHead.nativeElement.style.top = canvasRect.top + (canvasRect.height * 1.931634728536)/100 + "px";
this.elementHead.nativeElement.style.left = canvasRect.left + (canvasRect.width * 48.738582882804224)/100 + "px";
}
html: https://codepen.io/jmachado/pen/ybzNzr
Is there a method to dynamically adjust the position of the circle div to consistently remain in the same location over the image?