module Font where

import Graphics.UI.GLUT (GLfloat)
import Data.Char (isUpper, toLower)

letterPath :: Char -> [(GLfloat, GLfloat, GLfloat)]
letterPath ' ' = []
letterPath 'a' = [ (0   , 0   , 0) , (0.25, 0   , 0) , (0.375,1   , 0)
                 , (0.5 , 0.75, 0) , (0.625,1   , 0) , (0.75, 0   , 0)
                 , (1,      0,      0) ]
letterPath 'b' = letterPath 'p' ++ [ (0.67, 0.67, 0) , (1   , 0.5 , 0)
                                   , (0.67, 0.16, 0), (1   , 0.16, 0)
                                   , (0.33, 0.16, 0), (0.67, 0   , 0)
                                   , (0.33, 0   , 0) ]
letterPath 'c' = [ (1   , 0.67, 0) , (0.67, 0.67, 0) , (1   , 0.83, 0)
                 , (0.67, 0.83, 0) , (0.67, 1   , 0) , (0.33, 0.83, 0)
                 , (0.33, 1   , 0) , (0   , 0.83, 0) , (0.33, 0.83, 0)
                 , (0   , 0.16, 0) , (0.33, 0.16, 0) , (0.33, 0   , 0)
                 , (0.67, 0.16, 0) , (0.67, 0   , 0) , (0.67, 0.16, 0)
                 , (1   , 0.16, 0) , (0.67, 0.33, 0) , (1   , 0.33, 0) ]
letterPath 'd' = [ (0   , 0   , 0) , (0.33, 0   , 0) , (0   , 1   , 0)
                 , (0.33, 0.83, 0) , (0.67, 1   , 0) , (1   , 0.83, 0)
                 , (0.67, 0.83, 0) , (1   , 0.16, 0) , (0.67, 0.16, 0)
                 , (0.67, 0   , 0) , (0.33, 0.16, 0) , (0.33, 0   , 0) ]
letterPath 'e' = [ (1   , 0   , 0) , (1   , 0.16, 0) , (0   , 0   , 0)
                 , (0.33, 0.16, 0) , (0   , 0.16, 0) , (0.33, 0.5 , 0)
                 , (0   , 0.5 , 0) , (0.83, 0.5 , 0) , (0   , 0.67, 0)
                 , (0.83, 0.67, 0) , (0.33, 0.67, 0) , (0   , 0.67, 0)
                 , (0.33, 0.83, 0) , (0   , 1   , 0) , (1   , 0.83, 0)
                 , (1   , 1   , 0) ]
letterPath 'f' = [ (0.33, 0   , 0) , (0   , 0   , 0) , (0.33, 0.16, 0)
                 , (0   , 0.33, 0) , (0.33, 0.33, 0) , (0.83, 0.33, 0)
                 , (0   , 0.33, 0) , (0.83, 0.5 , 0) , (0   , 0.5 , 0)
                 , (0.33, 0.5 , 0) , (0   , 0.83, 0) , (0.33, 0.83, 0)
                 , (0   , 1   , 0) , (1   , 0.83, 0) , (1   , 1   , 0) ]
letterPath 'g' = letterPath 'c' ++ [ (0.5 , 0.33, 0) , (1   , 0.5 , 0)
                                   , (0.5 , 0.5 , 0) ]
letterPath 'h' = [ (0   , 1   , 0) , (0   , 0   , 0) , (0.33, 1   , 0)
                 , (0.33, 0   , 0) , (0.33, 0.4 , 0) , (0.33, 0.6 , 0)
                 , (0.67, 0.4 , 0) , (0.67, 0.6 , 0) , (0.67, 0   , 0)
                 , (0.67, 1   , 0) , (1   , 0   , 0) , (1   , 1   , 0) ]
letterPath 'i' = [ (0.16, 1   , 0) , (0.83, 1   , 0) , (0.16, 0.83, 0)
                 , (0.83, 0.83, 0) , (0.33, 0.83, 0) , (0.67, 0.83, 0)
                 , (0.33, 0.16, 0) , (0.67, 0.16, 0) , (0.16, 0.16, 0)
                 , (0.16, 0   , 0) , (0.83, 0.16, 0) , (0.83, 0   , 0) ]
letterPath 'j' = [ (0   , 1   , 0) , (0   , 0.83, 0) , (1   , 1   , 0)
                 , (0.67, 0.83, 0) , (1   , 0.16, 0) , (0.67, 0.16, 0)
                 , (0.67, 0   , 0) , (0.33, 0.16, 0) , (0.33, 0   , 0)
                 , (0.33, 0.16, 0) , (0   , 0.16, 0) , (0.33, 0.33, 0)
                 , (0   , 0.33, 0) ]
letterPath 'k' = [ (0   , 0   , 0) , (0   , 1   , 0) , (0.33, 0   , 0)
                 , (0.33, 1   , 0) , (0.33, 0.33, 0) , (0.33, 0.67, 0)
                 , (0.67, 0   , 0) , (1   , 0   , 0) , (0.33, 0.67, 0)
                 , (0.33, 0.33, 0) , (0.67, 1   , 0) , (1   , 1   , 0) ]
letterPath 'l' = [ (1   , 0   , 0) , (1   , 0.16, 0) , (0   , 0   , 0)
                 , (0.33, 0.16, 0) , (0   , 1   , 0) , (0.33, 1   , 0) ]
letterPath 'm' = [ (0   , 0   , 0) , (0   , 1   , 0) , (0.33, 0   , 0)
                 , (0.33, 1   , 0) , (0.33, 0.67, 0) , (0.5 , 0.67, 0)
                 , (0.5 , 0.33, 0) , (0.5 , 0.67, 0) , (0.67, 0.67, 0)
                 , (0.67, 1   , 0) , (0.67, 0   , 0) , (1   , 1   , 0)
                 , (1   , 0   , 0) ]
letterPath 'n' = [ (0   , 0   , 0) , (0   , 1   , 0) , (0.33, 0   , 0)
                 , (0.33, 1   , 0) , (0.33, 0.67, 0) , (0.67, 0.33, 0)
                 , (0.67, 0   , 0) , (0.67, 1   , 0) , (1   , 0   , 0)
                 , (1   , 1   , 0) ]
letterPath 'o' = [ (1   , 2/7 , 0) , (5/7 , 2/7 , 0) , (1   , 5/7 , 0)
                 , (5/7 , 5/7 , 0) , (5/7 , 1   , 0) , (4/7 , 6/7 , 0)
                 , (0.5 , 1   , 0) , (3/7 , 6/7 , 0) , (2/7 , 1   , 0)
                 , (2/7 , 5/7 , 0) , (0   , 5/7 , 0) , (2/7 , 2/7 , 0)
                 , (0   , 2/7 , 0) , (3/7 , 1/7 , 0) , (2/7 , 0   , 0)
                 , (5/7 , 0   , 0) , (4/7 , 1/7 , 0) , (1   , 2/7 , 0)
                 , (5/7 , 2/7 , 0) ]
letterPath 'p' = [ (0   , 0   , 0) , (0.33, 0   , 0) , (0.33,0.83 , 0)
                 , (0   , 0   , 0) , (0   , 1   , 0) , (0.33, 0.83, 0)
                 , (0.67, 0.83, 0) , (0   , 1   , 0) , (0.67, 1   , 0)
                 , (0.67, 0.83, 0) , (1   , 0.67, 0) , (0.67, 1   , 0)
                 , (1   , 0.83, 0) , (1   , 0.67, 0) , (0.67, 0.83, 0)
                 , (0.67, 0.67, 0) , (1   , 0.67, 0) , (0.67, 0.5 , 0)
                 , (0.67, 0.67, 0) , (0.33, 0.67, 0) , (0.67, 0.5 , 0)
                 , (0.33, 0.5 , 0) ]
letterPath 'q' = letterPath 'o' ++ [ (4/7 , 1/7 , 0) , (4/7 , 3/7 , 0)
                                   , (3/7 , 2/7 , 0) ]
letterPath 'r' = letterPath 'p' ++ [ (1   , 0   , 0) , (0.67, 0   , 0) ]
letterPath 's' = [ (0.33, 0   , 0) , (0   , 0.25, 0) , (0.67, 0   , 0)
                 , (1   , 0.25, 0) , (0.67, 0.375,0) , (1   , 0.375,0)
                 , (0.33, 0.375,0) , (0.67, 0.625,0) , (0   , 0.625,0)
                 , (0.33, 0.625,0) , (0   , 0.75, 0) , (0.33, 0.75, 0)
                 , (0.33, 1   , 0) , (1   , 0.75, 0) , (0.66, 1   , 0) ]
letterPath 't' = [ (0   , 1   , 0) , (1   , 1   , 0) , (0   , 0.83, 0)
                 , (1   , 0.83, 0) , (0.33, 0.83, 0) , (0.67, 0.83, 0)
                 , (0.33, 0   , 0) , (0.67, 0   , 0) ]
letterPath 'u' = [ (1   , 1   , 0) , (5/7 , 1   , 0) , (1   , 2/7 , 0)
                 , (5/7 , 2/7 , 0) , (5/7 , 0   , 0) , (4/7 , 1/7 , 0)
                 , (0.5 , 0   , 0) , (3/7 , 1/7 , 0) , (2/7 , 0   , 0)
                 , (2/7 , 2/7 , 0) , (0   , 2/7 , 0) , (2/7 , 1   , 0)
                 , (0   , 1   , 0) ]
letterPath 'v' = [ (0   , 1   , 0) , (0.25, 1   , 0) , (0.375,0   , 0)
                 , (0.5 , 0.25, 0) , (0.625,0   , 0) , (0.75, 1   , 0)
                 , (1   , 1   , 0) ]
letterPath 'w' = [ (0   , 1   , 0) , (2/8 , 1   , 0) , (1/8 , 0   , 0)
                 , (3/8 , 2/8 , 0) , (3/8 , 0   , 0) , (4/8 , 4/8 , 0)
                 , (4/8 , 2/8 , 0) , (5/8 , 2/8 , 0) , (5/8 , 0   , 0)
                 , (6/8 , 1   , 0) , (7/8 , 0   , 0) , (1   , 1   , 0) ]
letterPath 'x' = [ (0   , 0   , 0) , (0.33, 0   , 0) , (0.33, 0.5 , 0)
                 , (0.5 , 0.25, 0) , (0.67, 0.5 , 0) , (0.67, 0   , 0)
                 , (1   , 0   , 0) , (0   , 1   , 0) , (0.33, 1   , 0)
                 , (0.67, 0.5 , 0) , (0.5 , 0.75, 0) , (1   , 1   , 0)
                 , (0.67, 1   , 0) ]
letterPath 'y' = [ (0   , 1   , 0) , (0.33, 1   , 0) , (0.33, 0.5 , 0)
                 , (0.5 , 0.75, 0) , (0.67, 0.5 , 0) , (0.67, 1   , 0)
                 , (1   , 1   , 0) , (0   , 0   , 0) , (0.33, 0   , 0) ]
letterPath 'z' = [ (1   , 0   , 0) , (0   , 0   , 0) , (1   , 0.16, 0)
                 , (0   , 0.16, 0) , (0.33, 0.16, 0) , (0.67, 0.83, 0)
                 , (1   , 0.83, 0) , (0   , 0.83, 0) , (1   , 1   , 0)
                 , (0   , 1   , 0) ]
letterPath '1' = [ (0.625,0   , 0) , (0.375,0   , 0) , (0.625,1   , 0)
                 , (0.375,0.67, 0) , (0.375,1   , 0) , (0.25, 0.63, 0)
                 , (0.25, 0.83, 0) ]
letterPath '2' = [ (0   , 0.67, 0) , (0.33, 0.67, 0) , (0   , 0.83, 0)
                 , (0.33, 0.83, 0) , (0.33, 1   , 0) , (0.33, 0.83, 0)
                 , (0.67, 1   , 0) , (0.67, 0.83, 0) , (1   , 0.83, 0)
                 , (0.67, 0.67, 0) , (1   , 0.67, 0) , (0   , 0.16, 0)
                 , (0.33, 0.16, 0) , (0   , 0   , 0) , (1   , 0.16, 0)
                 , (1   , 0   , 0) ]
letterPath '3' = [ (0   , 0.67, 0) , (0.33, 0.67, 0) , (0   , 0.83, 0)
                 , (0.33, 0.83, 0) , (0.33, 1   , 0) , (0.67, 0.83, 0)
                 , (0.67, 1   , 0) , (1   , 0.83, 0) , (0.67, 0.83, 0)
                 , (1   , 0.58, 0) , (0.67, 0.58, 0) , (0.5 , 0.58, 0)
                 , (1   , 0.58, 0) , (0.5 , 0.42, 0) , (1   , 0.42, 0)
                 , (0.67, 0.42, 0) , (1   , 0.16, 0) , (0.67, 0.16, 0)
                 , (0.67, 0   , 0) , (0.33, 0.16, 0) , (0.33, 0   , 0)
                 , (0.33, 0.16, 0) , (0   , 0.16, 0) , (0.33, 0.33, 0)
                 , (0   , 0.33, 0) ]
letterPath '4' = [ (0.83, 0   , 0) , (0.5 , 0   , 0) , (0.83, 0.16, 0)
                 , (0.5 , 0.16, 0) , (1   , 0.16, 0) , (0   , 0.16, 0)
                 , (1   , 0.33, 0) , (0   , 0.33, 0) , (0.16, 0.33, 0)
                 , (0.5 , 1   , 0) , (0.5 , 0.83, 0) , (0.83, 1   , 0)
                 , (0.5 , 0.33, 0) , (0.83, 0.33, 0) ]
letterPath '5' = [ (0   , 0.33, 0) , (0   , 0.16, 0) , (0.33, 0.33, 0)
                 , (0.33, 0   , 0) , (0.33, 0.16, 0) , (0.67, 0   , 0)
                 , (1   , 0.16, 0) , (0.67, 0.5 , 0) , (1   , 0.5 , 0)
                 , (0.67, 0.5 , 0) , (0.67, 0.67, 0) , (0   , 0.5 , 0)
                 , (0.33, 0.67, 0) , (0   , 1   , 0) , (0.33, 0.83, 0)
                 , (1   , 1   , 0) , (1   , 0.83, 0) ]
letterPath '6' = letterPath 'c' ++ [ (0.67, 0.5 , 0) , (1   , 0.5 , 0)
                                   , (0.67, 0.5 , 0) , (0.67, 0.67, 0)
                                   , (0.33, 0.5 , 0) , (0.33, 0.67, 0) ]
letterPath '7' = [ (0.33, 0   , 0) , (0.67, 0   , 0) , (0.33, 0.33, 0)
                 , (0.67, 0.33, 0) , (0.67, 0.67, 0) , (1   , 0.67, 0)
                 , (0.67, 0.83, 0) , (1   , 1   , 0) , (0   , 0.83, 0)
                 , (0   , 1   , 0) ]
letterPath '8' = [ (0   , 0.16, 0) , (0.33, 0   , 0) , (0   , 0.5 , 0)
                 , (0.33, 0.67, 0) , (0.24, 0.58, 0) , (0.33, 0.83, 0)
                 , (0   , 0.67, 0) , (0   , 0.83, 0) , (0.33, 0.83, 0)
                 , (0.33, 1   , 0) , (0.67, 0.83, 0) , (0.67, 1   , 0)
                 , (1   , 0.83, 0) , (0.67, 0.83, 0) , (1   , 0.67, 0)
                 , (0.67, 0.67, 0) , (0.67, 0.5 , 0) , (0.33, 0.67, 0)
                 , (0.33, 0.5 , 0) , (0.67, 0.67, 0) , (0.67, 0.5 , 0)
                 , (1   , 0.5 , 0) , (0.67, 0.16, 0) , (1   , 0.16, 0)
                 , (0.67, 0   , 0) , (0.67, 0.16, 0) , (0.33, 0   , 0)
                 , (0.33, 0.16, 0) ]
letterPath '9' = map (\(x,y,z) -> (1-x,1-y,z)) $ letterPath '6'
letterPath '0' = letterPath 'o'
letterPath '/' = [ (0   , 0   , 0) , (0.25, 0   , 0) , (0.75, 1   , 0)
                 , (1   , 1   , 0) ]
letterPath c
    | isUpper c = letterPath $ toLower c
    | otherwise = [ (0, 1, 0) , (0, 0, 0) , (1, 1, 0) , (1, 0, 0) ]
