Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Calendar where
- import Control.Monad.Eff
- import Graphics.Canvas hiding (translate)
- import Prelude
- import Data.Array
- import Data.Foldable
- import Data.Traversable
- background = "#000000"
- type Position = { x :: Number, y :: Number }
- drawDay :: forall eff. Rectangle -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
- drawDay r ctx = do
- setFillStyle "#92b5c8" ctx
- setShadowBlur 0 ctx
- fillRect ctx r
- setFont "18px Arial" ctx
- setFillStyle "#FFFFFF" ctx
- fillText ctx "10" (r.x+4) (r.y+21)
- dayRect pos n = {x: pos.x + 31 * n, y: pos.y, w: 30, h: 30}
- combineArray :: forall f a. (Applicative f) => [f a] -> f [a]
- combineArray [] = pure []
- combineArray (x : xs) = (:) <$> x <*> combineArray xs
- drawNDays :: forall eff. Number -> Position -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
- drawNDays n pos ctx = traverse (\ddd -> drawDay (dayRect pos ddd) ctx) (1 .. 7)
- drawWeek :: forall eff. Position -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
- drawWeek pos ctx = drawNDays 7 pos ctx
- drawNWeeks :: forall eff. Number -> Position -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
- drawNWeeks 1 pos ctx = drawWeek pos ctx
- drawNWeeks n pos ctx = do
- drawWeek {x: pos.x, y: pos.y + ((n-1)*31)} ctx
- drawNWeeks (n-1) pos ctx
- drawMonth :: forall eff. Position -> Context2D -> Eff (canvas :: Canvas | eff) Context2D
- drawMonth pos ctx = do
- drawNWeeks 4 pos ctx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement