2 | module IdrisGL.SDL.SDL_ttf
4 | import IdrisGL.DataType
7 | textStyle2Code : TextStyle -> Int
8 | textStyle2Code TS_NORMAL = 0
9 | textStyle2Code TS_BOLD = 1
10 | textStyle2Code TS_ITALIC = 2
11 | textStyle2Code TS_UNDERLINE = 3
12 | textStyle2Code TS_STRIKETHROUGH = 4
14 | textHinting2Code : TextHinting -> Int
15 | textHinting2Code TH_NORMAL = 0
16 | textHinting2Code TH_LIGHT = 1
17 | textHinting2Code TH_MONO = 2
18 | textHinting2Code TH_NONE = 3
24 | frgn : String -> String
25 | frgn func = "C:" ++ func ++ ",sdl_ttf"
29 | %foreign frgn "drawText"
30 | prim_drawText : AnyPtr
31 | -> String -> Int -> String
33 | -> Int -> Int -> Int -> Int
41 | drawText : HasIO io => Renderer
42 | -> (text : String) -> (size : Int) -> (font : String)
43 | -> Coordinate -> Color
45 | drawText (MkRenderer ren) text size font (MkCoor x y) color
46 | = let (r,g,b,a) = rgbaOfColor color in
47 | primIO $
prim_drawText ren text size font x y r g b a
51 | %foreign frgn "drawSolidText"
52 | prim_drawSolidText : AnyPtr
53 | -> String -> Int -> String
54 | -> Int -> Int -> Int
56 | -> Int -> Int -> Int -> Int
65 | drawSolidText : HasIO io => Renderer
66 | -> (text : String) -> (size : Int) -> (font : String)
67 | -> TextStyle -> (kerning : Int) -> TextHinting
68 | -> Coordinate -> Color -> io ()
69 | drawSolidText (MkRenderer ren) text size font style kerning hinting (MkCoor x y) color
70 | = let (r,g,b,a) = rgbaOfColor color
71 | s = textStyle2Code style
72 | h = textHinting2Code hinting in
73 | primIO $
prim_drawSolidText ren text size font s kerning h x y r g b a
77 | %foreign frgn "drawBlendedText"
78 | prim_drawBlendedText : AnyPtr
79 | -> String -> Int -> String
80 | -> Int -> Int -> Int
82 | -> Int -> Int -> Int -> Int
91 | drawBlendedText : HasIO io => Renderer
92 | -> (text : String) -> (size : Int) -> (font : String)
93 | -> TextStyle -> (kerning : Int) -> TextHinting
94 | -> Coordinate -> Color -> io ()
95 | drawBlendedText (MkRenderer ren) text size font style kerning hinting (MkCoor x y) color
96 | = let (r,g,b,a) = rgbaOfColor color
97 | s = textStyle2Code style
98 | h = textHinting2Code hinting in
99 | primIO $
prim_drawBlendedText ren text size font s kerning h x y r g b a
103 | %foreign frgn "drawShadedText"
104 | prim_drawShadedText : AnyPtr
105 | -> String -> Int -> String
106 | -> Int -> Int -> Int
108 | -> Int -> Int -> Int -> Int
109 | -> Int -> Int -> Int -> Int
120 | drawShadedText : HasIO io => Renderer
121 | -> (text : String) -> (size : Int) -> (font : String)
122 | -> TextStyle -> (kerning : Int) -> TextHinting
123 | -> Coordinate -> (color1 : Color) -> (color2 : Color)
125 | drawShadedText (MkRenderer ren)
127 | style kerning hinting
128 | (MkCoor x y) color1 color2
129 | = let (r1,g1,b1,a1) = rgbaOfColor color1
130 | (r2,g2,b2,a2) = rgbaOfColor color2
131 | s = textStyle2Code style
132 | h = textHinting2Code hinting in
133 | primIO $
prim_drawShadedText ren text size font s kerning h x y r1 g1 b1 a1 r2 g2 b2 a2