This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Diagrams.FullWindow

Utilities for when you just want to get a diagram on the whole screen.

See Diagrams.Wiring docs for more info on CollageLocations.

fullWindowCollageLocFunc : CollageLocFunc

A location function which always returns a CollageLocation in the middle of the window, filling the whole window.

fullWindowCollageLoc : Signal CollageLocation

Signal of full-window collage locations, updating as the window size changes.

fullWindowUpdates : Signal (CollageLocation, PrimMouseEvent)

Signal of location and mouse updates for when diagram is filling the whole screen.

fullWindowMain : Diagram t a -> Signal E.Element

The easiest way to get a diagram on the screen:

main = fullWindowMain (rect 10 10 (justFill <| Solid Color.orange))
fullWindowView : (Int, Int) -> Diagram t a -> E.Element
module Diagrams.FullWindow where

{-| Utilities for when you just want to get a diagram on the whole screen.

See `Diagrams.Wiring` docs for more info on `CollageLocation`s.

@docs fullWindowCollageLocFunc, fullWindowCollageLoc, fullWindowUpdates, fullWindowMain, fullWindowView
-}

import Window
import Signal as S
import Graphics.Element as E
import Graphics.Collage as C

import Diagrams.Wiring exposing (..)
import Diagrams.Core exposing (..)
import Diagrams.Type exposing (..)

{-| A location function which always returns a `CollageLocation` in the middle of the window,
filling the whole window. -}
fullWindowCollageLocFunc : CollageLocFunc
fullWindowCollageLocFunc dims =
  { offset = (0.0,0.0), dims = dims }

{-| Signal of full-window collage locations, updating as the window size changes. -}
fullWindowCollageLoc : Signal CollageLocation
fullWindowCollageLoc =
  S.map fullWindowCollageLocFunc floatWindowDims

{-| Signal of location and mouse updates for when diagram is filling the whole screen. -}
fullWindowUpdates : Signal (CollageLocation, PrimMouseEvent)
fullWindowUpdates =
  makeUpdateStream fullWindowCollageLocFunc

{-| The easiest way to get a diagram on the screen:

    main = fullWindowMain (rect 10 10 (justFill <| Solid Color.orange))
-}
fullWindowMain : Diagram t a -> Signal E.Element
fullWindowMain dia =
  S.map (\dims -> fullWindowView dims dia) Window.dimensions

{-|-}
fullWindowView : (Int, Int) -> Diagram t a -> E.Element
fullWindowView (w, h) d =
  C.collage w h [render d]