Changeset 20925 for lang/haskell/nario/Font.hs
- Timestamp:
- 10/07/08 20:42:00 (3 months ago)
- Files:
-
- 1 modified
-
lang/haskell/nario/Font.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/nario/Font.hs
r20670 r20925 1 -- -*- mode: haskell; Encoding: UTF-8 -*- 1 2 -- Bitmap font 2 3 module Font ( 4 Font(..), 3 5 fontPut, 4 6 fontPutc 5 7 ) where 6 8 7 import Multimedia.SDL 8 import Control.Monad 9 import Data.Char 9 import Multimedia.SDL (blitSurface, pt, Rect(..), Surface) 10 import Control.Monad (zipWithM_) 11 import Data.Char (ord) 10 12 11 fontWidth = 8 12 fontHeight = 8 13 fontXN = 16 13 data Font = Font { 14 fontSurface :: Surface, 15 fontWidth :: Int, 16 fontHeight :: Int, 17 fontXN :: Int 18 } 19 14 20 15 21 -- 文字列表示 16 fontPut sur imgsur x y str = zipWithM_ (\i c -> fontPutc sur imgsur i y c) [x..] str22 fontPut font sur x y str = zipWithM_ (\i c -> fontPutc font sur i y c) [x..] str 17 23 18 24 -- 1文字表示 19 fontPutc sur imgsur x y c = do20 blitSurface imgsur(Just rc) sur pos25 fontPutc font sur x y c = do 26 blitSurface (fontSurface font) (Just rc) sur pos 21 27 where 22 pos = pt (x * fontWidth) (y * fontHeight)28 pos = pt (x * (fontWidth font)) (y * (fontHeight font)) 23 29 ic = ord c - ord ' ' 24 u = (ic `mod` fontXN) * fontWidth 25 v = (ic `div` fontXN) * fontHeight 26 rc = Rect u v fontWidth fontHeight 30 u = (ic `mod` xn) * w 31 v = (ic `div` xn) * h 32 rc = Rect u v w h 33 34 xn = fontXN font 35 w = fontWidth font 36 h = fontHeight font
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)