Skip to content

Instantly share code, notes, and snippets.

@mk2
Last active August 29, 2015 14:02
Show Gist options
  • Save mk2/b91056f636750320fee7 to your computer and use it in GitHub Desktop.
Save mk2/b91056f636750320fee7 to your computer and use it in GitHub Desktop.
GridDraw_ELM
{--
グリッドを描く例
--}
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