packages feed

grid 1.0 → 1.1

raw patch · 3 files changed

+66/−6 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

grid.cabal view
@@ -1,5 +1,5 @@ name:           grid-version:        1.0+version:        1.1 synopsis:       Tools for working with regular grids\/graphs\/lattices. description:    Provides tools for working with regular arrangements                 of tiles, such as might be used in a board game or some
src/Math/Geometry/Grid.hs view
@@ -16,14 +16,14 @@  module Math.Geometry.Grid   (-    -- * Generic+    -- * The Grid class     Grid(..),     -- * Grids with triangular tiles     TriTriGrid,     triTriGrid,     ParaTriGrid,     paraTriGrid,-    -- Grids with square tiles+    -- * Grids with square tiles     RectSquareGrid,     rectSquareGrid,     TorSquareGrid,@@ -33,8 +33,60 @@     hexHexGrid,     ParaHexGrid,     paraHexGrid+    -- * Example+    -- $Example   ) where  import Math.Geometry.GridInternal (Grid(..), TriTriGrid, triTriGrid,    ParaTriGrid, paraTriGrid, RectSquareGrid, rectSquareGrid, TorSquareGrid,    torSquareGrid, HexHexGrid, hexHexGrid, ParaHexGrid, paraHexGrid)++{- $Example+   Create a grid.++>ghci> let g = hexHexGrid 3+>ghci> indices g+>[(-2,0),(-2,1),(-2,2),(-1,-1),(-1,0),(-1,1),(-1,2),(0,-2),(0,-1),(0,0),(0,1),(0,2),(1,-2),(1,-1),(1,0),(1,1),(2,-2),(2,-1),(2,0)]++   Find out the minimum number of moves to go from one tile in a grid to another+   tile, moving between adjacent tiles at each step.++>ghci> distance (0,-2) (0,2) g+>4++   Find out the minimum number of moves to go from one tile in a grid to any +   other tile, moving between adjacent tiles at each step.++>ghci> viewpoint (1,-2) g+>[((-2,0),3),((-2,1),3),((-2,2),4),((-1,-1),2),((-1,0),2),((-1,1),3),((-1,2),4),((0,-2),1),((0,-1),1),((0,0),2),((0,1),3),((0,2),4),((1,-2),0),((1,-1),1),((1,0),2),((1,1),3),((2,-2),1),((2,-1),2),((2,0),3)]++   Find out which tiles are adjacent to a particular tile.++>ghci> neighbours (-1,1) g+>[(-2,1),(-2,2),(-1,2),(0,1),(0,0),(-1,0)]++   Find out if a tile is within the grid boundary.++>ghci> inGrid (0,0) g+>True+>ghci> inGrid (0,12) g+>False++   Find out the physical dimensions of the grid.++>ghci> size g+>3++   Find out the number of tiles in the grid.++>ghci> tileCount g+>19++   Check if a grid is empty (contains no tiles).++>ghci> empty g+>False+>ghci> nonEmpty g+>True++-}
src/Math/Geometry/GridInternal.hs view
@@ -105,7 +105,7 @@  -- | A triangular grid with triangular tiles. --   The grid and its indexing scheme are illustrated in the user guide,---   available from +--   available at https://github.com/mhwombat/grid/wiki. data TriTriGrid = TriTriGrid Int [(Int, Int)]  instance Show TriTriGrid where show (TriTriGrid s _) = "triTriGrid " ++ show s@@ -136,6 +136,8 @@ --  -- | A Parallelogrammatical grid with triangular tiles.+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at https://github.com/mhwombat/grid/wiki. data ParaTriGrid = ParaTriGrid (Int, Int) [(Int, Int)]  instance Show ParaTriGrid where @@ -161,6 +163,8 @@ --  -- | A rectangular grid with square tiles.+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at https://github.com/mhwombat/grid/wiki. data RectSquareGrid = RectSquareGrid (Int, Int) [(Int, Int)]  instance Show RectSquareGrid where @@ -187,6 +191,8 @@ --  -- | A toroidal grid with square tiles.+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at https://github.com/mhwombat/grid/wiki. data TorSquareGrid = TorSquareGrid (Int, Int) [(Int, Int)]  instance Show TorSquareGrid where @@ -230,6 +236,8 @@ --  -- | A hexagonal grid with hexagonal tiles+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at https://github.com/mhwombat/grid/wiki. data HexHexGrid = HexHexGrid Int [(Int, Int)]  instance Show HexHexGrid where show (HexHexGrid s _) = "hexHexGrid " ++ show s@@ -253,6 +261,8 @@ --  -- | A parallelogramatical grid with hexagonal tiles+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at https://github.com/mhwombat/grid/wiki. data ParaHexGrid = ParaHexGrid (Int, Int) [(Int, Int)]  instance Show ParaHexGrid where @@ -273,5 +283,3 @@ paraHexGrid ∷ Int → Int → ParaHexGrid paraHexGrid r c =    ParaHexGrid (r,c) [(x, y) | x ← [0..c-1], y ← [0..r-1]]--