Created
May 20, 2017 08:46
-
-
Save gicmo/a1eb5f11cae692f8babe5f97441e1d76 to your computer and use it in GitHub Desktop.
Calculate the width, height limits for a given dpi threshold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import numpy as np | |
def limit(ts, r): | |
return (r / ts) * 25.4 | |
def ds(w, h): | |
return np.sqrt(w**2 + h**2) / 25.4 | |
res = [(3840, 2048)] | |
def main(): | |
ts = [192, 182, 181, 180] if len(sys.argv) < 2 else [int(sys.argv[1])] | |
for t in ts: | |
for r in res: | |
x, y = r[0], r[1] | |
w, h = limit(t, x), limit(t, y) | |
d = ds(w, h) | |
print("%d %d×%d => %5.2f×%5.2f [%2.2f]" % (t, x, y, w, h, d)) | |
if __name__ == '__main__': | |
main() |
Author
gicmo
commented
May 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment