{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} module Poem(Layout(..),poem,Attrib(..)) where -- FIXME: this is a bit silly, but placing these in the language gives -- inference problems. -- grouping = "grouping" -- left = "left" -- center = "center" -- right = "right" -- FIXME: move to Layout.hs {- Layout Params -} import Number type ScaleX = Number type ScaleY = Number type CenterX = Number type CenterY = Number type Duration = Number type Accent = Number type InitialChars = Number type TimeDelay = Number type BeginFrame = Int type EndFrame = Int type FadeSpeed = Number type FGColor = Number type BGColor = Number type Alpha = Number type TimeConst = Number data Attrib = Expand TimeConst (CenterX, CenterY) (ScaleX, ScaleY) -- out-of-bound expand | Scale (ScaleX, ScaleY) -- text scale | Meter [(Duration, Accent)] | Bullet InitialChars TimeDelay TimeDelay | LifeTime BeginFrame EndFrame FadeSpeed | Flash | Zoom TimeConst | White | NbTiles Int -- | PenColor FGColor BGColor Alpha deriving Show type Opts = String {- Layout language -} class Monad m => Layout m el font opts | el -> font opts m, opts -> el font m, m -> el font opts where texta :: [Attrib] -> font -> String -> el text :: font -> String -> el text = texta [] empty :: el rows :: opts -> [el] -> el columns :: opts -> [el] -> el matrix :: [opts] -> [[el]] -> el grouping :: opts left :: opts center :: opts right :: opts imagea :: [Attrib] -> Maybe String -> m () framea :: Number -> el -> m () font :: String -> m font -- type annotated, because inference takes quite long... poem :: Layout m el font opts => m () poem = let e = (4,4) -- default expand bold = Scale (1.7, 1.7) -- bold is just larger, taking into account layout bold2 = Scale (2.5, 2.5) image = imagea [] expand = Expand 2 expandtc = Expand frame = framea 5.0 fadeOut = fadeOutN 1 fadeOutN n = LifeTime 0 n 2 -- Number of frames to live bullet n delay = [bold, Meter[(1.3,1)], Bullet n delay 5, expand (0,0) (1,1)] flag = image $ Just "flag.png" web n = imagea [NbTiles n] $ Just "web.png" in do f <- font "font.ttf" fi <- font "font_italic.ttf" flashWeb <- return $ \n -> do imagea [Flash, NbTiles n] $ Just "web.png" -- FIXME: flash framea 1 $ texta [Meter[(0.5,1)]] f "" imagea [Zoom 0.7] $ Just "flag.png" framea 5 $ texta [Meter[(0.5,1)]] f "" imagea [] $ Just "flag.png" image $ Nothing frame $ rows grouping [rows left [texta [White, expand (0 ,0) e] f "eyes"], rows center [texta [White, expand (0.5,0) e] f "wide"], rows right [texta [White, expand (1, 0) e] f "open"]] {- frame $ text f "1" frame $ text f "2" frame $ text f "3" -} frame $ rows right [texta [White, Meter[(2,1)]] fi "...Oh say does that star-spangled", texta [White, Meter[(2,1)]] fi "banner yet wave..."] flashWeb 1 frame $ matrix [right,left] [[text f "Dad ", texta [bold] f "died"], [text f "from bone marrow ", empty], [text f "transplant ", empty], [text f "complications ", empty], [text f "within the ", texta [expand (0,0) e] f "1st "], [texta [fadeOut] f "year ", empty]] frame $ rows left [text f "The", texta ([fadeOut]++(bullet 3 2)) f " VETERANS", texta ([fadeOut]++(bullet 3 2)) f " AFFAIRS"] frame $ matrix [right,left] [[text f "sent a letter to his ", texta [expand (0, 0.5) e] f "3rd "], [text f "wife since he was ", empty], [text f "married to her the ", empty], [texta [fadeOut, expand (0.35,0) (4,2)] f "longest ", empty]] line <- return $ (\lines -> matrix (map (\_ -> center) lines) [lines]) frame $ rows grouping [rows right [text f "to acknowledge use of", text f "Agent Orange in Vietnam", line [texta [Meter [(0.5,1)]] f "was at ", texta [bold, Meter [(0.5,1)]] f "fault", text f " for vets'"]], -- matrix [center,center,center] -- [[texta [Meter [(0.5,1)]] f "was at ", texta [bold, Meter [(0.5,1)]] f "fault", text f " for vets"]]], --text f "was at fault for vets'" rows left [texta (bullet 1 3) f "CHRONIC", texta (bullet 1 3) f "MYLEOGENOUS", texta ([fadeOut]++(bullet 1 3)) f "LEUKEMIA"]] frame $ matrix [right,left] [[text f "when the letter arrived ", empty], [text f "he would have been ", texta [expand (0,0) e] f "58 "], [text f "already dead ", empty], [texta [fadeOut, expand (0.7,0.2) e] f "7 ", text f "years "]] flashWeb 2 frame $ rows right [line [text f "Diagnosed ", texta [bold] f "after"], text f "diagnosis of", texta [fadeOut] f "CML"] frame $ rows grouping [rows right [text f "Dad's"], rows left [texta (bullet 1 4) f "POST", texta (bullet 1 4) f "TRAUMATIC", texta (bullet 1 4) f "STRESS", texta ([fadeOut]++(bullet 1 4)) f "DISORDER"]] frame $ rows right [text f "hit a number of people", text f "children and wives", text f "with a belt", texta [bold, expand (1,0) (1.5,1), Meter [(2,1)]] f "and words", texta [fadeOut] f "and hands"] frame $ rows right [line [text f "the ", texta [bold] f "same", text f " hands"], text f "that held us", texta [fadeOut] f "with hugs"] flashWeb 3 frame $ rows grouping [rows right [text f "Dad's youngest", text f "enlisted"], rows left [texta (bullet 1 2) f "AIR", texta ([fadeOut]++(bullet 1 2)) f "FORCE"]] frame $ matrix [right,left] [[text f "just before ", empty], [text f "the cut-off ", empty], [text f "age of ", texta [fadeOut, expand (0,0) e] f "28"]] frame $ rows right [text f "a decade older", text f "than Dad who", line [text f "joined the ", texta [bold] f "same"], texta [fadeOut] f "military branch"] frame $ rows right [line [text f "to ", texta [bold] f "escape"], text f "his abusive father", texta [fadeOut] f "dishonorably discharged"] frame $ rows grouping [rows right [text f "from the Navy of"], rows left [texta ([fadeOut]++(bullet 1 3)) f "WORLD", texta ([fadeOut]++(bullet 1 3)) f "WAR", texta ([fadeOut]++(bullet 2 3)) f "II TWO"]] flashWeb 4 frame $ matrix [right,left] [[empty, line [text f " Dad ", texta [bold] f "died"]], [texta [expand (1,0.2) e] f " 13", text f " years ago this "], [empty, texta [fadeOut] f " Thanksgiving "]] frame $ rows grouping [rows right [text f "most of those years the"], rows left [texta (bullet 1 3) f "UNITED", texta (bullet 1 3) f "STATES OF", texta ([fadeOut] ++ (bullet 1 3)) f "AMERICA"]] frame $ rows right [text f "has warred on the ", line [texta [bold, fadeOutN 2, expandtc 10 (1,0) (1.5,1), Meter [(1,1)]] f "peoples", text f " "], text f "of Afghanistan ", text f "and Iraq "] frame $ rows right [text f "as we have warred on ", -- line [texta [bold, fadeOut, expand (1,0) (1.5,1), Meter [(1,1)]] f "peoples", text f " "], empty, text f "of this continent and ", text f "all over the world "] frame $ rows grouping [rows left [text f "steeping"], rows center [text f "our nation's story"], rows right [line [text f "in ", texta [fadeOut, bold] f "blood"]]] image $ Nothing frame $ rows grouping [rows left [texta [White, Meter[(2,1)]] fi "... for the land of the free"], rows right [texta [White, Meter[(2,1)]] fi "and the home of the brave ..."]] {- Two background photos: flag is full screen, and web is small in center. The web expands while the flag shrinks for the following frames. There are four frames for this "swap", this one being the first (as the text is appearing), -} flashWeb 4 -- Start with flag in background, but keep it as a transition frame. imagea [fadeOutN 6] $ Just "flag.png" framea 1 $ empty -- Start mixing in web web 1 frame $ rows grouping [rows right [text f "These memories spun", text f "while tending"], rows left [texta (bullet 1 3) f "EYES", texta (bullet 1 3) f "WIDE", texta ([fadeOut]++(bullet 1 3)) f "OPEN"]] web 2 frame $ rows right [text f "an exhibit about", text f "human loss", text f "from certain", texta [fadeOut] f "US invasions"] web 3 frame $ rows right [line [text f "The boots ", text f "the shoes ", text f "the tiles"], line [text f "evoke ",texta [bold] f "not only", text f " the killed but"], texta [fadeOut, expand (1,0) (1.5,1)] f "all their loved ones"] web 4 framea 3 $ empty web 5 framea 3 $ empty web 6 frame $ rows grouping [rows left [line [text f "The web is ", texta [expand (0,0) (1.5,1)] f "wide" ]], rows center [text f "the strands are many"], rows right [texta [fadeOut] f "and hope connects us"]] frame $ rows right [texta [fadeOutN 3, bold, expandtc 10 (1,0) (1.5,1), Meter [(1,1)]] f "as long as", line [text f "we ", texta [bold] f "see"], text f "ourselves", texta [fadeOut] f "in one another", text f ""] frame $ rows right [texta [bold] f "", -- text f "as long as", text f "we remember", texta [fadeOut, bold] f "everyone", text f "is someone's child", empty] frame $ rows right [texta [fadeOut,bold] f "", -- text f "as long as", texta [fadeOut] f "we turn", texta [fadeOut] f "to the Light", texta [fadeOut] f "that holds us", texta [fadeOutN 2, bold, expandtc 10 (1,0) (4,4), Meter [(1,1)]] f "all"] -- dummy frames framea 10 $ rows right [text f "", text f ""] framea 10 $ rows right [text f "", text f ""] -- frame $ matrix [center] [[texta [Meter[(3,1)], bold, expand (0.5,0) e] f "ALL"]] {- frame $ rows right [empty, empty, empty, empty, texta [Meter[(0,1)], bold, expand (1,0) e] f "all"] -}