Re: [csswg-drafts] [css-values] Ability to address actual physical size (#614)

> to add a calibration step in your web app. 

Notably, this would basically be:

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.
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, or a cookie, etc).
3. On the pages where you need the accurate length, fetch it from local storage, and set a `--unit-scale: 1.07;` (subbing in the real value) property on the `html` element.
4. Anywhere you use a length that needs to be accurate, instead of `width: 5cm;`, write `width: calc(5cm * var(--unit-scale, 1));`.

This is a robust and minimal calibration scheme that will "fail open" - if the user hasn't calibrated, or clears local data, or has JS turned off, it'll just use standard CSS units (due to the `, 1` default arg for the unit scale), rather than breaking.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/614#issuecomment-611217635 using your GitHub account

Received on Wednesday, 8 April 2020 22:02:33 UTC