seanpm2001 / advanced_eye_chart Goto Github PK
View Code? Open in Web Editor NEWAn advanced eye chart tool for optometrists.
License: GNU General Public License v3.0
An advanced eye chart tool for optometrists.
License: GNU General Public License v3.0
I gave up early on on the original Advanced Eye Chart script due to its over complexity. I know it can be done in a much more efficient way, I just don't know what. I have been trying to find a new efficient way for nearly 48 hours.
Here is the old, incomplete, inefficient code
# This is extremely inefficient. If anyone knows a better way, let me know
letter1ID = random.randint(0, 85) # First letter on the chart, top left, largest (200/20)
if (letter1ID == 0):
letter1 = str("a")
if (letter1ID == 1):
letter1 = str("A")
if (letter1ID == 2):
letter1 = str("b")
if (letter1ID == 3):
letter1 = str("B")
if (letter1ID == 4):
letter1 = str("c")
if (letter1ID == 5):
letter1 = str("C")
if (letter1ID == 6):
letter1 = str("d")
if (letter1ID == 7):
letter1 = str("D")
if (letter1ID == 8):
letter1 = str("e")
if (letter1ID == 9):
letter1 = str("E")
if (letter1ID == 10):
letter1 = str("f")
if (letter1ID == 11):
letter1 = str("F")
if (letter1ID == 12):
letter1 = str("g")
if (letter1ID == 13):
letter1 = str("G")
if (letter1ID == 14):
letter1 = str("h")
if (letter1ID == 15):
letter1 = str("H")
if (letter1ID == 16):
letter1 = str("i")
if (letter1ID == 17):
letter1 = str("I")
if (letter1ID == 18):
letter1 = str("j")
if (letter1ID == 19):
letter1 = str("J")
if (letter1ID == 20):
letter1 = str("k")
if (letter1ID == 21):
letter1 = str("K")
if (letter1ID == 22):
letter1 = str("l")
if (letter1ID == 23):
letter1 = str("L")
if (letter1ID == 24):
letter1 = str("m")
if (letter1ID == 25):
letter1 = str("M")
if (letter1ID == 26):
letter1 = str("n")
if (letter1ID == 27):
letter1 = str("N")
if (letter1ID == 28):
letter1 = str("o")
if (letter1ID == 29):
letter1 = str("O")
if (letter1ID == 30):
letter1 = str("p")
if (letter1ID == 31):
letter1 = str("P")
if (letter1ID == 32):
letter1 = str("q")
if (letter1ID == 33):
letter1 = str("Q")
if (letter1ID == 34):
letter1 = str("r")
if (letter1ID == 35):
letter1 = str("R")
if (letter1ID == 36):
letter1 = str("s")
if (letter1ID == 37):
letter1 = str("S")
if (letter1ID == 38):
letter1 = str("T")
if (letter1ID == 39):
letter1 = str("t")
if (letter1ID == 40):
letter1 = str("u")
if (letter1ID == 41):
letter1 = str("U")
if (letter1ID == 42):
letter1 = str("v")
if (letter1ID == 43):
letter1 = str("V")
if (letter1ID == 44):
letter1 = str("w")
if (letter1ID == 45):
letter1 = str("W")
if (letter1ID == 46):
letter1 = str("x")
if (letter1ID == 47):
letter1 = str("X")
if (letter1ID == 48):
letter1 = str("y")
if (letter1ID == 49):
letter1 = str("Y")
if (letter1ID == 50):
letter1 = str("z")
if (letter1ID == 51):
letter1 = str("Z")
if (letter1ID == 52):
letter1 = str("0")
if (letter1ID == 53):
letter1 = str("1")
if (letter1ID == 54):
letter1 = str("2")
if (letter1ID == 55):
letter1 = str("3")
if (letter1ID == 56):
letter1 = str("4")
if (letter1ID == 57):
letter1 = str("5")
if (letter1ID == 58):
letter1 = str("6")
if (letter1ID == 59):
letter1 = str("7")
if (letter1ID == 60):
letter1 = str("8")
if (letter1ID == 61):
letter1 = str("9")
if (letter1ID == 62):
letter1 = str(",")
if (letter1ID == 63):
letter1 = str(".")
if (letter1ID == 64):
letter1 = str("!")
if (letter1ID == 65):
letter1 = str("@")
if (letter1ID == 66):
letter1 = str("#")
if (letter1ID == 67):
letter1 = str("$")
if (letter1ID == 68):
letter1 = str("!")
if (letter1ID == 69):
letter1 = str("%")
if (letter1ID == 70):
letter1 = str("^")
if (letter1ID == 71):
letter1 = str("&")
if (letter1ID == 72):
letter1 = str("*")
if (letter1ID == 73):
letter1 = str("=")
if (letter1ID == 74):
letter1 = str("-")
if (letter1ID == 75):
letter1 = str("+")
if (letter1ID == 76):
letter1 = str("_")
if (letter1ID == 77):
letter1 = str("?")
if (letter1ID == 78):
letter1 = str("<")
if (letter1ID == 79):
letter1 = str(">")
if (letter1ID == 80):
letter1 = str("~")
if (letter1ID == 81):
letter1 = str("`")
if (letter1ID == 82):
letter1 = str("\"")
if (letter1ID == 83):
letter1 = str("/")
if (letter1ID == 84):
letter1 = str(":")
if (letter1ID == 85):
letter1 = str(";")
letter2ID = random.randint(0, 85)
if (letter2ID == 0 and letter2ID != letter1ID):
letter2 = str("a")
if (letter2ID == 1 and letter2ID != letter1ID):
letter2 = str("A")
if (letter2ID == 2 and letter2ID != letter1ID):
letter2 = str("b")
if (letter1ID == 3 and letter2ID != letter1ID):
letter1 = str("B")
if (letter1ID == 4 and letter2ID != letter1ID):
letter1 = str("c")
if (letter1ID == 5 and letter2ID != letter1ID):
letter1 = str("C")
if (letter1ID == 6 and letter2ID != letter1ID):
letter1 = str("d")
if (letter1ID == 7 and letter2ID != letter1ID):
letter1 = str("D")
if (letter1ID == 8 and letter2ID != letter1ID):
letter1 = str("e")
if (letter1ID == 9 and letter2ID != letter1ID):
letter1 = str("E")
if (letter1ID == 10 and letter2ID != letter1ID):
letter1 = str("f")
if (letter1ID == 11 and letter2ID != letter1ID):
letter1 = str("F")
if (letter1ID == 12 and letter2ID != letter1ID):
letter1 = str("g")
if (letter1ID == 13 and letter2ID != letter1ID):
letter1 = str("G")
if (letter1ID == 14 and letter2ID != letter1ID):
letter1 = str("h")
if (letter1ID == 15 and letter2ID != letter1ID):
letter1 = str("H")
if (letter1ID == 16 and letter2ID != letter1ID):
letter1 = str("i")
if (letter1ID == 17 and letter2ID != letter1ID):
letter1 = str("I")
if (letter1ID == 18 and letter2ID != letter1ID):
letter1 = str("j")
if (letter1ID == 19 and letter2ID != letter1ID):
letter1 = str("J")
if (letter1ID == 20 and letter2ID != letter1ID):
letter1 = str("k")
if (letter1ID == 21 and letter2ID != letter1ID):
letter1 = str("K")
if (letter1ID == 22 and letter2ID != letter1ID):
letter1 = str("l")
if (letter1ID == 23 and letter2ID != letter1ID):
letter1 = str("L")
if (letter1ID == 24 and letter2ID != letter1ID):
letter1 = str("m")
if (letter1ID == 25 and letter2ID != letter1ID):
letter1 = str("M")
if (letter1ID == 26 and letter2ID != letter1ID):
letter1 = str("n")
if (letter1ID == 27 and letter2ID != letter1ID):
letter1 = str("N")
if (letter1ID == 28 and letter2ID != letter1ID):
letter1 = str("o")
if (letter1ID == 29 and letter2ID != letter1ID):
letter1 = str("O")
if (letter1ID == 30 and letter2ID != letter1ID):
letter1 = str("p")
if (letter1ID == 31 and letter2ID != letter1ID):
letter1 = str("P")
if (letter1ID == 32 and letter2ID != letter1ID):
letter1 = str("q")
if (letter1ID == 33 and letter2ID != letter1ID):
letter1 = str("Q")
if (letter1ID == 34 and letter2ID != letter1ID):
letter1 = str("r")
if (letter1ID == 35 and letter2ID != letter1ID):
letter1 = str("R")
if (letter1ID == 36 and letter2ID != letter1ID):
letter1 = str("s")
if (letter1ID == 37 and letter2ID != letter1ID):
letter1 = str("S")
if (letter1ID == 38 and letter2ID != letter1ID):
letter1 = str("T")
if (letter1ID == 39 and letter2ID != letter1ID):
letter1 = str("t")
if (letter1ID == 40 and letter2ID != letter1ID):
letter1 = str("u")
if (letter1ID == 41 and letter2ID != letter1ID):
letter1 = str("U")
if (letter1ID == 42 and letter2ID != letter1ID):
letter1 = str("v")
if (letter1ID == 43 and letter2ID != letter1ID):
letter1 = str("V")
if (letter1ID == 44 and letter2ID != letter1ID):
letter1 = str("w")
if (letter1ID == 45 and letter2ID != letter1ID):
letter1 = str("W")
if (letter1ID == 46 and letter2ID != letter1ID):
letter1 = str("x")
if (letter1ID == 47 and letter2ID != letter1ID):
letter1 = str("X")
if (letter1ID == 48 and letter2ID != letter1ID):
letter1 = str("y")
if (letter1ID == 49 and letter2ID != letter1ID):
letter1 = str("Y")
if (letter1ID == 50 and letter2ID != letter1ID):
letter1 = str("z")
if (letter1ID == 51 and letter2ID != letter1ID):
letter1 = str("Z")
if (letter1ID == 52 and letter2ID != letter1ID):
letter1 = str("0")
if (letter1ID == 53 and letter2ID != letter1ID):
letter1 = str("1")
if (letter1ID == 54 and letter2ID != letter1ID):
letter1 = str("2")
if (letter1ID == 55 and letter2ID != letter1ID):
letter1 = str("3")
if (letter1ID == 56 and letter2ID != letter1ID):
letter1 = str("4")
if (letter1ID == 57 and letter2ID != letter1ID):
letter1 = str("5")
if (letter1ID == 58 and letter2ID != letter1ID):
letter1 = str("6")
if (letter1ID == 59 and letter2ID != letter1ID):
letter1 = str("7")
if (letter1ID == 60 and letter2ID != letter1ID):
letter1 = str("8")
if (letter1ID == 61 and letter2ID != letter1ID):
letter1 = str("9")
if (letter1ID == 62 and letter2ID != letter1ID):
letter1 = str(",")
if (letter1ID == 63 and letter2ID != letter1ID):
letter1 = str(".")
if (letter1ID == 64 and letter2ID != letter1ID):
letter1 = str("!")
if (letter1ID == 65 and letter2ID != letter1ID):
letter1 = str("@")
if (letter1ID == 66 and letter2ID != letter1ID):
letter1 = str("#")
if (letter1ID == 67 and letter2ID != letter1ID):
letter1 = str("$")
if (letter1ID == 68 and letter2ID != letter1ID):
letter1 = str("!")
if (letter1ID == 69 and letter2ID != letter1ID):
letter1 = str("%")
if (letter1ID == 70 and letter2ID != letter1ID):
letter1 = str("^")
if (letter1ID == 71 and letter2ID != letter1ID):
letter1 = str("&")
if (letter1ID == 72 and letter2ID != letter1ID):
letter1 = str("*")
if (letter1ID == 73 and letter2ID != letter1ID):
letter1 = str("=")
if (letter1ID == 74 and letter2ID != letter1ID):
letter1 = str("-")
if (letter1ID == 75 and letter2ID != letter1ID):
letter1 = str("+")
if (letter1ID == 76 and letter2ID != letter1ID):
letter1 = str("_")
if (letter1ID == 77 and letter2ID != letter1ID):
letter1 = str("?")
if (letter1ID == 78 and letter2ID != letter1ID):
letter1 = str("<")
if (letter1ID == 79 and letter2ID != letter1ID):
letter1 = str(">")
if (letter1ID == 80 and letter2ID != letter1ID):
letter1 = str("~")
if (letter1ID == 81 and letter2ID != letter1ID):
letter1 = str("`")
if (letter1ID == 82 and letter2ID != letter1ID):
letter1 = str("\"")
if (letter1ID == 83 and letter2ID != letter1ID):
letter1 = str("/")
if (letter1ID == 84 and letter2ID != letter1ID):
letter1 = str(":")
if (letter1ID == 85 and letter2ID != letter1ID):
letter1 = str(";")
letter3ID = random.randint(0, 512)
if (letter3ID == 0 and letter3ID != letter2ID):
letter3 = str("a")
if (letter3ID == 1 and letter3ID != letter2ID):
letter3 = str("A")
if (letter3ID == 2 and letter3ID != letter2ID):
letter3 = str("b")
# Stopping here for now until I find a more efficient method. There HAS to be a better way to do this.
I am looking for ways to better optimize this, and continue to support various languages and alphabets. I am not looking for another language to do this in, unless it is absolutely necessary in the case that Python doesn't support that method.
@all-contributors please add NihalKarne for code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.