TameemADR commited on
Commit
1ee3be3
·
verified ·
1 Parent(s): 5cf388d

Update static/js/script.js

Browse files
Files changed (1) hide show
  1. static/js/script.js +9 -3
static/js/script.js CHANGED
@@ -23,9 +23,14 @@ function loadImage(src) {
23
  }
24
 
25
  document.getElementById("canvas").addEventListener("click", function (e) {
26
- const rect = this.getBoundingClientRect();
27
- const x = Math.round(e.clientX - rect.left);
28
- const y = Math.round(e.clientY - rect.top);
 
 
 
 
 
29
 
30
  fetch('/click', {
31
  method: 'POST',
@@ -45,6 +50,7 @@ document.getElementById("canvas").addEventListener("click", function (e) {
45
  });
46
  });
47
 
 
48
  function updateHSVLabels() {
49
  document.getElementById('hMinVal').innerText = hsv.hMin;
50
  document.getElementById('hMaxVal').innerText = hsv.hMax;
 
23
  }
24
 
25
  document.getElementById("canvas").addEventListener("click", function (e) {
26
+ const canvas = this;
27
+ const rect = canvas.getBoundingClientRect();
28
+
29
+ const scaleX = canvas.width / rect.width;
30
+ const scaleY = canvas.height / rect.height;
31
+
32
+ const x = Math.round((e.clientX - rect.left) * scaleX);
33
+ const y = Math.round((e.clientY - rect.top) * scaleY);
34
 
35
  fetch('/click', {
36
  method: 'POST',
 
50
  });
51
  });
52
 
53
+
54
  function updateHSVLabels() {
55
  document.getElementById('hMinVal').innerText = hsv.hMin;
56
  document.getElementById('hMaxVal').innerText = hsv.hMax;