0

enter image description here

Here, I made a canvas app with total width is (742px), so here what I need, I just want to calculate and get right section (Index) by X only.

Example, I got 393.9015504531791 as X calculated with whole width, So X here it's 0.5x in real, how do I would calculate that and get right Index between (1-17) only through X? enter image description here

I tried many calcs I know, but honestly I'm not good on Math lol.

Vishwas R
  • 3,340
  • 1
  • 16
  • 37
cair71
  • 13
  • 1

1 Answers1

0
OneWidth = 542 / 17
LeftEdge = (742 - 542) / 2
Index = Math.floor((X - LeftEdge) / OneWidth) + 1
MBo
  • 77,366
  • 5
  • 53
  • 86