Safe Haskell | None |
---|---|
Language | Haskell2010 |
This toolkit is a very simple and lightweight implementation of the bresenham line drawing algorithm. It allows you to follow straight paths on your map very easily.
- type TCODLineListener = Int -> Int -> IO Bool
- lineInitGlobal :: Int -> Int -> Int -> Int -> IO ()
- lineStepGlobal :: IO (Bool, Int, Int)
- lineGlobal :: Int -> Int -> Int -> Int -> TCODLineListener -> IO Bool
- data TCODBresenhamData = TCODBresenhamData {
- bresenStepX :: !Int
- bresenStepY :: !Int
- bresenE :: !Int
- bresenDeltaX :: !Int
- bresenDeltaY :: !Int
- bresenOrigX :: !Int
- bresenOrigY :: !Int
- bresenDestX :: !Int
- bresenDestY :: !Int
- lineInit :: Int -> Int -> Int -> Int -> TCODBresenhamData
- lineStep :: TCODBresenhamData -> (TCODBresenhamData, Bool, Int, Int)
- lineIO :: Int -> Int -> Int -> Int -> TCODLineListener -> IO Bool
- line :: Int -> Int -> Int -> Int -> (Int -> Int -> Bool) -> Bool
Documentation
Initializing the line
First, you have to initialize the toolkit with your starting and ending coordinates.
lineStepGlobal :: IO (Bool, Int, Int) Source #
Walking the line
You can then step through each cell with this function. It returns true when you reach the line's ending point.
:: Int | x from |
-> Int | y from |
-> Int | x to |
-> Int | y to |
-> TCODLineListener | Callback called for each line's point. The function stops if the callback returns false. |
-> IO Bool |
Callback-based function. Stops when the callback returns false
The function returns false if the line has been interrupted by the callback (it returned false before the last point).
data TCODBresenhamData Source #
Holds state of Bresenham algorithm for thread safe version of API
TCODBresenhamData | |
|
:: Int | x from |
-> Int | y from |
-> Int | x to |
-> Int | y to |
-> TCODBresenhamData | State of algorithm that is passed around |
Initializing the line, thread safe version
First, you have to initialize the toolkit with your starting and ending coordinates.
lineStep :: TCODBresenhamData -> (TCODBresenhamData, Bool, Int, Int) Source #
Walking the line, thread safe version
You can then step through each cell with this function. It returns true when you reach the line's ending point.
:: Int | x from |
-> Int | y from |
-> Int | x to |
-> Int | y to |
-> TCODLineListener | Callback called for each line's point. The function stops if the callback returns false. |
-> IO Bool |
Callback-based function. Stops when the callback returns false, thread safe version
The function returns false if the line has been interrupted by the callback (it returned false before the last point).
:: Int | x from |
-> Int | y from |
-> Int | x to |
-> Int | y to |
-> (Int -> Int -> Bool) | Callback called for each line's point. The function stops if the callback returns false. |
-> Bool |
Callback-based function. Stops when the callback returns false, thread safe version
The function returns false if the line has been interrupted by the callback (it returned false before the last point).
Note: that predicated is pure unlike in lineIO