This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
faq [2021/02/26 09:55] – Add "real physical units" tabatkins | faq [2021/02/26 10:23] – [Real Physical Lengths] tabatkins | ||
---|---|---|---|
Line 331: | Line 331: | ||
There' | There' | ||
- | 1. Have a calibration page, where you ask the user to measure the distance between two lines that are some CSS distance apart (say, 10cm), and input the value they get. | + | - Have a calibration page, where you ask the user to measure the distance between two lines that are some CSS distance apart (say, 10cm), and input the value they get. |
- | 2. Use this to find the scaling factor necessary for that screen (CSS length divided by user-provided length), and store it locally (via localStorage, | + | |
- | 3. On the pages where you need the accurate length, fetch it from local storage, and set a '' | + | |
- | 4. Anywhere you use a length that needs to be accurate, instead of '' | + | |
This is a robust and minimal scheme that is guaranteed to give correct results on a given device, and "fails open" - if the user hasn't calibrated yet, or has cleared their local storage, etc, the '' | This is a robust and minimal scheme that is guaranteed to give correct results on a given device, and "fails open" - if the user hasn't calibrated yet, or has cleared their local storage, etc, the '' |