Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Seg16 copyright 2011 JEM <SifakaMon@gmail.com>, reuse allowed under a modified MIT license term
- -- --- ---
- -- | \ | / |
- -- --- ---
- -- | / | \ |
- -- ---.---
- -- Markers:
- -- a b
- -- c d e f g
- -- h i
- -- j k l m n
- -- o q p
- -- notice I cheated and made it a 17 segment display (for decimal)
- -- version 2 adds a parameter for aspect ratio
- function seg16draw(x, y, str, measure, aspect)
- if aspect == nil then aspect = 1.4 end
- sz = sz / aspect
- for c in str:gmatch(".") do
- local d = seg16char[c]
- if d ~= nil then
- for s in d:gmatch(".") do
- p = seg16seg[s]
- if p ~= nil and measure ~= true then
- line(x+p[1] * sz,y+p[2] * sz * aspect,x+p[3] * sz,y+p[4] * sz * aspect)
- end
- end
- end
- x = x + 1.3 * sz
- end
- return x
- end
- seg16seg = {
- a = {0,1,.5,1},
- b = {.5,1,1,1},
- c = {0,1,0,.5},
- d = {0,1,.5,.5},
- e = {.5,1,.5,.5},
- f = {.5,.5,1,1},
- g = {1,1,1,.5},
- h = {0,.5,.5,.5},
- i = {.5,.5,1,.5},
- j = {0,.5,0,0},
- k = {0,0,.5,.5},
- l = {.5,.5,.5,0},
- m = {.5,.5,1,0},
- n = {1,.5,1,0},
- o = {0,0,.5,0},
- p = {.5,0,1,0},
- q = {.5,0,.5,0.1}
- }
- seg16char = {
- ["_"] = "op",
- ["|"] = "el",
- ["/"] = "kf",
- ["\\"]= "md",
- ["-"] = "hi",
- ["="] = "ohpi",
- ["."] = "q",
- [","] = "k",
- ["0"] = "kfabgnpojc",
- ["1"] = "fgn",
- ["2"] = "abgihjop",
- ["3"] = "abgihnpo",
- ["4"] = "chign",
- ["5"] = "bachinpo",
- ["6"] = "bacjopnih",
- ["7"] = "abfk",
- ["8"] = "abgnpojchi",
- ["9"] = "ihcabgnpo",
- A = "jcabgnhi",
- B = "abgnopeil",
- C = "bacjop",
- D = "abgnopel",
- E = "bachjop",
- F = "bacjh",
- G = "bacjopni",
- H = "cjhign",
- I = "abelop",
- J = "bgnpoj",
- K = "cjhfm",
- L = "cjop",
- M = "jcdfgn",
- N = "jcdmng",
- O = "abgnpojc",
- P = "abjihcjg",
- Q = "abgnmpojc",
- R = "abjihcmjg",
- S = "badinpo",
- T = "abel",
- U = "cjopng",
- V = "dmng",
- W = "cjkmng",
- X = "dfkm",
- Y = "dfl",
- Z = "abfkop"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement