Last active
August 29, 2015 14:02
-
-
Save mk2/b91056f636750320fee7 to your computer and use it in GitHub Desktop.
GridDraw_ELM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-- | |
グリッドを描く例 | |
--} | |
import List (..) | |
data Cell a = Blank a | Filled a | Outlined a | Other a | Nothing | |
type CellInfo = { width : Float | |
, height : Float | |
, color : Color | |
} | |
xCoords side = | |
concat . repeat side <| [1 .. side] | |
yCoords side = | |
concat . map (repeat side) <| [1 .. side] | |
xyCoords side = | |
zip (xCoords side) (yCoords side) | |
xycCoords side = | |
zip (xCoords side) (yCoords side) |> zipWith (\(x, y) c -> (x, y, c)) | |
drawXy (x, y, c) = (x, y, c) | |
drawGrid f xys = | |
map f <| xys | |
main = asText <| drawGrid drawXy <| xycCoords 8 <| repeat 64 Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment